home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PCBOARD
/
TAPEFLAG.ZIP
/
TAPEFLAG.PPS
< prev
next >
Wrap
Text File
|
1994-03-05
|
21KB
|
612 lines
;******************************************************************************
; TAPEFLAG.PPE version 1.0 released on 3/5/94 by Steve Prater
;
; TAPEFLAG.PPE is a replacement for PCBoard's internal "more?" prompt, gives
; PCBoard v15.1 the easiest-to-use system for flagging and viewing files of
; any BBS around. It gives callers the ability to point and shoot when
; flagging or viewing files. It now gives you the ability to restore files
; from a tape drive.
;
; This PPE is a modification to David Terry's FLAG.PPE v3.0 and is distributed
; along with the original code in accordance with the requirements set forth
; in David Terry's FLAG.PPE v 3.0 documentation.
;******************************************************************************
' check to see if caller has ANSI capabilities and, if not, display the old
' prompt and exit - let PCBoard handle the input.
;***********************************************************************
IF (! ANSION()) THEN
DISPFILE PPEPATH()+"FLAGOLD",LANG
END
ENDIF
BOOLEAN exitflag ' Flag to determine when we should exit
BOOLEAN rip ' Flag to indicate RIPscrip is in use
STRING text ' The text that the caller types
STRING key ' Keystroke text
STRING tape ' drive and path to tape restore software
STRING restoreline ' Command line used with tape restore software
' read from .CFG file
STRING restoreline1 ' command line passed to tape software
STRING restoredir ' Directory to restore files to
STRING RestoreCMD ' command to make tape operate in restore mode
STRING volnum ' tape volume number
STRING ppepath ' path to PPE file
STRING rc ' Stores return code from shell function
STRING BS ' An ASCII backspace character
STRING BS2 ' An ASCII backspace character
STRING CR ' An ASCII carriage return character
STRING ESC ' An ASCII esc character
BYTE len ' Length of the text the caller has typed
BYTE oldy ' Last row position of cursor
BYTE newy ' New row position of cursor
BYTE filedir ' File directory of files being scanned
STRING filenames(23) ' The names of the files found on the screen
STRING filename ' The name of the file that is being processed
STRING fileimage ' Includes the color codes for restoration of text
STRING warningfile ' full path and file name of lenth of time to restore
' warning file.
STRING nodeloc ' hold path & filename of node.loc file
STRING tapeconf ' sysop's tape specific conference number
STRING dirnum ' File directory in use
STRING ansiline ' individual line read from WARNINGFILE
STRING multinode ' Y or N for allow multiple node access
STRING allowednode ' node # allowed if not multiple node
INTEGER curconf ' Current Conference user is in
INTEGER n ' integer used for counting reps in loops
;***********************************************************************
; Initializations
BS = CHR(8) ' Backspace Key
BS2 = CHR(127) ' Alternate Backspace Key
CR = CHR(13) ' Carriage Return
ESC = CHR(27) ' ESC character
len = 0 ' Initialize to 0 bytes in the input buffer
text = "" ' Initialize to an empty input buffer
;***********************************************************************
; Main Program
' Open and read configuation file
GOSUB config:
:MAIN
' in case the last invocation of flag.ppe saved
RESTSCRN ' the screen, restore it now
CLREOL ' clear the line for input
GOSUB displayprompt ' display the new prompt
GOSUB scanforfiles ' build filenames array
' While the user hasn't exited, get keystrokes and act on them.
' Exiting will occur when the caller presses ENTER.
WHILE (!exitflag) DO
key = INKEY() ' Get a keypress from the user
if (key <> "") THEN ' If the user pressed a key, then let's process it
' If it is the FIRST keystroke, signified by the buffer having 0 bytes
' in it, then check to see if it is a SPACE. If so, then we'll go into
' MARK mode. If not, then we'll process the keystrokes the same way that
' PCBoard would .. gathering them up into a buffer. Once the ENTER key
' is pressed, we'll exit out and stuff PCBoard's keyboard buffer with the
' keystrokes that were collected.
IF (len = 0 & key = " ") THEN
oldy = GETY()
newy = 0
PRINT CR
CLREOL
PRINT CR
CLREOL
PRINT ESC+"[s" ' save the current cursor position
' Let the caller know what he can do while in MARK mode
DISPFILE PPEPATH()+"FLAGBAR",GRAPH+LANG
' Move the cursor back to the first column
PRINT CR
' Find the first filename on the screen.
GOSUB findfile
' If a filename was found, then findfile highlighted it. Now wait for
' another keystroke to see if the user whats to mark this one, or move
' on to another one, or exit out. Marking is done by pressing ENTER,
' moving to another file is done by pressing SPACE, viewing the file is
' done by pressing "V", and exiting is done by pressing ESC.
IF (filename <> "") THEN
WHILE (key != ESC & key != CR & UPPER(key) != "V") DO
key = INKEY()
' If the key pressed was a SPACE then the user has decided to skip
' over that file. So unhighlight it, then try to find another
' file. If a file is found, we'll stay in this loop. If one is
' not found, then we'll restore the original prompt and go back to
' waiting for keystrokes in case the caller wants to start over
' (marking files) or wants to manually (F)lag them instead.
IF (key = " ") THEN
GOSUB unhighlight
GOSUB findfile
IF (filename = "") THEN
GOSUB restorecursor
GOSUB displayprompt
GOTO bottom
ENDIF
ENDIF
ENDWHILE
' If we've gotten this far, then ESC, CR or V was pressed. We'll
' unhighlight the file, restore the prompt and then, if CR was pressed,
' meaning the user wished to MARK that file, then will stuff PCBoard's
' keyboard buffer with a FLAG command and the name of the file to flag.
' If V was pressed, then we'll instead stuff the buffer with a command
' to VIEW the file.
GOSUB unhighlight
GOSUB restorecursor
IF (key = CR) THEN
'This subroutine checks the current conf. and restores the file
'from tape if the user is in the tape specific conference, or
'else reads it in directly from the hard disk if the user is in
'any other conference.
GOSUB restorefromtape
ELSEIF (UPPER(key) = "V") THEN
' save the screen into PCBoard's memory so that we can restore it
' when FLAG.PPE is called up again, then issue the view command
SAVESCRN
KBDSTUFF "V "+filename+CR
END
ENDIF
ELSE
GOSUB restorecursor
ENDIF
GOSUB displayprompt
CONTINUE
ELSEIF (key == BS | key == BS2) THEN
' If the caller pressed backspace or delete, then delete the character
' to the left, and remove it from the input buffer. Of course, if the
' caller hasn't typed anything yet, or if the caller has already
' backspaced everything out, signified by the len being 0 (meaning there
' are 0 bytes in the buffer), then we'll just loop back around waiting
' for more keystrokes
IF (len > 0) THEN
PRINT BS+" "
len = len - 1
text = LEFT(text,len)
ELSE
CONTINUE
ENDIF
ELSEIF (key == CR) THEN
' If it's a carriage return then set the flag to exit
exitflag = TRUE
ELSEIF (LEN(key) > 1 | key < " ") THEN
' Special keys, such as UP, DOWN, etc, return multi-letter values such
' as "UP" and "DOWN" when the INKEY() function is called. Since we just
' want to ignore special characters, we'll use the CONTINUE statement to
' jump back to the top of the loop
'
' We also want to avoid displaying "control characters" so anything
' less than a SPACE should also be skipped.
CONTINUE
ELSEIF ((len = 0) & ((key = "?") | (UPPER(key) = "H"))) THEN
' If the user typed "?" or "H" then we want to display a help file.
' First we'll save the current screen, then display the help file, and
' then restore the saved screen after the caller has read the help file.
SAVESCRN
NEWLINE
DISPFILE PPEPATH()+"FLAGHLP",GRAPH+LANG
NEWLINE
WAIT
RESTSCRN
CONTINUE
ELSEIF ((key >= " ") & (len < 80)) THEN
' Here we are just gathering up keystrokes and putting them into an
' input buffer. As long as the keystrokes are greater than or equal to
' a SPACE we'll just add them in until a limit of 80 characters is
' reached. PCBoard won't let you type more than 80 characters at that
' prompt anyway so we might as well keep the same limit.
text = text + key
len = len + 1
ENDIF
PRINT key ' Print any keystrokes the caller types
ENDIF
:bottom
ENDWHILE
' If we've gotten this far, then the caller has pressed ENTER so we'll stuff
' whatever the caller has typed into PCBoard's input buffer and let PCBoard
' process the request.
'
' But first, if the command begins with V then it may be a view files command.
' Verify that assumption by checking to see if the user typed "V" and pressed
' ENTER (check length equal to 1) or if the user typed "V filename" (check
' for length greater than or equal to 3 for "F f")
text = RTRIM(text," ")
IF (UPPER(LEFT(text,1)) = "V") THEN
IF (LEN(text) = 1) THEN
CLREOL
filename = ""
PROMPTSTR 240,filename,12,MASK_FILE(),FIELDLEN
filename = RTRIM(filename," ");
IF (LEN(filename) = 0) THEN
CLREOL
KBDSTUFF CR
END
ENDIF
NEWLINE
' the lines below could be used to specify a different "default extension"
' for archive files in different conferences - uncomment and adapt as
' necessary to suit your needs
'
' IF (INSTR(filename,".") = 0) THEN
' IF (CURCONF() = 30) THEN
' filename = filename + ".ARJ"
' ELSEIF (CURCONF() = 50) THEN
' filename = filename + ".ZOO"
' ENDIF
' ENDIF
text = "V "+filename
' save the screen to PCBoard's memory so that the next invocation of
' FLAG.PPE will restore the screen
SAVESCRN
ELSEIF (LEN(text) >= 3) THEN
' save the screen to PCBoard's memory so that the next invocation of
' FLAG.PPE will restore the screen
CLREOL
' the lines below could be used to specify a different "default extension"
' for archive files in different conferences - uncomment and adapt as
' necessary to suit your needs
'
' IF (INSTR(filename,".") = 0) THEN
' IF (CURCONF() = 30) THEN
' text = text + ".ARJ"
' ELSEIF (CURCONF() = 50) THEN
' text = text + ".ZOO"
' ENDIF
' ENDIF
SAVESCRN
ELSE
KBDSTUFF CR
END
ENDIF
ENDIF
KBDSTUFF text+CR
END
;***********************************************************************
'
' This subroutine restores the cursor position. It does this using an ANSI
' command that simply restores a previously saved cursor position. In
' addition, we'll clear the line before returning.
:restorecursor
PRINT ESC+"[u"
CLREOL
RETURN
;***********************************************************************
'
' This is a subroutine that displays the new prompt and then sets the color to
' the default for input.
:displayprompt
DISPFILE PPEPATH()+"FLAGNEW",LANG
DEFCOLOR
RETURN
;***********************************************************************
'
' This is a subroutine that checks the filenames() array to locate the next
' file on screen. If RIPscrip is used, then special commands (which are
' passed via a mouse-click from the caller's terminal, are used to identify
' which file is desired.
'
' If a valid filename is found, it is stored in a variable called filename.
' Also, it calls another subroutine to highlight the filename on the screen.
:findfile
IF (rip) THEN
newy = 0
key = ""
WHILE (newy = 0) DO
key = INKEY() ' watch for the next character
newy = ASC(key)
IF (newy >= 129 & newy <= 151) THEN
newy = newy - 128
IF (filenames(newy) <> "") THEN
GOSUB highlight
filename = filenames(newy)
RETURN
ELSE
newy = 0
ENDIF
ENDIF
ENDWHILE
ELSE
WHILE (newy < oldy) DO
newy = newy + 1
IF (filenames(newy) <> "") THEN
GOSUB highlight
filename = filenames(newy)
RETURN
ENDIF
ENDWHILE
ENDIF
' no valid filename was found, return with an empty filename
filename = ""
RETURN
;***********************************************************************
'
' This is a subroutine that highlights the filename moving the cursor to the
' correct line and then changing the color to black on white and printing the
' filename. Prior to highlighting the filename, it saves a color image of the
' filename so that, when it comes time to unhighlight the file, the image can
' be restored.
:highlight
' move the cursor back to where it started, at the bottom, and then move
' it up to the appropriate line on the screen.
PRINT ESC+"[u"+ESC+"["+STRING(oldy-newy)+"A"
' get the file image (text & attributes) for later restoration
fileimage = SCRTEXT(1,newy,13,TRUE)
' then highlight the filename and return
COLOR @X70
PRINT filenames(newy)+CR
RETURN
;***********************************************************************
'
' This is a subroutine that unhighlights the filename by printing the file
' image, which includes color codes as well as the filename.
:unhighlight
PRINT fileimage+CR
RETURN
;***********************************************************************
'
' This subroutine scans the screen at startup to see and fills an array called
' filenames() with the names of all files found on screen. If RIPscrip is in
' use, it will also send out RIPscrip commands to define the location of the
' filenames on screen so that the caller can use a mouse to point and click.
:scanforfiles
IF (GRAFMODE() = "R") THEN
rip = TRUE
ENDIF
' NOTE: This loop is unnecessary because PPL automatically initializes
' all array elements to 0 or blank
'
' FOR newy=1 TO 23
' filenames(newy) = "" ' initialize the array elements
' NEXT
newy = 1
WHILE (newy > 0) DO
' get a filename off the screen ... if a filename is found, the filename
' variable will be updated, if no more filenames are found, newy will be
' set to 0.
SCRFILE newy, filename
IF (newy <> 0) THEN
' store the filename that was found into an array
filenames(newy) = filename
' If in RIPscrip mode, define the mouse region where the filename is
' located. The coordinates are defined in X,Y coordinates of 0,newy and
' 13,newy+1. The X coordinate (0 to 13) defines the length of the name.
' The Y coordinate (newy to newy+1) defines the height of the name.
' An 8x8 font is assumed. The CHR(newy+128) is a "command" that we will
' be using to communicate back to FLAG.PPE the position of the file being
' selected via mouse click.
IF (rip) THEN
MOUSEREG 0,1,newy,13,newy+1,8,8,TRUE,FALSE," "+CHR(newy+128)
ENDIF
INC newy
ENDIF
ENDWHILE
' finish up the mouse region definitions
IF (rip) THEN
MPRINT "!|#|#|#"+CR+chr(10)
ENDIF
RETURN
;***********************************************************************
;
; This subroutine restores the tagged file from tape if the user
; is currently located in conference #1
:restorefromtape
let dirnum =" "
SAVESCRN ' save screen so we can restore it
' after displaying warning file
IF (CURCONF() = tapeconf) THEN ' if user is in the tape conference then
' goto the tape restore mode or else goto
' the regular FLAG mode
inputtext "What directory Number are you looking at @X09(1-18)@X07",dirnum,@X07,2
PRINT CR
CLREOL
GOSUB CHECKNODE ' see if multinode access is allowed.
GOSUB LOCKNODE ' see if tape drive is already in use
' Now OPEN and dsiplay the time warning file
FOPEN 2, warningfile(),O_RD,S_DN
IF (FERR(2)) then
PRINTLN "Error....Exiting...."
END
ENDIF
let n = 1
FGET 2, ansiline
println ansiline
while (!FERR(2)) do
inc n
FGET 2, ansiline
println ansiline
endwhile
Fclose 2
let nodeloc = ppepath()+"node.loc"
FCREATE 2, nodeloc,O_WR,S_DB
fput 2, "Tape drive locked! Restoring File "+filename+"."
fclose 2
if (dirnum() < 10) then
LET restoreline1=" "+restorecmd+" "+restoreline+dirnum+"A\"+filename+" "+restoredir+" /v="+volnum
elseif (dirnum() > 9) then
let restoreline=left(restoreline(), len(restoreline) - 1)
LET restoreline1=" "+restorecmd+" "+restoreline+dirnum+"A\"+filename+" "+restoredir+" /v="+volnum
elseif (dirnum() > 99) then
let restoreline=left(restoreline(), len(restoreline) - 2)
LET restoreline1=" "+restorecmd+" "+restoreline+dirnum+"A\"+filename+" "+restoredir+" /v="+volnum
endif
shell false,rc,tape,restoreline1
delete nodeloc
RESTSCRN
PRINT CR
CLREOL
KBDSTUFF "F "+filename+CR
ELSEIF (CURCONF() <> 1) THEN
KBDSTUFF "F "+filename+CR
ENDIF
return
;***********************************************************************
; This routine opens and reads the FLAG1.CFG file
;
;
:CONFIG
;
let n() = 0
FOPEN 1, ppepath()+PPEname()+".CFG",O_RD,S_DN
IF (FERR(1)) then
PRINTLN "Error....Exiting...."
END
ENDIF
let n() = N + 1
FGET 1, dirnum
let n() = N + 1
FGET 1, tape
let n() = N+1
FGET 1, restorecmd
let n() = N+1
FGET 1, restoreline
let n() = N+1
FGET 1, restoredir
let n() = N+1
FGET 1, volnum
let n() = N+1
FGET 1, warningfile
let n() = N+1
FGET 1, tapeconf
let n() = N+1
FGET 1, multinode
let n() = N+1
FGET 1, allowednode
FcLOSE 1
RETURN
*****************************************************************************
'
:locknode
'
' This routine checks to see if the tape drive is in use by another node.
' If so, it displays the locked node message.
'
'
if (exist(ppepath()+"node.loc")) then
Println "@CLS@@X00@X07"
Println "@X0F @X47╔══════════════════════════════════════════════╗"
Println "@X0F @X47║ Sorry, the tape drive is in use by another ║"
Println "@X0F @X47║ node. Please try again later! Thanks! ║"
Println "@X0F @X47╚══════════════════════════════════════════════╝"
println "@XFF "
println
wait
goto MAIN
endif
return
'
*****************************************************************************
'
:checknode
'
' This routine checks to see if multinode access is allowed. If not, it
' determines what node is allowed access.
'
'
'if multinode = "Y" then
if (multinode = "Y") then
' n = 1 'This is just because it HAD to evaluate something
return
endif
if (PCBNODE() = allowednode) then
' n=1 'This is just because it HAD to evaluate something
return
elseif (PCBNODE() <> allowednode) then
' n=1 'This is just because it HAD to evaluate something
Println "@CLS@@X00@X07"
Println "@X0F @X47 "
Println "@X0F @X47 Sorry, You must call back on node "+Allowednode+" to restore "
Println "@X0F @X47 files from tape! Thanks! "
Println "@X0F @X47 "
println "@XFF "
println
wait
goto MAIN
endif
return