
! script name: filing.d/readfile
! topic: read geometry file

!A
!A NAME:
!A
!A 	Open
!A
!A DESCRIPTION:
!A
!A 	This script allows a geometry file to be read in.
!A 	(Current information will be deleted.)
!A
!B INSTRUCTIONS:
!B
!B 	OPEN JOB FILE Yes or No: Enter "Y" to bring in an existing
!B 		file, enter "N" to abort procedure.  NOTE: If "Y"
!B 		is selected current information is deleted.
!B
!B 	SELECT EXISTING JOB FILE: The selection box will appear at
!B 		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 Jobname$[256]
DIM Mask$[32]
DIM Header$[4096]
DIM Startup$[256]
DIM Setconstants$[256]

DeActivateUndo
stat= NamedVarStr("startup script",WsSystemVars,"startup",Startup$)
stat= NamedVarStr("startup constants",WsSystemVars,"setconstants",SetConstants$)
Stat=SetInputFormat("a1=",",Y,N,")
Stat=SetEqualsValue(0,"Y")
Stat=GetValue("OPEN JOB FILE Yes or No",Answer$)
IF (ExitScript(Destination$)) THEN Leave

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

Stat= NamedVarStr("retrieve dir",WsSystemVars,"/usr/weber/ST/",Dir$)
D_label$="DIRECTORY"
Sub_label$="SUB DIRECTORIES"
F_label$="FILES"
Choice$="FILE TO OPEN"
Mask$="[A-Za-z0-9]*"

Stat=UserFileBox(Dir$,Mask$,D_label$,Sub_label$,F_label$,Choice$)
Stat=SetInputFormat("a99","")
Stat=GetValue("SELECT EXISTING JOB FILE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "CANCEL" THEN Leave
IF NamedVarVal("save dirs",WsSystemVars,0) THEN V1=CreateVariable("retrieve dir",WsSystemVars,PathNameDirectory(Answer$))

IF POS(Answer$,".") THEN
	SELECT Answer$[LEN(Answer$)-3;4]
	CASE ".syn",".nte",".cmd",".tpe"
		Name$= Answer$[1,LEN(Answer$)-4]
		Jobname$= Name$&".syn"
	CASE ELSE
		GOTO No_ext
	END SELECT
ELSE
No_ext:	Name$= Answer$
	Op_mode= 1
	Jobname$= Name$
END IF
LowerFileBox

StdWorkplane
DeleteAll
PlotOff
Stat=ReadStoredFile(Jobname$)
PlotOn
V1=CreateVariable("startup script",WsSystemVars,Startup$)
V1=CreateVariable("startup constants",WsSystemVars,SetConstants$)

ResizeAll

Leave:!

LowerFileBox
Stat=SetInputFormat("n4","")

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


