This shows you the differences between two versions of the page.
el:ref [2016/01/01 22:39] |
el:ref [2020/02/28 10:46] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Ref ===== | ||
+ | ==== Format ==== | ||
+ | subroutine subroutinename ( // | ||
+ | call subroutinename ( // ref(variable), | ||
+ | \\ | ||
+ | function functionname ( // | ||
+ | functionname ( // | ||
+ | ==== Description ==== | ||
+ | |||
+ | By default values are passed to [[Subroutine|Subroutines]] and [[function|Functions]] by value. | ||
+ | The **ref()** declaration allows you to pass a reference to a variable or an array to the routine. | ||
+ | |||
+ | ==== Example ==== | ||
+ | |||
+ | < | ||
+ | dim a(10) | ||
+ | call assignarray(ref(a), | ||
+ | print " | ||
+ | end | ||
+ | |||
+ | subroutine assignarray(ref(array), | ||
+ | # set array elements | ||
+ | for t = 0 to arraylen-1 | ||
+ | array[t]= t*t | ||
+ | print array[t] | ||
+ | next t | ||
+ | end subroutine | ||
+ | |||
+ | function totalarray(ref(array), | ||
+ | | ||
+ | for t = 0 to arraylen-1 | ||
+ | totalarray += array[t] | ||
+ | next t | ||
+ | end function | ||
+ | </ | ||
+ | displays\\ | ||
+ | < | ||
+ | 0 | ||
+ | 1 | ||
+ | 4 | ||
+ | 9 | ||
+ | 16 | ||
+ | 25 | ||
+ | 36 | ||
+ | 49 | ||
+ | 64 | ||
+ | 81 | ||
+ | total=285 | ||
+ | </ | ||
+ | ==== See Also ==== | ||
+ | {{page> | ||
+ | |||
+ | ==== New To Version ==== | ||
+ | 0.9.9.13 |