
! script name: filing.d/removefile
! topic: remove file

!A
!A NAME:
!A
!A 	Remove
!A
!A DESCRIPTION:
!A
!A 	This script will remove a file from a specified directory.
!A

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

DIM Answer$[256]
DIM Destination$[256]
DIM Dir$[256]
DIM D_label$[256]
DIM Sub_label$[256]
DIM F_label$[256]
DIM Choice$[256]
DIM Mask$[32]

Stat= NamedVarStr("storage dir",WsSystemVars,"/usr/weber/ST/",Dir$)
D_label$="DIRECTORY"
Sub_label$="SUB DIRECTORIES"
F_label$="FILES"
Choice$="FILE TO OPEN"
Mask$="*"

Question:!
Stat=UserFileBox(Dir$,Mask$,D_label$,Sub_label$,F_label$,Choice$)
Stat=SetInputFormat("a99","")
Stat=GetValue("SELECT FILE TO DELETE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "CANCEL" THEN Leave

Stat= RemoveFile(Answer$)
Tmp_var=0
LOOP 
	EXIT IF POS(Answer$[Tmp_var+1],"/")=0
	Tmp_var= Tmp_var+POS(Answer$[Tmp_var+1],"/")
END LOOP
Dir$= Answer$[1,Tmp_var]

GOTO Question

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

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


