passing Parrameters to Functions and Sub Programs
passing Parrameters to Functions and Sub Programs
(OP)
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
RE: passing Parrameters to Functions and Sub Programs
CODE
MySub MyVar1,MyVar2,MyVar3
'...
Skip,
Just traded in my old subtlety...
for a NUANCE!
RE: passing Parrameters to Functions and Sub Programs
I will Have to rewrite some lines of code to accomodate the changes. At the moment the macro has over 500 Lines of Code and is growing as i add features. but at least for the most part it does actually Work.
RE: passing Parrameters to Functions and Sub Programs
I use vb.net but the concept is still the same
CODE
SignInClaims(Sess0, TPX, UserID, Password)
Declaration line for the SignInClaims Sub is:
CODE
'code
End Sub
Additionally, it looks like some of the session stuff you are doing is over-complicated. If you want I would be more than happy to provide some examples of screen scraping functions that could be easily adapted to fit your project. Post back and let me know how you are doing