Hello all,
I'm still learning StaticVar and Gui. I'm trying to assign 'data' from staticvar to 'myArray' elements like the example below (took 1 day to get the other part to work...phew..). Somehow the values are not transferring.
Appreciate any advice from you guys.
idCount = 1;
idReset = 2;
idchangeText = 3;
count = StaticVarGet("countStaticVar");
data = StaticVarGet("dataStaticVar");
myArray = 0;
function CreateButtonGUI()
{
GuiButton( "Count+", idCount, 100, 600, 70, 30, notifyClicked );
GuiButton( "Reset", idReset, 160, 600, 70, 30, notifyClicked );
GuiButton( "Change Count Button", idChangeText, 100, 630, 130, 30, notifyClicked );
}
function Counter()
{
count = Nz(count) + 1;
StaticVarSet("countStaticVar", count);
data = Nz(data) + 10;
printf("\ndata = :" + data);
myArray[count] = StaticVarSet("dataStaticVar", data);
}
function Reset()
{
StaticVarRemove("countStaticVar");
}
function ChangeButtonText()
{
GuiSetText("Counter", idCount );
}
function HandleEvents()
{
for( n = 0; id = GuiGetEvent( n, 0 ); n++ )
{
switch ( id )
{
case idCount:
Counter();
break;
case idReset:
Reset();
break;
case idChangeText:
ChangeButtonText();
break;
}
}
}
CreateButtonGUI();
HandleEvents();
printf("\ncount: " + count);
printf("\nmyArray[2]: " + myArray[2]);