Thanks a lot Bobby.
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Roberto G.
Gutierrez, StataCorp
Sent: Wednesday, June 01, 2005 5:01 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Plugin related question
Indranil Majumdar <imajumdar@creditsights.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[0]
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".
For example,
#define MaxLen 100 ; /* or whatever you want */
...
char buf[MaxLen] ;
ST_retcode rc ;
if(rc = SF_macro_use(argv[0], buf, MaxLen)) return(rc) ;
/* takes contents of argv[0] (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.
--Bobby
rgutierrez@stata.com
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/