PARAMARRAY
 
Syntax


SUB | FUNCTION name (PARAMARRAY paramname) 

Description


Used to declare a variable number of parameters in FUNCTIONs or SUBs.

When used a variable number of INTEGER parameters can be passed BYVAL to a FUNCTION or SUB and accessed as elements of an array named paramname.

1 to 15 parameters may be passed. and the number of parameters - 1 is passed in paramname(15).

 
 
Example


FUNCTION sumof (PARAMARRAY z)
  DIM i,sum
  sum = 0
  FOR i=0 to z(15)
    sum += z(i)
  NEXT
  return sum
ENDFUNCTION

main:

print sumof(1,2,3)             '  prints 6
print sumof(5,6,7,8,9,10)   '  prints 45


Differences from other BASICs

See also