LOAD and Save data to a file
; Example Code
goSub ENs_SetupCommandLine ; initialize save/load enviroment
SET %TestVar 1
set %testvar2 test
set %Filename C:\easyuo\en-test.txt
display ok saveing a test value of %testvar - %testvar2
goSub ENs_ClearFile %filename
gosub ENs_SaveData %filename TestVar TestVar2
; ~~~~~~~~~~~~~~~~~~~
set %testvar 2
set %testvar2 boo
display ok resting testvalue to %testvar : %testvar2
; ~~~~~~~~~~~~~~~~~~~
gosub ENs_LoadData %fileName
display ok TestValue = %testvar : %testvar2 $ (should be 1 : test what was saved in file)
halt
; Subs
sub ENs_SaveData ; <%Filename> 1..z of <Varname to save without the % Sign>
set !SDFileName %1
set !SDBufferText
set !SDFile #spc , >> , #spc , !SDFileName
set !SDAnd #spc , && , #spc
set !SDEcho Echo , #spc , Set , #spc
set !SDVarName %2
set !SdValue % . !SDVarName
set !SDBufferText !SdEcho , %ENs_PercentSign , !SdVarName , #spc , !SDValue , !SDFile
if %0 > 2
{
for !x 3 %0
{
set !SDVarName % . !x
set !SdValue % . !SDVarName
set !SDBufferText !SDBufferText , !SDAnd , !SDEcho , %ENs_PercentSign , !SdVarName , #spc , !SDValue , !SDFile
}
}
if %ENs_Cmd = N/A
gosub ENs_SetupCommandLine
Execute %ENs_Cmd /c !SDBufferText
Return
sub ENs_LoadData ; %filename
call %1
return
Sub ENs_ClearFile
set !SDFileName %1
if %ENs_Cmd = N/A
gosub ENs_SetupCommandLine
set !clOutput #SMC , #spc , ENs , #spc , Var , #spc , Save
Execute %ENs_Cmd /c Echo !clOutput > !SDFileName
Return
Sub ENs_SetupCommandLine
Set %ENs_Cmd cmd.exe
Str Left #OSVer 1
If #StrRes = 1
Set %ENs_Cmd command.com
If #StrRes = 2
Set %ENs_Cmd cmd.exe
set %ENs_PercentSign %
Return