
! script name: filing.d/copyfile
! topic: copy stored job

!A
!A NAME:
!A
!A 	Copy File
!A
!A DESCRIPTION:
!A
!A 	This script will copy a stored job.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT EXISTING JOB FILE: The selection box will
!B 		appear at this time for a selection to be made.
!B
!B 	COPY NAME: Enter the name.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: copyfile ")

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Copyname$[256]
DIM Dir$[256]
DIM D_label$[256]
DIM Sub_label$[256]
DIM F_label$[256]
DIM Choice$[256]
DIM Mask$[32]
DIM Store_dir$[255]

Start:!
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]*"

StdWorkplane

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
LowerFileBox
Name$= Answer$

Stat=SetInputFormat("a99","")
Stat=GetValue("COPY NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "CANCEL" THEN Leave
LowerFileBox
Copyname$= Answer$
IF NOT POS(Copyname$,"/") THEN
	Copyname$= FileNameString(Dir$,Copyname$)
END IF

F_type= DoesFileExist(Copyname$)
SELECT F_type
CASE 0
        Stat=SetInputFormat("a1",",Y,N,")
        Stat=GetValue("COPY FILE: Yes or No ",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
        IF Answer$= "Y" THEN
		Stat= CopyFile(Name$,Copyname$)
        END IF
CASE 1
        Stat=SetInputFormat("a1",",Y,N,")
        Stat=GetValue("FILE EXISTS: OVERWRITE  Yes or No",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
        IF Answer$= "Y" THEN
		Stat= CopyFile(Name$,Copyname$)
        END IF
CASE 2
        Stat=SetInputFormat("a1",",P,")
        Stat=GetValue("COPY NAME IS A DIRECTORY: Proceed ",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
END SELECT

GOTO Start

Leave:!
LowerFileBox
Stat=SetInputFormat("n4","")

IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

