Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Plugin related question


From   "Indranil Majumdar" <[email protected]>
To   <[email protected]>
Subject   RE: st: Plugin related question
Date   Wed, 1 Jun 2005 17:43:22 -0400

Thanks a lot Bobby.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Roberto G.
Gutierrez, StataCorp
Sent: Wednesday, June 01, 2005 5:01 PM
To: [email protected]
Subject: Re: st: Plugin related question

Indranil Majumdar <[email protected]> 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
[email protected]
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index