Difference between revisions of "Variable Names"

From OSUPDOCS
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 5: Line 5:
Variables are defined and used in the form <tt>#varname</tt> where <tt>varname</tt> is any valid variable name. A number sign must always be used to indicate a variable (although the number sign is optional in [[NairnFEAMPMViz]], it is recommended to use it for compatibility). The rules for a valid variable name after the number sign (or entire name if number sign omitted in [[NairnFEAMPMViz]]) are:
Variables are defined and used in the form <tt>#varname</tt> where <tt>varname</tt> is any valid variable name. A number sign must always be used to indicate a variable (although the number sign is optional in [[NairnFEAMPMViz]], it is recommended to use it for compatibility). The rules for a valid variable name after the number sign (or entire name if number sign omitted in [[NairnFEAMPMViz]]) are:


* It must start with a letter or underscore.
* It must start with a letter (a-z or A-Z) or an underscore (_).
* It can be followed by any number of additional upper or lower case letters, underscores, or numbers.
* It can be followed by any number of additional upper (A-Z) or lower (a-z) case letters, underscores (_), or numbers (0-9).
* It may end in a dollar sign ($).
* Variable names are case sensitive.
* Variable names are case sensitive.
* In [[NairnFEAMPM]], the name cannot contain any [[Expression Syntax#Supported Functions|numeric function]] as a substring in the name.
* In [[NairnFEAMPMViz]], string variables must end in a dollar sign ($) while numeric variables must not. In [[NairnFEAMPM]], a variable can optionally end in a dollar sign ($) and for compatibility, it is good practice to end string variables with a dollar sign.
 
* In [[NairnFEAMPMViz]], the name cannot contain any [[Expression Syntax#Supported Functions|supported function name]] as a substring within the name.
In [[NairnFEAMPM]], any variable can be a numeric or a string variable. In [[NairnFEAMPMViz]], string variables must end in a dollar sign ($) and numeric variables cannot end in a dollar sign. For compatibility of scripting commands, good practice when using [[NairnFEAMPM]] is to end string variables with a dollar sign ($).


== Initializing a Variable ==
== Initializing a Variable ==
Line 30: Line 28:


* The [[Expression Syntax|expression]] in the square brackets must evaluate to an integer index into the array.
* The [[Expression Syntax|expression]] in the square brackets must evaluate to an integer index into the array.
* Multidimensional arrays are allowed such as <tt>#z[#i][#j]</tt></li>
* Multidimensional arrays are allowed such as <tt>#z[#i][#j]</tt>.
* There is no need to define the dimension of arrays.
* There is no need to define the dimension of arrays.

Latest revision as of 21:28, 14 January 2014

The scripting language can define variables in command files and do calculations on variables using expressions.

Defining Variables

Variables are defined and used in the form #varname where varname is any valid variable name. A number sign must always be used to indicate a variable (although the number sign is optional in NairnFEAMPMViz, it is recommended to use it for compatibility). The rules for a valid variable name after the number sign (or entire name if number sign omitted in NairnFEAMPMViz) are:

  • It must start with a letter (a-z or A-Z) or an underscore (_).
  • It can be followed by any number of additional upper (A-Z) or lower (a-z) case letters, underscores (_), or numbers (0-9).
  • Variable names are case sensitive.
  • In NairnFEAMPMViz, string variables must end in a dollar sign ($) while numeric variables must not. In NairnFEAMPM, a variable can optionally end in a dollar sign ($) and for compatibility, it is good practice to end string variables with a dollar sign.
  • In NairnFEAMPMViz, the name cannot contain any supported function name as a substring within the name.

Initializing a Variable

A variable is initially defined in an assignment statement such as:

#x=1

where the variable is set equal to the right side of the equals sign which can be any valid expression. A variable cannot be used in an expression until it has been defined.

Variable Arrays

Any valid variable name can be a variable array by following it with an expression in square brackets

#y[#j]=1

where

  • The expression in the square brackets must evaluate to an integer index into the array.
  • Multidimensional arrays are allowed such as #z[#i][#j].
  • There is no need to define the dimension of arrays.