×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

passing Parrameters to Functions and Sub Programs

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
 

RE: passing Parrameters to Functions and Sub Programs



CODE

'call MySub NO PARENTHESES
  MySub MyVar1,MyVar2,MyVar3
'...

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: passing Parrameters to Functions and Sub Programs

(OP)
Thanks Skip,  I will give that a try. If it works it will save me having to use Global variables.

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

just a side note, you might want to specify how you are refrencing your vairables, ie byRef/byVal

I use vb.net but the concept is still the same

CODE

'calling my sub in code, no need for call in .net
SignInClaims(Sess0, TPX, UserID, Password)

Declaration line for the SignInClaims Sub is:

CODE

Private Sub SignInClaims(ByVal Sess0 As Object, ByVal TPX As String, ByVal UserID As String, ByVal Password As String)
'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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close