Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Can't get config variables working correctly (Read 2845 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Can't get config variables working correctly

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: [Select]
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.

Can't get config variables working correctly

Reply #1
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?

Can't get config variables working correctly

Reply #2
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.