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 #30 background imageLoading...
Page #30 background image
AKD BASIC User Guide | 3 AKDBASICLanguage
3.5.8 Function
Function function-name [(argument-list)] as function-type
...statements...
End Function
On function entry, all local variable strings are “” and all numeric locals are zero (including all ele-
ments of local arrays). If the function takes no arguments, omit the argument-list. An empty
argument-list is illegal. The value returned from the function is specified by assigning an iden-
tifier with the name of the function.
Example:
function cube(x as float) as float
cube = x * x * x
end function
Arguments are passed by value. Arrays can not be returned by a function. Arrays passed to a
function are passed by value.
If the return value is not set, a runtime error condition is generated (caught with ON ERROR).
Array actuals must conform with formals to the extent that they have the same number of
dimensions, and EXACTLY the same type. The size of each dimension is available to the func-
tion through the use of local constants that are bound on function entry.
Example:
function sum(x(n) as integer) as integer
dim i, total as integer
sum = 0
for i = 1 to n
total = total + x(i)
next
sum = total
end function
This function exploits the fact that the variable N is automatically assigned a value when the
function is called and the value is the extent of the array passed on invocation. N is a read-only
variable in this context. Attempts to write to N cause compile-time errors.
The local variable, total is automatically initialized to 0 upon function entry.
3.5.9 GoTo
GoTo label
A program can only GoTo a label in the same scope. A GoTo may jump out of a For or While
loop, but not INTO one.
3.5.10 If…Then…Else
if condition1 then
...statement block1...
elseif condition2 then
...statement block2...
else
...statement block3...
end if
Kollmorgen | March 30, 2012 30

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