
! script name: filing.d/opensafetystore
! topic: read safety stored job

!A
!A NAME:
!A
!A 	Recover Backup
!A
!A DESCRIPTION:
!A
!A 	This script opens the current safetystore file in the
!A	users current working directory.
!A
!B INSTRUCTIONS:
!B
!B	THIS ERASES THE CURRENT JOB. LOAD Yes / No:
!B 		Answering "Y" will perform a "delete all" operation
!B 		removing ALL existing geometry, before loading the
!B 		saved file.  Answer "N" to leave the script.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: open safety store file ")

DIM Answer$[256],Destination$[256],Header$[4096]
DIM Startup$[256],Setconstants$[256],Ac$[256]
DIM Store_dir$[255],Retrieve_dir$[255],Pics_dir$[255]
DIM Iges_dir$[255],Dxf_dir$[255],Use_widget$[255]

stat= NamedVarStr("startup script",WsSystemVars,"startup",Startup$)
stat= NamedVarStr("startup constants",WsSystemVars,"setconstants",SetConstants$)

DeActivateUndo
Stat=SetInputFormat("a1=",",Y,N,")
Stat=SetEqualsValue(0,"Y")
Stat=GetValue("THIS ERASES THE CURRENT JOB. LOAD Yes / No ",Answer$)
IF ExitScript(Destination$) OR Answer$="N" THEN Leave

Stat= NamedVarStr("storage dir",WsSystemVars,"/usr/weber/ST/",Store_dir$)
Stat= NamedVarStr("retrieve dir",WsSystemVars,"/usr/weber/ST/",Retrieve_dir$)
Stat= NamedVarStr("pics dir",WsSystemVars,"/usr/weber/ST/pics/",Pics_dir$)
Stat= NamedVarStr("iges storage dir",WsSystemVars,"/usr/weber/ST/iges/",Iges_dir$)
Stat= NamedVarStr("dxf storage dir",WsSystemVars,"/usr/weber/ST/dxf/",Dxf_dir$)
Stat= NamedVarStr("use iges widget",WsSystemVars,"no",Use_widget$)
Use_safe= NamedVarVal("use backup routine",WsSystemVars,0.0)
Time_check= NamedVarVal("time check",WsSystemVars,720.0)

DeleteAll
PlotOff
Stat=ReadStoredFile("safetystore",1.0)
PlotOn

V1=CreateVariable("startup script",WsSystemVars,Startup$)
V1=CreateVariable("startup constants",WsSystemVars,SetConstants$)
V1=CreateVariable("storage dir",WsSystemVars,Store_dir$)
Stat= SetVarSubType(V1,WsNVTypeDir)
V1=CreateVariable("retrieve dir",WsSystemVars,Retrieve_dir$)
Stat= SetVarSubType(V1,WsNVTypeDir)
V1=CreateVariable("pics dir",WsSystemVars,Pics_dir$)
Stat= SetVarSubType(V1,WsNVTypeDir)
V1=CreateVariable("iges storage dir",WsSystemVars,Iges_dir$)
Stat= SetVarSubType(V1,WsNVTypeDir)
V1=CreateVariable("dxf storage dir",WsSystemVars,Dxf_dir$)
Stat= SetVarSubType(V1,WsNVTypeDir)
V1=CreateVariable("use iges widget",WsSystemVars,Use_widget$)
Stat= SetVarSubType(V1,WsNVTypeYesNo)
V1=CreateVariable("use backup routine",WsSystemVars,Use_safe)
Stat= SetVarSubType(V1,WsNVTypeYesNo)
V1=CreateVariable("time check",WsSystemVars,Time_check)

Stat= CurrentHeader(Header$)
IF LEN(Header$) THEN
        Head=ReadUserData(WsGeneralString,"HEADER",Header$)
        IF ValidGeometry(Head) THEN
		Stat=GetUserString(Head,"Accumulated Time:",Ac$)
		AccTime = VAL("0"&TRIM$(Ac$))
		V1=CreateVariable("accumulated time",WsSystemVars,AccTime)
		V1=CreateVariable("job start time",WsSystemVars,TIMEDATE)
		Enti= UserDataString(Head,Header$)
		Stat= FileHeader(Header$)
		Stat= DeleteEntity(Head)
        END IF
END IF

ResizeAll

Leave:!
LowerFileBox
Stat=SetInputFormat("n4","")
IF LEN(Destination$) THEN LOAD Destination$
LOAD SetConstants$
END

