...
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 | ||||
---|---|---|---|---|
| ||||
# Now plot the field plot (Z500) # using default contours |
Functions
The following examples show how to write functions in Macro. A function does not need to have a return value.
Code Block | ||
---|---|---|
| ||
# function that takes no arguments
function always_return_5 ()
return 5
end always_return_5
five = always_return_5()
# function that takes an argument and does no type-checking
function add_10_untyped (a)
return a+10
end add_10_untyped
b = add_10_untyped(4)
# function that takes two arguments
function add_two_untyped (a, b)
return a+b
end add_two_untyped
b = add_two_untyped(9, 11)
# function that takes an argument that must be a number
function add_10_to_number (a:number)
return a+10
end add_10_to_number
b = add_10_to_number(6)
# function that takes any number of arguments
function print_all_params
loop arg in arguments()
print(arg)
end loop
end print_all_params
print_all_params(5, 6, 7, 'Hello') |
Loops, tests & functions
Please check this handout: macrotut_syntax.pdf
...