User Tools

Site Tools


en:ref

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:ref [2016/08/12 12:51]
admin
en:ref [2020/02/28 10:46]
Line 1: Line 1:
-===== Ref (Function) ===== 
  
-==== Format ==== 
-subroutine subroutinename ( //**ref(**variable**)**,variable// )\\ 
-call subroutinename ( // ref(variable),variable// )\\ 
-\\ 
-function functionname ( //**ref(**variable**)**,variable// )\\ 
-functionname ( //ref(variable),variable// )\\ 
- 
-returns [[integerexpressions|integer_expression]] 
- 
-==== Description ==== 
- 
-By default values are passed to [[Subroutine|Subroutines]] and [[function|Functions]] by value.  This means that the value that you specify when calling the routine is copied into a variable that belongs to and is totally local to the routine.\\ 
-The **ref()** declaration allows you to pass a reference to a variable or an array to the routine.  When a routine changes the value of a referenced variable, the change is actually made to the original variable used in the routine call. 
- 
-==== Example ==== 
- 
-<code> 
-dim a(10) 
-call assignarray(ref(a),10) 
-print "total="+totalarray(ref(a),10) 
-end 
- 
-subroutine assignarray(ref(array), arraylen) 
-   # set array elements 
-   for t = 0 to arraylen-1 
-      array[t]= t*t 
-    print array[t] 
-   next t 
-end subroutine 
- 
-function totalarray(ref(array),arraylen) 
-   totalarray = 0 
-   for t = 0 to arraylen-1 
-      totalarray += array[t] 
-   next t 
-end function 
-</code> 
-displays\\ 
-<code> 
-0 
-1 
-4 
-9 
-16 
-25 
-36 
-49 
-64 
-81 
-total=285 
-</code> 
-==== See Also ==== 
-{{page>en:start#Program Control&noheader}} 
- 
-==== History ====  
-|0.9.9.13|New To Version| 
en/ref.txt ยท Last modified: 2020/02/28 10:46 (external edit)