Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Is this possible?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,48471
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Is this possible?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Is this possible? - 6/19/2007 2:29:51 AM   
  2000a

 

Posts: 3
Score: 0
Joined: 6/19/2007
Status: offline
 
Hi,

Is it possible to do this?  Please note that I can't do it any other way.

I have a VBScript.  The first line is a varialbe set to the name of a function that I want to call.  I would like to call the function that has the same name that is stored in the "FuncToCall" variable.
How can I call the function: FuncAdd(10, 5) which should return 15?

In C++ I could use a pointer, but I have no clue about VBScript...


'-------------------
Dim FuncToCall
FuncToCall = "FuncAdd"

' SOME HOW CALL FuncAdd(10, 5) . It should return 15.
' FuncAddResult = FuncToCall(10, 5)



Function FuncAdd (x, y)
      FuncAdd = x + y
End Function

Function FuncWhatever ()
      '...
End Function

'-------------------


thank you
 
 
Post #: 1
 
 RE: Is this possible? - 6/19/2007 2:47:30 AM   
  DiGiTAL.SkReAM


Posts: 1171
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
Execute and ExecuteGlobal will run strings as if they were lines of vbscript code.
For example:

      

The only thing is that you have to get the quotes just right.

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to 2000a)
 
 
Post #: 2
 
 RE: Is this possible? - 6/19/2007 2:56:25 AM   
  2000a

 

Posts: 3
Score: 0
Joined: 6/19/2007
Status: offline
Thanks DiGiTAL.SkReAM

It works...



(in reply to DiGiTAL.SkReAM)
 
 
Post #: 3
 
 RE: Is this possible? - 6/19/2007 5:05:45 AM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi 2000a,

while DiGiTAL.SkReAM's advice to use Execute(Global) (or Eval to mention
the third construct of this kind) - that is the interpretation of (string) data as code -
will solve your problem, you should be aware of the fact that VBScript's equivalence
to C/C++ pointers (delegates in the .NET languages) is

       Set fRef = GetRef( sName )

Example:


      

ehvbs

(in reply to 2000a)
 
 
Post #: 4
 
 RE: Is this possible? - 6/19/2007 5:30:24 AM   
  2000a

 

Posts: 3
Score: 0
Joined: 6/19/2007
Status: offline
thanks ehvbs.

two solutions for a problem that I thought impossible to solve.  that's why i'm a rookie :)


thanks all.

(in reply to ehvbs)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Is this possible? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts