Programmer Guide/Command Reference/STXCONSTANTS: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
  <var>var</var> := STXCONSTANTS * | <var>keyword</var> <var>table</var>
  <var>var</var> := STXCONSTANTS <var>constanttype</var> [ <var>table</var> ]
<var>var</var> := STXCONSTANTS *  [ <var>table</var> ]


The <code>STXCONSTANT</code> command returns the list of constants supported in {{STX}} dependant on the <var>keyword</var>. If argument <var>table</var> is passed, and is a table, the respective table is emptied, a new entry is added for each constant, and the number of entries is returned. If no table is passed, a space delimited concatenated string of the constants is returned.
The <code>STXCONSTANT</code> command returns the list of constants of a certain type, <var>constanttype</var> (see below). If the <var>table</var> 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 <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> 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 {{Stx}} gorgeous!


== Examples ==
== Examples ==


  #stxConstants := STXCONSTANTS *
  <var>#stxConstants</var> := STXCONSTANTS *
Returns a blank separated list of constants supported by the <code>VAR STXCONSTANTS</code> command
{{Stx|caps}} will return a blank-separated list of the constants supported. In turn, each word in this list is valid for the  <var>constanttype</var> argument to the <code>VAR STXCONSTANTS</code> command.


  #nConstants := STXCONSTANTS * table       
  <var>#nConstants</var> := STXCONSTANTS * <var>item7</var>
Adds all constants supported by the <code>VAR STXCONSTANTS</code> command to the <code>table</code> and stores the number of entries in the variable <code>#nConstants</code>.
{{STX|caps}} stores all constants supported by the <code>VAR STXCONSTANTS</code> command in the table <var>item7</var>, and returns their the number, which, in turn, gets assigned to <var>#nConstants</var>.


  #nColors := STXCONSTANTS COLORS colorTable
  <var>#nColors</var> := STXCONSTANTS COLORS <var>colorTable</var>
Adds all supported color constants to the table <code>colorTable</code> and stores the number of entries in <code>#nColors</code>.
{{STx|caps}} stores all supported color constants in the table <var>colorTable</var> and stores the number of entries in <var>#nColors</var>.

Latest revision as of 21:22, 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 STx 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

STx 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

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

Navigation menu

Personal tools