home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!seismo!darwin.sura.net!spool.mu.edu!sdd.hp.com!usc!cs.utexas.edu!rutgers!ub!galileo.cc.rochester.edu!prodigal.psych.rochester.edu!eric
- From: eric@prodigal.psych.rochester.edu (Eric Hansen)
- Newsgroups: comp.lang.c
- Subject: How to call procedure with a variable?!
- Summary: How do I call a procedure using a variable?
- Keywords: C VARIABLE PROCEDURE
- Message-ID: <1992Sep10.143705.15262@galileo.cc.rochester.edu>
- Date: 10 Sep 92 14:37:05 GMT
- Sender: news@galileo.cc.rochester.edu
- Organization: University of Rochester - Rochester, New York
- Lines: 23
- Nntp-Posting-Host: prodigal.psych.rochester.edu
-
- I'd like to be able to call a procedure based on the contents of a variable.
- For instance, if my variable GOTOPROC is equal to "GetNewSearch(X,Y,Z)", then
- I'd like to somehow say GOTOPROC and have it perform the GetNewSearch
- routine. In the C Shell under Unix, you could use 'eval' to do this kind
- of thing, but how would I do this in C? Specifically, this is for MicroSoft C
- under DOS.
-
- In the past (in different languages), I've always had to use
- a 'case' or 'switch' type statement to say something like:
-
- case GOTOPROC of
- 'GetNewSearch(X,Y,Z)' : GetNewSearch(X,Y,Z);
- ..
- ..
-
- This seems pretty redundant, and there must be a more elegant way to
- accomplish this!
-
- Help! Thanks in advance,
-
- Eric Hansen
-
- eric@prodigal.psych.rochester.edu
-