This shows you the differences between two versions of the page.
el:subroutine [2016/01/01 22:40] |
el:subroutine [2020/02/28 10:46] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Subroutine ===== | ||
+ | ==== Format ==== | ||
+ | **subroutine** subroutinename ( //variable list// )\\ | ||
+ | // | ||
+ | **end subroutine** | ||
+ | |||
+ | **subroutine** subroutinename$ ( //variable list// )\\ | ||
+ | // | ||
+ | **end subroutine** | ||
+ | |||
+ | ==== Description ==== | ||
+ | Create a subroutine (or subprogram) that will receive zero or more values and process those values. | ||
+ | |||
+ | Subroutine variables may a list of zero or more, comma separated, numeric or string variables. | ||
+ | |||
+ | Subroutines should be defined at the bottom of your program, and can not be defined within another [[function|Function]], | ||
+ | |||
+ | ==== Example ==== | ||
+ | |||
+ | < | ||
+ | # 100 random circles | ||
+ | clg | ||
+ | for x = 1 to 100 | ||
+ | call draw() | ||
+ | next x | ||
+ | end | ||
+ | |||
+ | function rnd(n) | ||
+ | rnd = int(rand*n) | ||
+ | end function | ||
+ | |||
+ | subroutine draw() | ||
+ | color rnd(256), | ||
+ | | ||
+ | end subroutine | ||
+ | </ | ||
+ | draws\\ | ||
+ | {{: | ||
+ | ==== See Also ==== | ||
+ | {{page> | ||
+ | |||
+ | ==== New To Version ==== | ||
+ | 0.9.9.1 |