03-14-2010, 01:05 AM
Greetings!
For about 3 hours now I have been working on my Jeopardy program with the Netbeans IDE. Once I got the interface all together, I opened up JCreator and pasted the text document GameInformationUploader section of my previous JeopardyUploader test script, then edited the naming of the Category buttons to take titles from my categories array, and saved in JCreator. When I reloaded the script in Netbeans... MASS ERRORS!!! I said "Omigawd!" and checked what the problem was...
What happened is that my arrays were not global. Well, I tried a bunch of different ways to set global variables such as in LSL or C++, but it was no good. After several minutes of failing, like a stubborn man in Walmart who has been roaming the ails looking too long and finally deciding to ask an employee, I Googled it. And I found it. And here is what this entire epic story sums up to.
To set global variables, all you have to do is after you declare your class and your first opening bracket, state your global variables... BUT, when you state your variables, put "public static" in front of them. Example:
And that's it if you already knew this, than congratulations! If you didn't know this before but do now, congratulations to you too!
For about 3 hours now I have been working on my Jeopardy program with the Netbeans IDE. Once I got the interface all together, I opened up JCreator and pasted the text document GameInformationUploader section of my previous JeopardyUploader test script, then edited the naming of the Category buttons to take titles from my categories array, and saved in JCreator. When I reloaded the script in Netbeans... MASS ERRORS!!! I said "Omigawd!" and checked what the problem was...
What happened is that my arrays were not global. Well, I tried a bunch of different ways to set global variables such as in LSL or C++, but it was no good. After several minutes of failing, like a stubborn man in Walmart who has been roaming the ails looking too long and finally deciding to ask an employee, I Googled it. And I found it. And here is what this entire epic story sums up to.
To set global variables, all you have to do is after you declare your class and your first opening bracket, state your global variables... BUT, when you state your variables, put "public static" in front of them. Example:
Code:
public class GlobalDataStore
{
public static int globalInt = 0; //<---He's Global! *teehee*
}
And that's it if you already knew this, than congratulations! If you didn't know this before but do now, congratulations to you too!