Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I call a "dynamic" function?

Status
Not open for further replies.

zzfive03

Programmer
Jun 11, 2001
267
0
0
Hello, Is it possible to call a function whos name is contained in the string of a varable.

Example:
' - - - Front End Page - - -
<a herf='otherpage.asp?func=dosomething'>Click Me</a>

' - - - OtherPage.asp - - -
Dim MyFuncName
MyFuncName = Request.QueryString(&quot;func&quot;)

Call MyFuncName ' - - - HOW CAN I DO THIS CORRECTLY?

Sub func
'do whatever
End Sub


any help would be great
 
Nevermind, I found it..

Execute(myvar)
 
To the best of my knowledge that cannot be done. What you could do is a Select Case with the possibilities of the QueryString.

<A herf='thispage.asp?func=FunctionOne'>Click Me</A>

'thispage.asp
Function YourFunction(ByVal strQuery)
Select Case
Case &quot;FunctionOne&quot;:
YourFunction = 'Code To Perfom For &quot;FunctionOne&quot;
Case &quot;FunctionTwo&quot;:
YourFunction = 'Code To Perfom For &quot;FunctionTwo&quot;
Case Else
YourFunction = 'Code To Perfom For Anything that does not match one of the Case
End Select
End Function

YourFunction(Request.QueryString(&quot;func&quot;))
 
The Execute Method is what will do this for you. There was a thread not long ago that discussed this with a few examples. I'll see if I can dig it up and post it.

____________________________________________________
[sub]$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;[/sub]
onpnt2.gif
[sub][/sub]
 
thread333-558585

____________________________________________________
[sub]$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;[/sub]
onpnt2.gif
[sub][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top