2 named constant - #define and const, Named constant - #define and const – ElmoMC Multi-Axis Motion Controller-Maestro User Manual

Page 68

Advertising
background image

For example:

i = 0x3fff; // Hexadecimal constant

j = 0X3FFF; // Equal to i

5.1.6.2

Maestro

Software Manual

MAXL Program Language

MAN-MASSW (Ver. Q)

Named Constant - #define and const.

Constants must be declared in the “global declarations” section, i.e. before the first
function. Named constants declared with #define are accessible only in the current
program. Constants declared using const can be used by other programs.

#define is used to declare named constants locally. For example, if a program uses the
same constant several times, a named constant can be used as in the following
example:

// program : test1

#define AC 200000000

function run()

a1.ac=AC

a2.ac=AC

a1.dc=AC

a2.dc=AC

end function

To declare a global constant, which is visible to other programs and the command
interpreter, use

const

as in the following example:

// program test1

const AC=200000000

function run()

a1.ac=AC

a2.ac=AC

a1.dc=AC

a2.dc=AC

end function

Now the command interpreter has access to the named constant:

>test1.AC

200000000

5-6

Advertising