You can do either. See the manual:
In KiXtart, variables are used to temporarily store values
during the execution of a script. Variables have a name (the word you use to
refer to the value the variable contains) a type (which determines the kind of
data the variable can store) and a scope (which determines where in the script
you can reference the variable). You can think of a variable as a placeholder in
memory for an unknown value.
Storing data in variables
Variables can be assigned a particular value by using an
$Variable = 10
or by using a GET or GETS statement :
Optionally, variables can be created and assigned a value
on the commandline with which KiXtart is started. To do this, type the variable
name followed by an equal sign (=) and the value the variable should have. For
On the commandline, do not include spaces between the equal sign
(=) and the value. If you want to specify a value that contains spaces, enclose
it in quotation marks (for example, KIX32
Demo.kix $Key="Hi there").
To declare a variable is to tell the program about it in
advance. You declare a variable with the Dim or the Global statement, supplying
a name for the variable:
Variables declared with the Dim statement exist only as
long as the script segment in which the Dim statement was used is executing.
When the script segment completes, the variable, and its value, disappear.
Variables declared with the Global statement exist during the entire KiXtart
A variable name:
Can't contain operator characters (+,-,*,/,&,<,>,=)
Can’t contain a period
Must be unique within the same scope, which is the range from which the variable can be referenced
in a script, or script segment.
You can use the same name for variables in different
scopes, and if you do, you will only be able to reference the variable in the
current scope. Please see the example below for more details:
InGroup( “Admins” )
; local variable with same name
$Var = 20
; this will display ‘20’
; this will display ‘10’
Variables don’t have to be declared before they can be
used. You can also implicitly declare them simply by assigning a value to them.
Note that all variables that are declared in this way have a global scope (see
below for details on scope).
Scope of variables
Depending on how and where they are declared, variables can
have a local or a global scope. Variables with a global scope are visible
anywhere in any script during the entire KiXtart session. Variables with a local
scope are only visible to the script or script segment in which they were
Assuming this is the first reference to ‘$GlobalVariable’,
this variable is implicitly declared and will become a global variable,
visible everywhere in every script during this KiXtart session.
This variable will become a local variable and will
be visible only in the current script.
IF $X = 1
$LocalVariable = 10
this example, $LocalVariable will only be visible inside the IF statement.
this example, $LocalVariable will only be visible inside the subroutine
In KiXtart, variables are always of one fundamental data
type: Variant. The current implementation of KiXtart only uses two types of
variants: long integers and strings. A variant of type string can contain up to
32,000 characters. Integer variables can contain any value between ‑2,147,483,648
and 2,147,483,647. The type of a variable is automatically changed to the result
of the expression that is assigned to it. This means that if you assign a string
to a variable containing an integer, the type of the variable is changed to a
There is no limit to the number of variables that can be
defined, other than the amount of memory available to KiXtart.
Note that KiXtart can handle other types of variants, such
as Booleans, Bytes, etc. KiXtart itself does not create these types itself, but
they may be returned by other programs via COM automation. If any of these types
of variants is used in an expression, it will be converted to a long integer or
string before the expression is evaluated.
KiXtart supports single dimension arrays. Arrays allow you
to refer to a series of variables by the same name and to use a number (an
index) to tell them apart. This helps you create smaller and simpler code in
many situations, because you can set up loops that deal efficiently with any
number of cases by using the index number. Arrays have both upper and lower
bounds, and the elements of the array are contiguous within those bounds.
Because KiXtart allocates space for each index number, avoid declaring an array
larger than necessary.
When declaring an array, follow the array name by the upper
bound in square brackets. The upper bound cannot exceed 2,147,483,647.
‘ explicit declaration
= 10,20,30 ‘ implicit
= “A1”,“B2”,“C3” ‘ implicit
first declaration creates an array with 15 elements, with index numbers running
from 0 to 14. The second creates an array with 21 elements, with index numbers
running from 0 to 20. The third and fourth declarations create arrays with 3
elements, with index numbers running from 0 to 2.
Arrays are always of type variant.
Unlike regular variables, arrays can not be used inside
strings and can also not be assigned a value on the commandline.
[ 24 June 2002, 19:38: Message edited by: Howard Bullock ]