
! script name: archive.d/archfiletables
! topic: import tables from an archived file.

!A
!A NAME:
!A
!A	Import archived file tables.
!A
!A DESCRIPTION:
!A
!A	This script imports all tables present in an archived file.
!A
!B INSTRUCTIONS:
!B
!B
!# see also - htdocs/help.d/items.htm
!# see also - htdocs/help.d/property.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: import archived file tables ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Class$[256]
DIM File$[256]
DIM Ques$[256]
DIM D_label$[256]
DIM Choice$[256]
DIM Archive$[512]
DIM Project$[512]
DIM Prefix$[256]
DIM Archive_dir$[512]
DIM Project_dir$[512]
DIM Current_dir$[512]
DIM Filename$[512]
DIM A$[512]
DIM B$[512]

DeActivateUndo
File$= "tempdata"
Stat= RemoveFile(File$)
Start:!

Stat= NamedVarStr("archive dir",WsSystemVars,"/usr/weber/archive/",Archive$)
IF NOT DoesFileExist(Archive$) THEN Leave
Archive_dir$= Archive$
Prefix$= "revision"

Project_dir:!
Ques$= "SELECT PROJECT"
D_label$= "PROJECTS"
Choice$= "selected project"
Answer$= SelectDirectory(Archive_dir$,"*",Ques$,D_label$,Choice$,Prefix$,Current_dir$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "New", "CANCEL"
        GOTO Leave
END SELECT
Answer$= TRIM$(Answer$)
Project$= PathNameFile(Answer$)
Project_dir$= Answer$
IF NOT DoesFileExist(Project_dir$) THEN
        GOTO Project_dir
ELSE
        Filename$= CurrRevisionName(Project_dir$,Prefix$,"synfile")
END IF
LowerSelectBox


Group= ReadFileTables(Filename$)
ResizeAll
Stat= PlotEntity(Group)
Stat= DeleteEntity(Group)

GOTO Start


Leave:!
Stat=SetInputFormat("n4","")
Stat= DeleteEntity(Group)
LowerSelectBox
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
