AKD BASIC User Guide | 3 AKDBASICLanguage
(this is similar to the format used to define a subroutine or function). The only statements per-
mitted in this section are assignment statements of the form:
<parameter> = <constant expression>
This section can be automatically generated by WorkBench when a New Program is created.
Choose "current drive parameters" to include the connected drive's setup parameters in your
program. If you choose to not include the setup parameters in your program, be sure to save the
setup parameters to the drive to ensure proper drive setup upon power up.
3.2.3 Global Variables, Constants, and Aliases
This section contains variables, constant definitions, and global alias expressions — they
apply everywhere in the program, unless specifically overridden by another declaration at local
scope (inside a subroutine, function, or interrupt handler). Global definitions may be placed
almost anywhere in the program text — between subroutines, before or after ‘main’, and so on.
Global variables, constants, and aliases do not need to be defined before use — the only
requirement is that they be defined at some point in the program text. You may have multiple
instances of the global variables section throughout your program. However, as a matter of
good programming style, we recommend that you keep all global definitions in one place, pref-
erably at or near the beginning of your program.
3.2.4 Variable Definitions
The format of a global variable definition is:
dim a,b as integer, x,y,z as float
dim ia(3,4) as integer
dim s1, s2 as string*80
dim sa(5,2) as string
dim j, k, l as integer NV
Line 1 declares a and b as integers, x,y, and z as floats. Line 2 declares a 3 x 4 array of
integers. Line 3 declares s1 and s2 as strings, each of length 80. Line 4 declares sa as a 5 x 2
array of strings, each with the default length of 32 characters. Line 5 defines 3 integers, j, k, and
l as NV.
In addition, global variables can be specified as ‘NV’ to indicate their values are retained when
power is turned off. All other global variables are automatically initialized when the program
begins (strings are set to empty, and floats and integers are set to 0). There are no restrictions
on the ordering of volatile vs. non-volatile user-variables. For ease of program maintenance,
place all non-volatile variables definitions in a single section at the beginning of the program,
and add new variables to the end of that section.
3.2.5 Constant Definitions
The format of a constant declaration is:
const <name> = <constant_expression>
as in
const ARRAY_SIZE = 4 * NUMBER_OF_ENTRIES
const PI_SQUARE = 3.1415926535 ^ 2
const GREETING = “Hello”
const GREETING = “Hello”
const NUMBER_OF_ENTRIES = 5
Kollmorgen™ | March 30, 2012 22