home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13458 < prev    next >
Encoding:
Internet Message Format  |  1992-09-10  |  1.3 KB

  1. 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
  2. From: eric@prodigal.psych.rochester.edu (Eric Hansen)
  3. Newsgroups: comp.lang.c
  4. Subject: How to call procedure with a variable?!
  5. Summary: How do I call a procedure using a variable?
  6. Keywords: C VARIABLE PROCEDURE
  7. Message-ID: <1992Sep10.143705.15262@galileo.cc.rochester.edu>
  8. Date: 10 Sep 92 14:37:05 GMT
  9. Sender: news@galileo.cc.rochester.edu
  10. Organization: University of Rochester - Rochester, New York
  11. Lines: 23
  12. Nntp-Posting-Host: prodigal.psych.rochester.edu
  13.  
  14. I'd like to be able to call a procedure based on the contents of a variable.
  15. For instance, if my variable  GOTOPROC is equal to "GetNewSearch(X,Y,Z)", then
  16. I'd like to somehow say GOTOPROC and have it perform the GetNewSearch
  17. routine.  In the C Shell under Unix, you could use 'eval' to do this kind
  18. of thing, but how would I do this in C?  Specifically, this is for MicroSoft C
  19. under DOS.
  20.  
  21. In the past (in different languages), I've always had to use
  22. a 'case' or 'switch' type statement to say something like:
  23.  
  24. case GOTOPROC of
  25.     'GetNewSearch(X,Y,Z)' : GetNewSearch(X,Y,Z);
  26.     ..
  27.     ..
  28.  
  29. This seems pretty redundant, and there must be a more elegant way to 
  30. accomplish this!
  31.  
  32. Help!  Thanks in advance,
  33.  
  34. Eric Hansen
  35.  
  36. eric@prodigal.psych.rochester.edu
  37.