EasyManuals Logo

Kollmorgen AKD Basic User Manual

Kollmorgen AKD Basic
506 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #39 background imageLoading...
Page #39 background image
AKD BASIC User Guide | 3 AKDBASICLanguage
and includes the file .C\H\HEADER, and the file HEADER includes COMMON. The compiler
looks for COMMON in C:\H, not in C:\WORK.
C:\WORK
A.BAS
$INCLUDE “..\H\HEADER”
C:\H
HEADER
$INCLUDE “COMMON”
Compilation errors occur when a file is included multiple times. For example, if B.BAS includes
files MATH and INCL, and INCL also includes MATH, MATH is included twice, causing a com-
pile-time error.
B.BAS
$INCLUDE “MATH”
$INCLUDE “INCL”
INCL
$INCLUDE “MATH”
3.9 Arrays and Function Parameter Lists
When an array parameter (formal) of a function or subroutine is declared, the number of dimen-
sions is specified, but the extent of (number of elements in) each dimension is not specified.
This allows the programmer some freedom when invoking such a function. For example, a func-
tion may be defined to take a one-dimensional array and compute the sum of the elements in
the array. A single function can be written to take a one-dimensional array of any size and cor-
rectly compute the sum. (Because AKD BASIC checks array bounds at run time on each
access, there is no risk that a function will read or write outside the bounds of the array.)
When a formal parameter to a function is an array, instead of specifying the extent of each
dimension, a list of variables is used to both implicitly specify the number of dimensions and to
hold the extent of each dimension. These variables are read-only and cannot be modified within
the function.
Adopt a convention for assigning names to placeholders. One such convention is to use the
name of the array with a numerical suffix. For example,
function f(a(a1,a2,a3) as integer) as integer
where a1, a2, and a3 are the variables that get the extents of the array, a.
The function f above would be called as follows:
dim x_array(3,4,5) as integer
dim y_array(1,2,10) as integer
print f(x_array()) + f(y_array())
In both invocations of f, the function correctly determines the extent of each dimension of the
passed array.
Remember that when passing an array to a function, the type of the array must match
EXACTLY with the type expected by the function. Unlike scalar arguments (implicitly coerced
from float to int or int to float), arrays are NOT coerced. An attempt to pass an integer array to a
function that expects a float array results in a compile-time error.
3.9.1 Optimizations
As mentioned in an earlier section, constant definitions are completely ‘folded at the point of
definition. This is efficient code. Constant expressions inside AKD BASIC statements are also
39 Kollmorgen | March 30, 2012

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Kollmorgen AKD Basic and is the answer not in the manual?

Kollmorgen AKD Basic Specifications

General IconGeneral
BrandKollmorgen
ModelAKD Basic
CategoryController
LanguageEnglish

Related product manuals