User Tools

Site Tools


fr:ref

Differences

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

Link to this comparison view

fr:ref [2016/01/01 22:45]
fr:ref [2020/02/28 10:46] (current)
Line 1: Line 1:
 +===== Ref =====
  
 +==== Format ====
 +subroutine subroutinename ( //**ref(**variable**)**,variable// )\\
 +call subroutinename ( // ref(variable),variable// )\\
 +\\
 +function functionname ( //**ref(**variable**)**,variable// )\\
 +functionname ( //ref(variable),variable// )\\
 +==== Description ====
 +
 +Par défaut se sont des valeurs qui sont passés en paramètre à [[Subroutine|Subroutines]] et [[function|Functions]]. Cela signifie que les valeurs spécifiées à l'appel sont copiée dans les variables correspondantes qui sont entièrement locales à la fonction.\\
 +La déclaration ref permet de passer la référence d'une variable ou d'un tableau à la routine. Quand une routine change la valeur d'une telle variable, les changements sont répercutés dans lavariable originale.
 +
 +==== Exemple ====
 +
 +<code>
 +dim a(10)
 +call assignarray(ref(a),10)
 +print "total="+totalarray(ref(a),10)
 +end
 +
 +subroutine assignarray(ref(array), arraylen)
 +   # Initialise les éléments du tableau
 +   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>
 +Affichera\\
 +<code>
 +0
 +1
 +4
 +9
 +16
 +25
 +36
 +49
 +64
 +81
 +total=285
 +</code>
 +==== Voir Aussi ====
 +{{page>fr:start#Contrôle de programme&noheader}}
 +
 +==== Disponible depuis la version ==== 
 +0.9.9.13