Command
var
Purpose
Declares variables.
Aliases
var, variable
Syntax
var [<options>] <type> <name> [<name> ...]
Options
-g Global. If this option is specified, the variable(s) being declared are available
not only locally (such as within a do....done block, function, script, etc.)
but are also available throughout (globally). Wihout this option, the variable(s)
are available only locally.
Global variables must not already be declared anywhere else. Global variables can
not be declared again (overloaded) anywhere else.
Arguments
<type> This is the type of the variable(s). Following types are supported.
bool or boolean Boolean or logical variable whose values can be TRUE or FALSE.
int or integer Integer variable.
real Real variable.
str or string String variable.
<name> This is the name of the variable. Variable names can contain any alphabetic
characters from a to z, from A to Z, any digits from 0 to 9, underscrore (_).
The first character must not be a digit.
Variable names are case-sensitive.
Stream Input
Ignored.
Stream Output
None.
Stream Error
Any errors are listed here.
Description
This command declares one or more variables.
Multiple variables can be declared in the same var command. There names must be separated by
spaces. Commas are treated as spaces.
Once declared, the variable value can be set using the set command. The value of the variable can
be accessed by prepending its name with a $.
Variable types can not be mixed during declaration, but they can be mixed during access. When types
are mixed during access, all types are converted upward in order of operability. See help pages on
conversion and make for more details.
Some variable names are predefined by the system. They are called 'system variables'. See help
page on systemvar.
Restrictions
Variable names can not begin with $ sign.
All system variables (see systemvar) are declared global.
Valid Examples
var integer i
Will declare an integer variable i.
var int i
set $i=$i+5
echo $i
Will declare an integer variable i, add 5 to its default value (0), then print the resulting value.
var real x y z
Will declare variables x, y, and z, all of same type - real.
Invalid Examples
integer i
Will produce an error. The command var is missing before the variable type int.
var int i, real x
This is misleading. Since there are NO reserved words, the above will declare i, real, and x
as int variables. If the intention is to declare i as int variable, and x as real variable, use
the following instead.
var int i ; var real x
See Also
echo
set
conversion
make
constant
systemvar
|
© 2008-2010, biterScripting.com. All rights reserved.
biterScripting, biterScript, biterBrowser, biterScripting.com, FVA (Forward Variable Assignment) are trademarks of biterScripting.com. Is it biterScripting-compatible ? is a service mark of biterScripting.com.
Explorer, Unix, Windows are trademarks, service marks or other forms of intellectual property of their respective owners.
|