-
Notifications
You must be signed in to change notification settings - Fork 8
echo
Purpose: Prints text to all connected telnet terminals.
Syntax: echo {[value] values...}
{[value] values...}: A series of values containing the text to be echoed.
Note: If you would like to convert ascii menu boxes to CP437 drawing chars use echoEx.
Notes: This command is the primary way of displaying text in connected clients without sending it to the server. Using this command, you can output data from your script, create menus, etc.
Example:
# Get a product type using a menu
:GetProduct
echo "*" ANSI_15 "Select Product:" "**"
echo ANSI_11 "1 " ANSI_3 " - Fuel Ore*"
echo ANSI_11 "2 " ANSI_3 " - Organics*"
echo ANSI_11 "3 " ANSI_3 " - Equipment*"
getConsoleInput $Product SINGLEKEY
if ($Product <> 1) and ($Product <> 2) and ($Product <> 3)
goto :GetProduct
end
Additional Notes:
A lot of people believe that the following two lines of code do the same thing in TWX (and would be forgiven for thinking that, since the reasons why they don't are not obvious):
a) echo "Output test " & $testnum & " of " & $testcount & "" b) echo "Output test " $testnum " of " $testcount ""
They are actually compiled very differently.
Line (a) is translated into the following system commands (this output is from my decompiler debug function):
<S0> <L1> ---START COMMAND---
<S0> <L1> COMMAND: MERGETEXT
<S0> <L1> PARAM_VAR: $TESTCOUNT
<S0> <L1> PARAM_CONST: "*"
<S0> <L1> PARAM_VAR: $$7
<S0> <L1> MERGED $$7 = $TESTCOUNT & "*"
<S0> <L1> ---END COMMAND---
<S0> <L1> ---START COMMAND---
<S0> <L1> COMMAND: MERGETEXT
<S0> <L1> PARAM_CONST: " of "
<S0> <L1> PARAM_VAR: $$7
<S0> <L1> PARAM_VAR: $$5
<S0> <L1> FOUND VAR: $$7 = $TESTCOUNT & "*"
<S0> <L1> MERGED $$5 = " of " & $TESTCOUNT & "*"
<S0> <L1> ---END COMMAND---
<S0> <L1> ---START COMMAND---
<S0> <L1> COMMAND: MERGETEXT
<S0> <L1> PARAM_VAR: $TESTNUM
<S0> <L1> PARAM_VAR: $$5
<S0> <L1> PARAM_VAR: $$3
<S0> <L1> FOUND VAR: $$5 = " of " & $TESTCOUNT & "*"
<S0> <L1> MERGED $$3 = $TESTNUM & " of " & $TESTCOUNT & "*"
<S0> <L1> ---END COMMAND---
<S0> <L1> ---START COMMAND---
<S0> <L1> COMMAND: MERGETEXT
<S0> <L1> PARAM_CONST: "Output test "
<S0> <L1> PARAM_VAR: $$3
<S0> <L1> PARAM_VAR: $$1
<S0> <L1> FOUND VAR: $$3 = $TESTNUM & " of " & $TESTCOUNT & "*"
<S0> <L1> MERGED $$1 = "Output test " & $TESTNUM & " of " & $TESTCOUNT & "*"
<S0> <L1> ---END COMMAND---
<S0> <L1> ---START COMMAND---
<S0> <L1> COMMAND: ECHO
<S0> <L1> PARAM_VAR: $$1
<S0> <L1> FOUND VAR: $$1 = "Output test " & $TESTNUM & " of " & $TESTCOUNT & "*"
<S0> <L1> ---END COMMAND---
Line (b) looks like this:
<S0> <L3> ---START COMMAND---
<S0> <L3> COMMAND: ECHO
<S0> <L3> PARAM_CONST: "Output test "
<S0> <L3> PARAM_VAR: $TESTNUM
<S0> <L3> PARAM_CONST: " of "
<S0> <L3> PARAM_VAR: $TESTCOUNT
<S0> <L3> PARAM_CONST: "*"
<S0> <L3> ---END COMMAND---
So to summarize, using (a) requires the twx program to execute the following internal commands:
MERGETEXT $TESTCOUNT "*" $$7
MERGETEXT " of " $$7 $$5
MERGETEXT $TEXTNUM $$5 $$3
MERGETEXT "Output test " $$3 $$1
ECHO $$1
While (b) results in the following command:
ECHO "Output test " $testnum " of " $testcount "*"
.