This shows you the differences between two versions of the page.
en:subroutine [2016/08/13 09:06] admin |
en:subroutine [2020/02/28 10:46] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Subroutine (Statement) ===== | ||
- | |||
- | ==== Format ==== | ||
- | **subroutine** subroutine_name ( [[functionvariablelist|function_variable_list]] )\\ | ||
- | (tab)[[programsyntax|statement(s)]]\\ | ||
- | **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, variables. | ||
- | |||
- | Subroutines should be defined anywhere on your program, but 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 rgb(rnd(256), | ||
- | | ||
- | end subroutine | ||
- | </ | ||
- | draws\\ | ||
- | {{: | ||
- | ==== See Also ==== | ||
- | {{page> | ||
- | |||
- | ==== History ==== | ||
- | |0.9.9.1|New To Version| | ||