Programmer Guide/Command Reference/STXCONSTANTS: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 7: Line 7:
If no <var>table</var> argument is supplied, the command will return the respective list as a string containing the names of all constants, separated by blanks.
If no <var>table</var> argument is supplied, the command will return the respective list as a string containing the names of all constants, separated by blanks.


If you do not know what constants {{STX}} supports, i.e., what values you may supply for <var>constanttype</var> (we don't know this either!), the second form of the <code>STXCONSTANTS</code> comnmand comes in handy: If you supply the command only with an asterisk for its arguments, the command will return a list of constant types, cleanly separated by blanks. If you add the <var>table</var> argument, which must be a table, the list of constant types will be stored in the table, one entry per constant (any old content of the table will get lost). In the latter case, the command returns the number of the supported constants. Now isn't all that gorgeous!
If you do not know what constants {{STX}} supports, i.e., what values you may supply for <var>constanttype</var> (we don't know this either!), the second form of the <code>STXCONSTANTS</code> command comes in handy: If you supply the command only with an asterisk for its arguments, the command will return a list of constant types, cleanly separated by blanks. If you add the <var>table</var> argument, which must be a table, the list of constant types will be stored in the table, one entry per constant (any old content of the table will get lost). In the latter case, the command returns the number of the supported constants. Now isn't all that gorgeous!


== Examples ==
== Examples ==

Revision as of 21:19, 29 April 2014

var := STXCONSTANTS constanttype [ table ]
var := STXCONSTANTS *  [ table ]

The STXCONSTANT command returns the list of constants of a certain type, constanttype (see below). If the table argument is present, then it must specify an STx table. In this case, the table will be cleared, and the respective list of constants will be stored in the table, one entry per constant. In this case, the command will return the total number of constants returned.

If no table argument is supplied, the command will return the respective list as a string containing the names of all constants, separated by blanks.

If you do not know what constants STx supports, i.e., what values you may supply for constanttype (we don't know this either!), the second form of the STXCONSTANTS command comes in handy: If you supply the command only with an asterisk for its arguments, the command will return a list of constant types, cleanly separated by blanks. If you add the table argument, which must be a table, the list of constant types will be stored in the table, one entry per constant (any old content of the table will get lost). In the latter case, the command returns the number of the supported constants. Now isn't all that gorgeous!

Examples

#stxConstants := STXCONSTANTS *

STx will return a blank-separated list of the constants supported. In turn, each word in this list is valid for the constanttype argument to the VAR STXCONSTANTS command.

#nConstants := STXCONSTANTS * item7

Stores all constants supported by the VAR STXCONSTANTS command in the table item7, and returns their the number, which, in turn, gets assigned to #nConstants.

#nColors := STXCONSTANTS COLORS colorTable

Adds all supported color constants to the table colorTable and stores the number of entries in #nColors.

Navigation menu

Personal tools