
! script name: turbopost.d/recordpost

!A
!A NAME:
!A
!A 	RECORD POST
!A
!A DESCRIPTION:
!A
!A 	This script allows the selection of a post format if one has not been
!A 	selected, and gives the option of starting a new command file, using
!A 	an existing command file, or using a stored command file.  
!A
!B INSTRUCTIONS:
!B
!B 	TurboPost NAME: The POST FORMATS AVAILABLE selection box will
!B 		automatically appear with the available selection of post
!B 		formats.  If a TurboPost FORMAT has already been selected
!B 		this option does not appear.
!B
!B 	New, Existing, OR Stored COMMAND FILE:
!B 		N - New allows a command file to be started and removes the
!B 		    existing command file.
!B 		E - Existing allows the command file that was used last to
!B 		    be used.
!B 		S - Stored allows a command file that has been previously
!B 		    stored to be recalled and used.  The existing command
!B 		    file will be removed.
!B
!# see also - htdocs/help.d/millturbo.htm

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

DIM Answer$[256]
DIM Name$[256]
DIM Destination$[256]

DEG
DIM Dir$[256]
DIM D_label$[256]
DIM Sub_label$[256]
DIM F_label$[256]
DIM Choice$[256]
DIM Mask$[32]
DIM Jobs$(20,2)[15]
DIM Namelist$[32000]
DIM Namelist2$[32000]

DeActivateUndo
Active=ActivePostName(Name$)
IF Active THEN
	 LOAD "turbopost.d/turbocontrol"
END IF

Ask_name:!
Dir$=NamedVariableStr("post dir",WsSystemVars,"/usr/weber/post_formats/")
D_label$="POST FORMATS AVAILABLE"
Choice$="POST FORMAT SELECTED"
Mask$="[A-z]*"

Stat=DirectoryNames(Dir$,Mask$,Namelist$)
Stat= AlphabeticalOrder(Namelist$,",",WsAscending,Namelist2$)
Stat=GeneralListBox(D_label$,Choice$,Namelist2$)
Stat=SetInputFormat("a99","")
Stat=GetValue("TurboPost NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="CANCEL" THEN
	LowerSelectBox
	 LOAD "typecontrol"
END IF

Name$= FileNameString( Dir$,Answer$)

Units= CurrentUnits
Found=RecordPostName(Name$,Units)

IF NOT Found THEN Ask_name

Stat=SetInputFormat("a1=",",N,E,S,")
Stat=SetEqualsValue(0,"E")
Stat=GetValue("New, Existing, OR Stored COMMAND FILE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

IF Answer$="N" THEN
	ON ERROR GOTO Init_menus
	PURGE "command_file"
END IF

IF Answer$="S" THEN
	Num_files= 1
	Jobs$(1,1)= "command_file"
	Jobs$(1,2)= ".cmd"

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

	Stat=UserFileBox(Dir$,Mask$,D_label$,Sub_label$,F_label$,Choice$)
	Stat=SetInputFormat("a99","")
	Stat=GetValue("JOB FILE TO RETRIEVE",Answer$)
	IF (ExitScript(Destination$)) THEN Leave
	IF Answer$= "CANCEL" THEN Leave
	LowerFileBox

	Choice$= Answer$[LEN(Dir$)+1,POS(Answer$,".")-1]

	FOR J= 1 TO Num_files
		Stat= CopyFile(FileNameString(Dir$,Choice$,Jobs$(J,2)),Jobs$(J,1))
	NEXT J

END IF

Init_menus:First=1
First=InitCmdMenu(First,0)

GOTO Leave2

Leave:!
LowerSelectBox
Leave2:!
IF (NOT LEN(Destination$)) THEN
	 LOAD "turbopost.d/turbocontrol"
ELSE
	 LOAD Destination$
END IF
END

