|
||
| Contents -> REFERENCE MANUAL -> Syntax Description -> Variables | |
| spec Manual | |
2.3.13. - VariablesA variable is brought into existence simply by using it. Variables assigned values at the top level (outside of any curly-bracketed statement block) are automatically made global. Otherwise, unless explicitly given global attributes, the scope of a variable lies only within the statement or statement block in which it occurs. The possible attributes of a variable are as follows:
Variables can have string, number or array type and may have both string and number types simultaneously. The print
command always prints the string representation of a variable.
The formatted printing commands
printf, fprintf and
sprintf print the string or number value, depending on the format specification.
If the string value cannot be interpreted as a
number, its number value is zero.
All number values are maintained as double-precision
floating-point quantities.
Uninitialized variables have a number value of zero and a string value of "" (the null string).
Although associative
array indices are internally derived from the string value
of the index expression,
if the index is an uninitialized variable, its value for
purposes of indexing the array is the string
"0" . Functions such as input(),
getline(),
gpib_get()
and
ser_get()
return string values that possibly represent numbers.
When the string is used in a number context, automatic string to number
conversion takes place.
The conversion rules require that there are
no extraneous characters in the string.
An initial
0x or
0X introduces a hexadecimal integer.
An initial
0 introduces an octal constant, unless there is a decimal point or an
e or
E exponential string, in which case the entire string is interpreted as
a decimal number, leading zero notwithstanding.
|
Top
|
|
Prev | Next
|
|