Home, Up: Variables and User-Defined Constants
On this page:
Variable Names, Creating a Variable, The $myv = Assign Command, The STO Command, Viewing Variables, Deleting a Variable.
The name of a variable must begin with the dollar sign $. Hypatia assumes anything that begins with $ to be a variable.
Variable names can not contain spaces.
Since anything you type (apart from comments) is converted to lower case, variable names are case insensitive.
The variables $loop and $zero have special meanings, do not use them except for their intended purposes.
$ and $$ are pseudo variables (see Chain Calculations, $ and $$), you cannot assign values to them as described below.
$myv (short for $myvariable) stands here for any variable name you may want to use.
You create a variable by assigning it a value. This can be done in three ways:
- The assign command $myv = followed by a number, a constant, another variable, or a mathematical expression.
- The STO $myv command.
- The PROMPT $myv command, but for this we have to wait until the chapter "Scripts".
At any time you can assign a different value to the variable -- that's their purpose, after all.
There is no limit to the numbers of variables you may use.
Hypatia forgets the variables when you close the program, but you can save them -- see the next page.
This is the method you will probably want to use -- the variable name, followed by an equal sign, followed by anything that amounts to a single numerical value.
There must be a space before and after the eqal sign!
Note that, even though the part after the equal sign gets calculated, $myv = is a command, which for instance means that the recent calculation result $ is not updated!
Unlike other commands, though, the $myv = line gets written to the file hyin.
Examples:
$length = 7.5
$area = $length SQ
$n = $n 1 +
Anything that would be a valid calculation line can stand to the right of the equal sign.
STO $myv stores the recent calculation result (the value of the pseudo variable $) in the variable $myv.
You could do the same by entering $myv = $ -- the STO command mostly exists for historic reasons, but you may still find it useful.
SHOW shows the values of all currently defined variables, including $ and $$.
SHOW $myv shows the value of variable $myv.
In case that you have set angle unit to degrees (default is radians) a respective note will be displayed, since some values might be angles.
You can list more than one variable after the SHOW command:
SHOW $var1 $var2 $var3 etc.
(The list of variables to show can include loop index I and loop timer TIME, see chapter "Scripts and Loops".)
DEL $myv deletes the variable $myv.
Note that the command DEL can only delete a single variable at a time.
Home, Up: Variables and User-Defined Constants, Next: Saving Variables