
! script name: filing.d/retrieve
! topic: read entire stored job

!A
!A NAME:
!A
!A 	Re-Open Current
!A
!A DESCRIPTION:
!A
!A 	This script allows the entire stored job to be read in or only the
!A 	geometry or the turbo post portion. (Current information will be
!A 	deleted.)
!A
!B INSTRUCTIONS:
!B
!B 	OPEN Entire, Geometry, Turbo_info, OR None: 
!B
!B 		E - Entire allows all stored information pertaining to a
!B 		    specified job to be brought in.
!B 		G - Geometry retrieves only the file with the geometry in it.
!B 		T - Turbo_info retrieves only the file pertaining to TURBO POST.
!B 		P - Program (nc tape) retrieves only the nc tape file.
!B 		N - None allows the procedure to be ended.
!B
!B 	SELECT EXISTING JOB FILE: The selection box will
!B 		appear at this time for a selection to be made.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: open ")

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Dir$[256]
DIM D_label$[256]
DIM Sub_label$[256]
DIM F_label$[256]
DIM Choice$[256]
DIM Mask$[32]
DIM Header$[4096]
DIM Tmp$[256]
DIM Jobname$[256]
DIM Jobs$(20,2)[256]
DIM Startup$[256]
DIM Setconstants$[256],Ac$[256]
DIM Store_dir$[255],Retrieve_dir$[255],Pics_dir$[255]
DIM Iges_dir$[255],Dxf_dir$[255],Use_widget$[255]

DeActivateUndo
stat= NamedVarStr("startup script",WsSystemVars,"startup",Startup$)
stat= NamedVarStr("startup constants",WsSystemVars,"setconstants",SetConstants$)
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)

Stat= CurrentHeader(Header$)
IF LEN(Header$) THEN
        Head=ReadUserData(WsGeneralString,"HEADER",Header$)
        IF ValidGeometry(Head) THEN
                Stat=GetUserString(Head,"File name:",Jobname$)
                IF(POS(Jobname$,"NONE")) THEN LOAD "filing.d/retrieve"
        END IF
ELSE
        LOAD "filing.d/retrieve"
END IF

Stat=SetInputFormat("a1=",",Y,N,")
Stat=SetEqualsValue(0,"Y")
Stat=GetValue("ARE YOU SURE Yes or No ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "N" THEN Leave

Stat=SetInputFormat("a1=",",E,G,T,N,C,")
Stat=SetEqualsValue(0,"E")
Stat=GetValue("OPEN Entire, Geometry, Turbo_info, Cnc tape or None",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Op_mode= POS("GETC",Answer$)

IF Answer$="N" THEN LOAD "typecontrol"

IF Op_mode=1 OR Op_mode=2 THEN DeleteAll
PlotOff
IF Op_mode>1 AND Op_mode<4 THEN Stat= RemoveDirFiles("./","*","notepad")
IF Op_mode>1 THEN Stat= RemoveDirFiles("./","*","tapefile")
Stat=ReadStoredFile(Jobname$,Op_mode)
PlotOn

IF Op_mode=1 OR Op_mode=2 THEN
	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)
END IF

Stat= CurrentHeader(Header$)
IF LEN(Header$) THEN
        Head=ReadUserData(WsGeneralString,"HEADER",Header$)
        IF ValidGeometry(Head) THEN
		Stat=GetUserString(Head,"Accumulated Time:",Ac$)
		Stat= PutUserString(Head,"File name:",Jobname$)
		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

IF Op_mode<>4 THEN ResizeAll

Leave:!
LowerFileBox
Stat=SetInputFormat("n4","")

IF (NOT LEN(Destination$)) THEN
	 LOAD SetConstants$
ELSE
	 LOAD Destination$
END IF
END

