prev
up
next

Defining variables and functions

The user may define variables and functions in the input file, and apply them subsequently in expressions.
The input file is read sequentially and variables and functions must be defined before they can be used.
Note carefully that replacement of a variable (or function) by its value will occur wherever possible (textually),
even if it leads to non-sense input. A frequently occurring mistake is that the user defines a variable 'C'
in his (her) input and then gets his input corrupted because of subsequent isolated C characters are
replaced by the defined numerical value. Therefore: avoid single-character variables and function names.
Always check carefully that the identifier you introduce is not 'used' already in the input file.

A few variables and functions are pre-defined:

(variables):
pi = 3.1415....
(functions):
sin, cos, tan, asin, acos, atan, exp, log, sqrt, nint.

The argument list of a function must be enclosed in parentheses, and the arguments
(in case of more than one) must be separated by commas.
Defining variables and/or functions is done with the block-type key define.

Example (part of input):

DEFINE
ab = sin(pi/3)
s13 = 14*sqrt(2)
func(x,y,z) = x*ab+y**2-y*z
End
AKEY = FUNC (S13/5, S13/7, SIN(PI/6))

Here a function func and variables ab and s13 are defined, using the pre-defined functions sin and sqrt,
as well as the pre-defined variable pi. These are then applied to assign a value to the (hypothetical) key AKEY.
Note 1: the variable ab is also used in the definition of func'; this is allowed because ab is defined before func.
Note 2: variable- and function names must have the same form as keywords, i.e. only certain characters
are allowed.
Note 3: in the definition of variables and functions blanks are ignored altogether (in the value part) and will
not be interpreted as possible separators of the expression that defines the variable or function.

Define (block-type)

Definition of user-supplied functions and variables that can subsequently be used in the input file. (see the note on auxiliary input features)

SCM Home Page
Quality Software. Quantum Science
*
*
Copyright Terms of UsePrivacy Policy
Home Products Try & Buy Downloads Documentation Support News About SCM Contact
Home     Products     Try & Buy     Downloads     Documentation     Support     News     About SCM     Contact