Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Is it possible to pass an array to a subroutine?


Minh T. Jun 9, 2017 08:32 PM

I read the help menu for subroutine but it does not mention passing arrays. 

Sub, Exit Sub, EndSub

The ArgumentList is a list of variables that are passed to the Subroutine when it is called (the variables can be Float, Long, or String; if not specified Float is assumed). The use of an ArgumentList lets you assign variables within the main program to variables in the subroutine, process those variables in the subroutine, and then use the resulting processed values later in the program. Multiple variables are separated by commas. Changing an argument's value inside the Subroutine changes its value in the calling procedure. Use of ArgumentList is optional.


Carli Jun 27, 2017 11:03 AM

Yes it possible. 

Tested with fixed array dimensions (see below). If the dimension are not known during compile time you can look into pointers.

 

Public Values(10) As Long

Sub ArrayTest(Val As Long(10))
  Dim i
  For i=1 To 10 
    Val(i)=i
  Next i
End Sub

BeginProg
	Scan (1,Sec,0,0)
	ArrayTest(Values)
EndProg

 

Log in or register to post/reply in the forum.