next up previous contents
Next: view Up: Commands Previous: val   Contents


   'valu' <name> [[<value>|['push' [<splitkey>]]|'pop'] [nr]] | ->
          'sqr'|'sin'|'cos'|'tan'|'asin'|'acos'|'atan'] ->
          'int'|'float'|'exp' ->
         [name|<const> name|<const>] ]
An entity which stores a string of characters. Most characters are valid but no white-spaces are accepted from the command line. The command parser will scan each parameter of each command for expressions which match the name of a value and will replace the parameter by the content of the value. For example

pnt P0 xvalue 0. 0.

uses the value 'xvalue'. If the user has previously defined the value with:

valu xvalue 1.24

then the command-parser will replace 'xvalue' by '1.24' in the 'pnt' command.

ATTENTION: To suppress the substitution the value has to be masked by a leading '\'. For example the command:

del v \value

will delete the value itself. For convenience this masking works for all commands except 'valu' itself! The 'valu' command does not treat its own parameters as values and will not substitute them by previously defined ones. If this functionallity is needed then the ``val'' command has to be used.

The content of a value can be defined by the user

valu arg1 1.24

or derived from the stack previously filled by a command

valu arg1 pop

if the ''stack'' was activated. A certain number on the stack can be addressed with

valu arg1 pop 2

were the '2' means that 2 successive 'pops' are executed. In this way the second value on the stack can be loaded at once.

Values can be added to a set

seta valset v all

and can then be deleted by zapping ``zap'' the set storing the values.

Values can be written to the stack when the 'push' parameter is used:

valu arg1 push

A white-space separated string stored in a ``valu'' will be written to the stack in separate sub-strings. With this method single pieces of a white-space separated string can be splitted and stored in separate values:

stack on

opens the stack

valu complicatedString push

splits the string stored in 'complicatedString' and writes the single pieces to the stack. The command

valu subString pop 3

loads the 3rd substring into the varible 'subString'. Other splitting characters can be used when this character follows the push key-word:

valu string push .

splits the string at each occurence of ``.'' and writes the pieces to the stack.

The command is able to perform simple calculations like

valu result * arg1 arg2

'result' will store the product from 'arg1' and 'arg2'. The two arguments arg1 and arg2 may be other 'values' or constant numbers. That means that a direct multiplication of two numbers or a value with a number is possible. During the calulation the strings are converted to double precision numbers and the result is stored as a string representing an exponential number. The 'int', 'float' and 'exp' convert between integer, floating point and exponential format:

valu result int result

The '?' operator is used to request user input:

valu string ?

The command is waiting for user input. Please type into the terminal. Usually this requires to leave the graphics window and click into the terminal from which cgx was started.

The '&' operator is used to concatenate two strings:

valu string3 & string1 string2

The string1 and string2 might be values or constant strings.

See also ``prnt'' and ''How to write values to a file''.

next up previous contents
Next: view Up: Commands Previous: val   Contents
root 2018-12-15