
! script name: archive.d/editarchtext

!A
!A NAME:
!A
!A	EDIT ARCHIVE TEXT 
!A
!A DESCRIPTION:
!A
!A	This script allows an archive files .txt .hpgl and .html  files 
!A	to be edited.
!A
!B INSTRUCTIONS:
!B
!B
!# see also - htdocs/help.d/archive.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: edit archive text file ")

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 Namelist1$[32000]
DIM Namelist2$[32000]
DIM A$[512]
DIM Editor$[256]
DEG

Stat= NamedVarStr("archive dir",WsSystemVars,"/usr/weber/archive/",Archive$)
Stat= NamedVarStr("file editor",WsSystemVars,"notepad.exe",Editor$)
Flip_file= NamedVarVal("flip crlf",WsSystemVars,0)

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


Start:!

Project_dir:!
Ques$= "SELECT PROJECT TO BE LISTED "
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$= "TEXT FILES"
Choice$= "selected file"
Mask$="*"
Namelist1$=DirectoryNamesStr(Revision_dir$,Mask$,WsAscending,"",".txt")
Namelist2$=DirectoryNamesStr(Revision_dir$,Mask$,WsAscending,"",".hpgl")
Namelist1$= Namelist1$&Namelist2$
Namelist2$=DirectoryNamesStr(Revision_dir$,Mask$,WsAscending,"",".html")
Namelist1$= Namelist1$&Namelist2$
Namelist2$=DirectoryNamesStr(Revision_dir$,Mask$,WsAscending,"",".htm")
Namelist1$= Namelist1$&Namelist2$
Stat=GeneralListBox(D_label$,Choice$,Namelist1$)

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

LowerSelectBox

Stat=EditFile(Editor$,Filename$,Flip_file)

Leave:!
LowerSelectBox

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

