[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Plugin related question
Indranil Majumdar <email@example.com> asks:
> I have the following query regarding passing macros to stata plugins.
> The document for 'Creating and using Stata plugins' (on the Stata website),
> says - "We could have just as easily passed the local macro name with the
> underscore included in arglist..." The following is my interpretation, but
> it does not work.
> . program <C++ pluginname>, plugin
> . local x = 23.45
> . plugin call <C++ pluginname>, _x y
> It's not clear to me where to 'include the underscore in the arglist'. Any
> help will be appreciated.
The way you have it should work just fine. Inside the C plugin, argv would
contain the string "_x", which when you pass along to the function
SF_macro_use(), would know to look into the contents of local macro "x",
stored internally as "_x" to distinguish it from the global macro "x".
#define MaxLen 100 ; /* or whatever you want */
char buf[MaxLen] ;
ST_retcode rc ;
if(rc = SF_macro_use(argv, buf, MaxLen)) return(rc) ;
/* takes contents of argv (reference to local macro x in our example) */
/* and places the first MaxLen characters of its contents in buf */
/* At this point buf contains "23.45". */
Feel free to email me privately if you are still having trouble getting this
to work for you.
* For searches and help try: