Category : BBS Programs+Doors
Archive   : FLAG22.ZIP
Filename : FLAG.PPS

 
Output of file : FLAG.PPS contained in archive : FLAG22.ZIP
;******************************************************************************
; FLAG.PPE version 2.1 released on 9/22/93 by David W. Terry
;
; FLAG.PPE is a replacement for PCBoard's internal "more?" prompt, gives
; PCBoard v15.0 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.
;
; NOTE: Please DO NOT DISTRIBUTE modified source code without prior permission
; or without meeting the requirements set forth in FLAG.DOC.
;******************************************************************************

BOOLEAN exitflag ' Flag to determine when we should exit

STRING text ' The text that the caller types
STRING key ' Keystroke text

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

INTEGER len ' Length of the text the caller has typed
INTEGER oldx ' Last column position of cursor
INTEGER oldy ' Last row position of cursor
INTEGER newy ' New row position of cursor
INTEGER upcount ' A count of the number of lines to move up

STRING filename ' The name of the file that is being flagged
STRING savetext ' A saved copy - including color codes for restoration
STRING nprompt ' The new prompt to be displayed to the caller
STRING oprompt ' The original prompt that was used in PCBTEXT

INTEGER dotpos ' Used when validating filenames
INTEGER filelen ' Used when validating filenames
INTEGER filesize ' Used when validating filenames
DATE filedate ' Used when validating filenames


;***********************************************************************

; 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

' Below is the prompt we are going to show the caller. There are basically
' two differences between it and the standard prompt:
'
' 1) It uses @minleft@ instead of @timeleft@. The reason is that @minleft@
' shows the caller how many minutes are left AFTER deducting the time
' estimated for any files currently flagged for download.
' 2) It removes the (F)lag option, although it will still work (!), and
' replaces it with (SPACE)=Mark instead.

nprompt = "@X0A(@X0C@MINLEFT@@X0A min left), (H)elp, (V)iew, (@X0FSPACE@X0A)=Mark, More? "
oprompt = "(@TIMELEFT@ min left), (H)elp, (V)iew, (F)lag, More"

;***********************************************************************

; Main Program

IF (! ANSION()) THEN ' check to see if caller has ANSI capabilities
PRINT oprompt ' if not, display the old prompt and then just
END ' get out and let PCBoard handle the input.
ENDIF
' in case the last invocation of flag.ppe saved
RESTSCRN ' the screen, restore it now

CLREOL ' clear the current line
PRINT nprompt ' display the prompt
DEFCOLOR ' set the default color for user input

' 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
oldx = getx()
oldy = gety()
newy = oldy

' Let the caller know what he can do while in MARK mode

PRINT CR+"@CLREOL@@X0APress @X0FSPACE@X0A to move up, @X0FENTER@X0A to select, @X0FV@X0A to view, @X0FESC@X0A to exit"+CR

' Try to find a filename on the screen. If a filename is found, it
' will be signified by the filename being non-blank.

GOSUB findfile

' If a filename was found, then findfile highlighted it, let's 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 restoreline
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
KBDSTUFF "F "+filename+CR
END
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 restoreline
GOTO bottom

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 go to the bottom of the
' loop and loop back around waiting for more keystrokes.

IF (len > 0) THEN
PRINT BS+" "
len = len - 1
text = LEFT(text,len)
ELSE
GOTO bottom
ENDIF

ELSEIF (key == CR) THEN

' If it's a carriage return append it and prepare to exit
text = text + key
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, will drop down to the bottom to
' avoid adding them into the buffer or printing them on the screen.
'
' We also want to avoid displaying "control characters" so anything
' less than a SPACE should also be skipped.

GOTO bottom

ELSEIF ((len = 0) & ((key = "?") | (UPPER(key) = "H"))) THEN

SAVESCRN
NEWLINE
DISPFILE PPEPATH()+"FLAGHLP",GRAPH+LANG ' look for graphics or language
NEWLINE ' versions of the help file
WAIT
RESTSCRN
GOTO bottom

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 any keystrokes the caller types

PRINT key
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 is a view files command so
' save the screen to PCBoard's memory so that the next invocation of FLAG.PPE
' will restore the screen

IF (UPPER(LEFT(text,1)) = "V") THEN
SAVESCRN
ENDIF

KBDSTUFF text
END

;***********************************************************************

' This subroutine restores the cursor position. It does this by moving the
' cursor DOWN the number of lines that it had been moved UP. This is
' determined by subtracting the new cursor position from the old cursor
' position and then creating an ANSI command to move the cursor down that
' many lines and then it clears that line.

:restorecursor
IF (newy < oldy) THEN
PRINT ESC+"["+STRING(oldy-newy)+"B"
ENDIF
newy = oldy
CLREOL
RETURN

;***********************************************************************

' This is a subroutine that redisplays the original prompt and then sets the
' color to the default for input.

:restoreline
PRINT nprompt
DEFCOLOR
RETURN

;***********************************************************************

' This is a subroutine that scans the screen buffer by using the SCRTEXT()
' function to find any valid filenames in the left most column of the screen.
' It validates filenames by checking to see if the filename is from 1 to 12
' characters in length, and that, if a period is in the filename, that it does
' not have an extension longer than 3 characters, if there is not a period,
' then the main part of the filename cannot be more than 8 characters, also,
' the filename cannot have a space, a comma, a colon, a backslash, an asterisk,
' or the greater than or less than (< and >) characters in it.
'
' This routine will keep moving up the screen until it finds a valid filename
' and, if one is not found, it will return with the filename variable empty.
'
' If a valid filename is found, it is stored in a variable called filename.
' At the same time, it reads the COLORS that are used to highlight the filename
' as well so that later, when we "unhighlight" the file, we can put it back
' the way it was found. Finally, it highlights the filename by printing the
' name with a black-on-white color attribute and returns.

:findfile
IF (newy = 1) THEN
filename = ""
RETURN
ENDIF

upcount = 0
WHILE (newy >= 1) DO
newy = newy - 1
upcount = upcount + 1

' first check for a valid file size to be sure that it is greater than zero
' (0 would indicate that it wasn't a valid file or that the file was marked
' as OFFLINE or DELETED)
filesize = TRIM(SCRTEXT(13,newy,11,FALSE), " ")
if (filesize > 0) THEN

' The file size is okay, let's check for a valid date. This is
' done by reading the filedate into a DATE variable which PPL will
' then convert to a julian value. If the date was valid, the julian
' value will be greater than zero. Using this method of checking
' the date will work no matter what language (and country code) the
' caller is using because PPL will automatically take care of the
' proper date separators when evaluating the date that is found.
filedate = SCRTEXT(24,newy,8,FALSE)
if (filedate > 0) THEN

filename = RTRIM(SCRTEXT(1,newy,13,FALSE)," ") ' pull the name of the screen
filelen = LEN(filename)

' check for a valid filename
IF (filelen >= 1 & filelen <= 12) THEN
IF (! (INSTR(filename," ") | INSTR(filename,",") | INSTR(filename,":") | INSTR(filename,"\") | INSTR(filename,"*") | INSTR(filename,"<") | INSTR(filename,">"))) THEN
dotpos = INSTR(filename,".")
IF ((dotpos = 0 & filelen <= 8) | ((filelen - dotpos) <= 3)) THEN

' the filename is valid, save the colors as well
savetext = SCRTEXT(1,newy,13,TRUE)

' move the cursor up where the filename is
PRINT ESC+"["+STRING(upcount)+"A"

' then highlight the filename and return
COLOR @X70
PRINT filename+CR
RETURN
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDWHILE

' no valid filename was found, return with an empty filename
filename = ""

' since no filename was found, the cursor did not really move up so we need
' to add upcount back into the newy variable.
newy = newy + upcount
RETURN

;***********************************************************************

' This is a subroutine that unhighlights the filename by printing the saved
' text, which includes color codes as well as the filename.

:unhighlight
PRINT savetext+CR
RETURN

;***********************************************************************


  3 Responses to “Category : BBS Programs+Doors
Archive   : FLAG22.ZIP
Filename : FLAG.PPS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/