Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

and by case do else end export extern for function global if import in include inline loop nil not object of on or otherwise repeat return task tell then to until when while

Comments

To write comments, use the character #. Any text from this character to the end of the line is ignored. Each line to be commented must be preceded by the # character, i.e. C-like multi-line comments are not allowed.

Code Block
languagepy
titleMacro comments
# Now plot the field
plot (Z500) # using default contours 


Loops

Code Block
languagepy
# basic for loop
for i = 1 to 4 do
    print (i)
end for

# for loop with a list
for i = 1 to count(thisList) do
    print (i, " : ", thisList[i])
end for

# for loop using dates with a step
for day = 2003-01-24 to 2003-02-14 by 3 do
    print (day)
end for

# basic while loop
n = 1
while n <= 10 do
    print(n)
    n = n + 1
end while

# basic repeat loop
n = 1
repeat
    print(n)
    n = n + 1
until n > 10

# loop - can be used on lists, fieldsets and geopoints
loop element in thisList
    print(element)
end loop



Functions

You can define your own functions  in Macro. Functions can take any number of input arguments and can optionally enforce type-checking on them. A function does not need to have a return value. Only one value can be returned - to return multiple values, return a structure such as a list, vector or definition containing the values.

...