
! script name: archive.d/viewarchhtml
! topic: View archive .html files

!A
!A NAME:
!A
!A	View Archive .html Files
!A
!A DESCRIPTION:
!A
!A	This script allows archive html files to be viewed.
!A
!# see also - htdocs/help.d/archive.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: view archive html 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 Hostname$[512]
DIM Filepath$[512]
DIM Netscape$[512]
DIM Namelist1$[10000]
DIM Namelist2$[10000]
DIM A$[512]
DIM Drive_letter$[32]
DEG

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

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

IF ARGC<2 THEN
        View_mode= 1
ELSE
        View_mode= VAL(ARGV(1))
END IF

Netscape$= "/usr/weber/bin/browser.ksh"
Hostname$=GetHostName
System_id= OSystemId

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

IF View_mode = 2 THEN Start_process
D_label$= "PICS FILES"
Choice$= "selected file"
Mask$="*"
Namelist1$=DirectoryNamesStr(Revision_dir$,Mask$,WsAscending,"",".html")
Namelist2$=DirectoryNamesStr(Revision_dir$,Mask$,WsAscending,"",".htm")
Namelist1$= Namelist1$&Namelist2$
Namelist2$=DirectoryNamesStr(Revision_dir$,Mask$,WsAscending,"",".txt")
Namelist1$= Namelist1$&Namelist2$

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

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


Start_process:!
LowerSelectBox
Stat=DisplayMessage("LOADING HTML VIEWER")

N1= POS(Revision_dir$,":")
IF N1>1 AND N1< LEN(Revision_dir$) THEN
	Drive_letter$= Revision_dir$[1,N1-1]
	Revision_dir$= Revision_dir$[N1+1]
ELSE
	Drive_letter$= "C"
	IF N1> 0 THEN Project_dir
END IF

SELECT View_mode
CASE 2
	SELECT System_id
	CASE 1
		Filepath$= " file:"&Revision_dir$&" &"
	CASE ELSE
		Filepath$= " 'file:///"&Drive_letter$&"|"
		Filepath$= Filepath$&Revision_dir$&"' &"
	END SELECT
	Stat= StartProcess(Netscape$&Filepath$)
	Stat= SynergySleep(5)
! 	Stat=OutputString("html_dir",Revision_dir$,WsNewFile)
! 	Stat = MessageFileBox("html_dir","HTML_DIR","")
CASE ELSE
	SELECT System_id
	CASE 1
		Filepath$= " file:"&Revision_dir$&"/"&Filename$&" &"
	CASE ELSE
		Filepath$= " 'file:///"&Drive_letter$&"|"
		Filepath$= Filepath$&Revision_dir$&"/"&Filename$&"' &"
	END SELECT
	Stat = MessageFileBox(Revision_dir$&"/"&Filename$,"HTML_VIEW","")
END SELECT
! Stat= StartProcess(Netscape$&Filepath$)
! Stat= SynergySleep(5)

Leave:!
LowerSelectBox

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

