TheSorceror
Programmer
I Seem to be having a hell of a lot of troubles passing Variables into a Function or Sub Program Call.
For Example: (Extremely simplified).
Declare Sub MySub(Param1 as String, Param2 as String, Param3 as String)
Sub main()
Dim MyVar1 as String
Dim MyVar2 as String
Dim MyVar3 as String.
MyVar1 = "some text"
MyVar2 = "More Text"
MyVar3 = "Yet more Text"
MySub(MyVar1,MyVar2,MyVar3)
End Sub
Sub MySub(Param1 as String, Param2 as String, Param3 as String)
' do whatever with passed in params..
End Sub
When compiling the code it fails with a syntax error on the Sub call..
MySub(MyVar1,MyVar2,MyVar3)
It complains that there are too few arguements for the Sub program MySub
If i pass 1 parameter it compiles and works fine. it seems passing any more than 1 parameter causes it to fail.
Easy enough to work around though by declaring the Variables as Global Variables outside of Main But this is really Messy programming.
Any ideas or is this a limitation of Extra! Basic???
Funnily enough i do have a function(sub) call that does pass in 4 parameters and that works.
Her is the one that works.
Declare Function GetScreenID(yStart,xStart ,yEnd ,xEnd)
Sub Main ()
Dim ScreenName
ScreenName = GetScreenID(1,35,1,36)
End Sub
Function GetScreenID( yStart,xStart,yEnd,xEnd)
'MsgBox "entering GetScreenID Function"
Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
'reset Sess & MyScreen variables for current screen and tell us where we are.
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
Set MyArea = MyScreen.Area(yStart,xStart,yEnd,xEnd , ,)
MyArea.Select
MyArea.Copy
GetScreenID = MyArea.Value
End Function
Wierd hey?? it returns the text found at the co-ordinates passed into the function. Which is what it is meant to do..
So why can i pass in 4 variables into this function call but not any others??? And it does not matter if it is a Function or a Sub. The same error occurs regardless.
Any help appreciated.
Al
For Example: (Extremely simplified).
Declare Sub MySub(Param1 as String, Param2 as String, Param3 as String)
Sub main()
Dim MyVar1 as String
Dim MyVar2 as String
Dim MyVar3 as String.
MyVar1 = "some text"
MyVar2 = "More Text"
MyVar3 = "Yet more Text"
MySub(MyVar1,MyVar2,MyVar3)
End Sub
Sub MySub(Param1 as String, Param2 as String, Param3 as String)
' do whatever with passed in params..
End Sub
When compiling the code it fails with a syntax error on the Sub call..
MySub(MyVar1,MyVar2,MyVar3)
It complains that there are too few arguements for the Sub program MySub
If i pass 1 parameter it compiles and works fine. it seems passing any more than 1 parameter causes it to fail.
Easy enough to work around though by declaring the Variables as Global Variables outside of Main But this is really Messy programming.
Any ideas or is this a limitation of Extra! Basic???
Funnily enough i do have a function(sub) call that does pass in 4 parameters and that works.
Her is the one that works.
Declare Function GetScreenID(yStart,xStart ,yEnd ,xEnd)
Sub Main ()
Dim ScreenName
ScreenName = GetScreenID(1,35,1,36)
End Sub
Function GetScreenID( yStart,xStart,yEnd,xEnd)
'MsgBox "entering GetScreenID Function"
Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
'reset Sess & MyScreen variables for current screen and tell us where we are.
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
Set MyArea = MyScreen.Area(yStart,xStart,yEnd,xEnd , ,)
MyArea.Select
MyArea.Copy
GetScreenID = MyArea.Value
End Function
Wierd hey?? it returns the text found at the co-ordinates passed into the function. Which is what it is meant to do..
So why can i pass in 4 variables into this function call but not any others??? And it does not matter if it is a Function or a Sub. The same error occurs regardless.
Any help appreciated.
Al