Help - Search - Members - Calendar
Full Version: Can't get config variables working correctly
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
FrozenSpoon
Hello everyone. I'm making a new UI component but am clearly not understanding something with the cfg_var system. I looked at the tutorial here on the forum and still didn't get it.

Take the following code that I run everytime my UI starts:
CODE
static cfg_int NumTime("testvar", 0);
NumTime = NumTime + 1;
System::Windows::Forms::MessageBox::Show(int(NumTime).ToString());


It was my understaning that this loads the configuration variable testvar with a default value of 0. The message box that is displayed *always* indicates the number 1 everytime I start the UI. It seems like the variable is always getting replaced with 0.

What am I doing wrong? Thanks.
foosion
When exactly does the code run that displays the message box - when the core asks your component to create the main window or when the DLL is loaded?
FrozenSpoon
Your post got me to thinking -- I had placed the static cfg_int var inside a misc function. Placing it in global scope made it work correctly.

Thanks.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.