Add the 2 functions to somewhere near the beginning of script (above the Script Begin)
SCAR Code:
Function GetBalance(): Integer;
Var
i: Integer;
Begin
i:= OpenFile(ScriptPath+NewFile,False);
ReadFileString(i,Result,FileSize(i));
CloseFile(i);
Result:= StrToInt(Result);
End;
SCAR Code:
Function SaveBalance(balance: Integer):Boolean;
Var
i: Integer;
Begin
i:= ReWriteFile(ScriptPath+NewFile,False);
WriteFileString(i,IntToStr(balance));
CloseFile(i);
End;
You would then put 'AccountBalance:= GetBalance();' at the beginning and at the end you would put 'SaveBalance(AccountBalance);'. Unfortunately this would be the only way without changing it manually and having it as a Const. You would still need to define NewFile as a Const at the beginning and make sure you tell users not to delete the file as it contains their accountbalance.