User Tools

Site Tools


pt:ref

Differences

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

Link to this comparison view

pt:ref [2016/01/01 22:48]
pt:ref [2020/02/28 10:46] (current)
Line 1: Line 1:
 +===== Ref =====
  
 +==== Formato ====
 +subroutine subroutinename ( //**ref(**variable**)**,variable// )\\
 +call subroutinename ( // ref(variable),variable// )\\
 +\\
 +function functionname ( //**ref(**variable**)**,variable// )\\
 +functionname ( //ref(variable),variable// )\\
 +==== Descrição ====
 +
 +Por norma os parâmetros são passados ​​para as sub-rotinas e funções por valor. Isso significa que o valor especificado ao chamar a sub-rotina é totalmente local para esta.
 +REF() permite que se passe uma referência a uma variável ou um array para a rotina. Quando a rotina de alterar o valor da variável de referência, a alteração é realmente feita para a variável original usada na chamada de rotina.
 +==== Exemplo ====
 +
 +<code>
 +dim a(5)
 +
 +# atribui valores a cada elemento to array
 +for t = 0 to 4
 +a[t]= int(rand*6)
 +print a[t]
 +next t
 +
 +
 +print "Soma="+total(ref(a),5)
 +end
 +
 +
 +# soma todos os valores do array
 +function total(ref(array),comprimento)
 +   total= 0
 +   for t = 0 to comprimento-1
 +      total= total+array[t]
 +   next t
 +end function 
 +</code>
 +mostra qualquer coisa como\\
 +<code>
 +1
 +5
 +4
 +2
 +2
 +Soma=14
 +</code>
 +==== Ver também ====
 +[[call|Call]], [[Function|Function]], [[Global|Global]], [[Return|Return]], [[Subroutine|Subroutine]]
 +
 +==== Desde ==== 
 +0.9.9.13
pt/ref.txt · Last modified: 2020/02/28 10:46 (external edit)