
! script name: archive.d/sendarchhpgl
! topic: Sent a .hpgl file from the archive.

!A
!A NAME:
!A
!A	Send .hpgl
!A
!A DESCRIPTION:
!A
!A	This script allows archive .hpgl files to be sent to a device.
!A
!# see also - htdocs/help.d/archive.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: send archive .hpgl files ")

DIM Answer$[256],Destination$[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 Revision_dir$[512]
DIM Last_rev$[512]
DIM Filename$[512]
DIM Namelist$[32000]
DIM A$[512]
DEG

DeActivateUndo
Stat= NamedVarStr("archive dir",WsSystemVars,"/usr/weber/archive/",Archive$)

IF NOT DoesFileExist(Archive$) THEN Leave
Archive_dir$= Archive$
Prefix$= "revision"


Start:!

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
        A$= CurrRevisionName(Project_dir$,Prefix$,"info.txt")
	Revision_dir$= PathNameDirectory(A$)
END IF
IF NOT LEN(Revision_dir$) THEN Project_dir

D_label$= "PLOT FILES"
Choice$= "selected file"
Mask$="*"
Namelist$=DirectoryNamesStr(Revision_dir$,Mask$,WsAscending,"",".hpgl")

IF LEN(Namelist$) < 1 THEN Project_dir
Stat=GeneralListBox(D_label$,Choice$,Namelist$)

Stat=SetInputFormat("a99","")
Stat=GetValue("SELECT PLOT FILE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="CANCEL" THEN Leave
LowerSelectBox
Filename$=FileNameString(Revision_dir$,Answer$)

LowerSelectBox

Stat=DisplayMessage("SENDING PLOT FILE")

	stat=ChangeLabelStr("ScriptNameStatus","SYNPLOT,A,"&Filename$)
! 	stat= StartProcess("synplot.ksh "&Filename$&" &")

Stat= SynergySleep(2)


Leave:!
LowerSelectBox

Stat=SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
         LOAD "typecontrol"
ELSE
         LOAD Destination$
END IF
END

