Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: kccheng on June 02, 2011, 09:48:20 am

Title: Can I set/create environment variables from Wizard Script ?
Post by: kccheng on June 02, 2011, 09:48:20 am
Hi,

Can I set/create environment variables from Wizard Script ?
I'm working on a DLL wizard script.  And I want to set/create some environment
variable for my Host Application so it can find the DLL.
Is it possible ?

I check SetVar() function, which is not what I expected.
Thanks a lot.

Regards,
KC
Title: Re: Can I set/create environment variables from Wizard Script ?
Post by: oBFusCATed on June 02, 2011, 10:02:56 am
You want to set variables in Environment variables plugin (envvar) оr you want to use something like putenv() C lib function?
Title: Re: Can I set/create environment variables from Wizard Script ?
Post by: kccheng on June 02, 2011, 11:21:29 am
You want to set variables in Environment variables plugin (envvar) оr you want to use something like putenv() C lib function?

Either way which can be used in Wizard script.
I want to add (export) some environment variables from my DLL Wizard
which will be available when user click "Build->Run" or "Debug->Start" to
launch my host application.

My application will search a special path for DLL.  The default path could be
changed by environment variable MYAPP_DLL_DIR.

What I want is set MYAPP_DLL_DIR (at the time user create the project
via my Wizard) to the target output dir so the host app
can find the DLL created in C::B by default.
Is that possible ?

Regards,
KC
Title: Re: Can I set/create environment variables from Wizard Script ?
Post by: oBFusCATed on June 02, 2011, 12:40:03 pm
kccheng: Take a look at the envvar plugin. It does what you want in terms of features (you can set env variables, when your applications is executed from inside C::B).
I'm not sure how scriptable it is, probably not much, but it could be made. It is not that difficult.
Title: Re: Can I set/create environment variables from Wizard Script ?
Post by: kccheng on June 03, 2011, 02:47:43 am
kccheng: Take a look at the envvar plugin. It does what you want in terms of features (you can set env variables, when your applications is executed from inside C::B).

Hi

Thanks for reply.  Would you mind give me more info ?
I only find this Wiki page:
http://wiki.codeblocks.org/index.php?title=Environment_Variables_plugin (http://wiki.codeblocks.org/index.php?title=Environment_Variables_plugin)
and after reading this page, I don't even know how to use this
plugin ??

Regards
KC
Title: Re: Can I set/create environment variables from Wizard Script ?
Post by: oBFusCATed on June 03, 2011, 10:37:12 am
Read the page in the wiki again :)
Title: Re: Can I set/create environment variables from Wizard Script ?
Post by: kccheng on June 03, 2011, 11:42:21 am
Read the page in the wiki again :)
OK, I see what you meant :-) You are focus on C::B can set/get environment variables.
But I keep asking how to access these functions in Wizard script ... my bad.

Thanks
KC
Title: Re: Can I set/create environment variables from Wizard Script ?
Post by: oBFusCATed on June 03, 2011, 12:21:44 pm
You can read them from the configuration manager.
Setup some env var sets then close C::B and inspect the default.conf file. The use the API, to read and write to the variables.
Repeat the same with the project file. Probably there is no script hook for changing the current variable set in the project, but it won't be hard to be implemented.