配列引数は参照で渡される

 
 
 

配列は参照で渡されます。配列を引数としてプロシージャに渡してプロシージャ内で修正すると、プロシージャ コールから戻ったとき、配列には修正された値が入っています。例:

proc fred( string $myArray[] ) {
 for ( $i=0; $i<size($myArray); ++$i ) {
 $myArray[$i] = "fred";
 }
 $myArray[$i] = "flintstone"; // add to the end of the array.
 }
 string $a[] =`ls -geometry`;
 print("Before call to fred\n");
 print $a;
 fred($a);
 print("After call to fred\n");
 print $a;
produces this output: 
Before call to fred
nurbConeShape1
nurbConeShape2
nurbSphereShape1
nurbSphereShape2
After call to fred
fred
fred
fred
fred
flintstone