Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!usc!ucsd!ucbvax!bloom-beacon!eru!hagbard!sunic!isgate!krafla!einari From: einari@rhi.hi.is (Einar Indridason) Newsgroups: comp.os.msdos.programmer Subject: Re: Symbol address in Turbo C Message-ID: <2846@krafla.rhi.hi.is> Date: 27 Feb 91 20:18:43 GMT References: <5626@tahoe.unr.edu> Reply-To: einari@rhi.hi.is (Einar Indridason) Organization: University of Iceland (RHI) Lines: 39 In article valley@uchicago (Doug Dougherty) writes: >barber@equinox.unr.edu writes: > > >> I'm attempting to write a program which produces a report based on >>a form definition file. The form definition file will contain two types of >>information: 1) straight text to be copied to the report verbatium (sp), >>and 2) macros, which will be a name of a function located inside my >>program. >> The problem I'm having is finding a way to call a function given >>a string representation of it's name. So for example, if my program read >>the following from the form definition file: >> @fn_doit >>it would call the function fn_doit. I thought of building a local symbol What's wrong with (just typed from memory, that is): struct actions { char *string_to_compare_with; /* malloced as needed */ (*funcptr)(); /* function to be called */ } actions [] = { { "Hello", output_hello_string() }, /* output_hello_string is previously declared */ { "World", output_world_string() }, .... }; etc. This is what (for example) MicroEMACS does it. Hope it helps. -- Internet: einari@rhi.hi.is | "Just give me my command line and drag UUCP: ..!mcsun!isgate!rhi!einari | the GUIs to the waste basket!!!!" Surgeon Generals warning: Masking the 8th bit can seriously damage your brain!!