This shows you the differences between two versions of the page.
en:ref [2016/08/12 12:51] admin |
en:ref [2020/02/28 10:46] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Ref (Function) ===== | ||
- | ==== Format ==== | ||
- | subroutine subroutinename ( // | ||
- | call subroutinename ( // ref(variable), | ||
- | \\ | ||
- | function functionname ( // | ||
- | functionname ( // | ||
- | |||
- | returns [[integerexpressions|integer_expression]] | ||
- | |||
- | ==== 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> | ||
- | |||
- | ==== History ==== | ||
- | |0.9.9.13|New To Version| |