Getting the Environment in plugin init or idle

View: New views
2 Messages — Rating Filter:   Alert me  

Getting the Environment in plugin init or idle

by Joe Mele :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

Does anyone have 2 or 3 lines of code that does this in the new API.

thanks
Joe Mele


Re: Getting the Environment in plugin init or idle

by Jake Traynham :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Joe,

yowzah86 wrote:
>
>
> Hi
>
> Does anyone have 2 or 3 lines of code that does this in the new API.
>

   You can't get an environment in plug-in init because there is no
environment at that point.  However, in plug-in idle (or any time
really), you can get an environment using the FMX_SetToCurrentEnv call
like so:

fmx::errcode fError;
fmx::ExprEnvAutoPtr fEnv;

fError = FMX_SetToCurrentEnv(&(*fEnv));
if (fError == 0)
   {
     // use it...
   }

I've also seen this before (I think it's right):

fError = FMX_SetToCurrentEnv(fEnv->get());

... if you don't like the looks of &(*fEnv) .. :)

HTH,
Jake

> thanks
> Joe Mele
>


--
Jake Traynham
Owner, CNS Plug-ins
http://www.cnsplug-ins.com/
LightInTheBox - Buy quality products at wholesale price!