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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call a function/procedure whose name I build from a string?

Status
Not open for further replies.

keithvbk

Programmer
Dec 26, 2002
2
US
I create a function or procedure name by building the name to be executed from variables.
example:
basename = "INTERFACE"
nameext = "_x"
myproc = basename + nameext

Now how do I call the function whose name is contained in variable myproc ?

I appreciate the help !
Keith
 
Not sure where your functions/procedures are located but the following will work if located inside a prg file all together

functname='myfunction'
mv=functname

DO &mv

FUNCTION myfunction
@10,1 say [it works]
 
Parenteses denote a name so you can do this:

DO (basename + nameext)

Just watch out for spaces and variables as numbers... I uesually wrap a transform() around variables to remove this issue:

DO (TRANSFORM(basename) + TRANSFORM(nameext))

Brian
 
or even simply &myproc.

Code:
lcCommand = "RUN /N notepad"
&lcCommand

It's named macro substitution.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top