Connecting Tech Pros Worldwide Forums | Help | Site Map

Variable resets to zero

Newbie
 
Join Date: Nov 2005
Location: Florida
Posts: 3
#1: Nov 5 '05
I have this coded into a DLL file, it receives the initial "balance" from an external program. I tried to get the hibalance to always go up when balance goes up, but if balance goes down hibalance will remain as the highest it found. But the results are always balance = hibalance :mad: as if it's always getting reset. hibalance & cbalance are global variables defined higher up in the code structure.

Is there a way to save the value to a file or non volitle memory then retrieve it for the next iteration??

Expand|Select|Wrap|Line Numbers
  1. ////////////highest balance///////////////////
  2.  
  3. int topbalance (int hibalance)
  4.    {
  5.     cbalance =(int)gws("balance");       // assign balance to cbalance    
  6.     if (hibalance < cbalance); {           // compare - if false do nothing
  7.         hibalance = cbalance;               // if true
  8.           }
  9.     return hibalance;
  10.  }
How do I prevent the the variable hibalance from being reset to 0, simple but confused, any help would be a lifesaver. Tnx

Newbie
 
Join Date: Nov 2005
Location: Florida
Posts: 3
#2: Nov 6 '05

re: Variable resets to zero


Does anyone know how to save the above variable to say a txt file, then retrive it later for evaluation? :rolleyes:
Newbie
 
Join Date: Nov 2005
Location: Florida
Posts: 3
#3: Nov 8 '05

re: Variable resets to zero


Another option I think. Should I be defining this as a STATIC. Would it preserve the value? Or am I not bringing the hibalance back into the function?
Reply