home *** CD-ROM | disk | FTP | other *** search
/ Carsten's PPE Collection / Carstens_PPE_Collection_2007.zip / T / THTNK1B4.ZIP / FLAG.PPS < prev    next >
Text File  |  1994-07-16  |  15KB  |  447 lines

  1. ;******************************************************************************
  2. ;  FLAG.PPE version 3.0 released on 12/18/93 by David W. Terry
  3. ;
  4. ; FLAG.PPE is a replacement for PCBoard's internal "more?" prompt, gives
  5. ; PCBoard v15.1 the easiest-to-use system for flagging and viewing files of
  6. ; any BBS around.  It gives callers the ability to point and shoot when
  7. ; flagging or viewing files.
  8. ;
  9. ; NOTE:  Please DO NOT DISTRIBUTE modified source code without prior permission
  10. ; or without meeting the requirements set forth in FLAG.DOC.
  11. ;******************************************************************************
  12.  
  13. ' check to see if caller has ANSI capabilities and, if not, display the old
  14. ' prompt and exit - let PCBoard handle the input.
  15.  
  16. ;***********************************************************************
  17.  
  18. IF (! ANSION()) THEN
  19.   DISPFILE PPEPATH()+"FLAGOLD",LANG
  20.   END
  21. ENDIF
  22.  
  23. BOOLEAN exitflag       ' Flag to determine when we should exit
  24. BOOLEAN rip            ' Flag to indicate RIPscrip is in use
  25.  
  26. STRING  text           ' The text that the caller types
  27. STRING  key            ' Keystroke text
  28.  
  29. STRING  BS             ' An ASCII backspace character
  30. STRING  BS2            ' An ASCII backspace character
  31. STRING  CR             ' An ASCII carriage return character
  32. STRING  ESC            ' An ASCII esc character
  33.  
  34. BYTE    len            ' Length of the text the caller has typed
  35. BYTE    oldy           ' Last row position of cursor
  36. BYTE    newy           ' New row position of cursor
  37.  
  38. STRING  filenames(23)  ' The names of the files found on the screen
  39. STRING  filename       ' The name of the file that is being processed
  40. STRING  fileimage      ' Includes the color codes for restoration of text
  41.  
  42. ;***********************************************************************
  43.  
  44. ; Initializations
  45.  
  46. BS     = CHR(8)   ' Backspace Key
  47. BS2    = CHR(127) ' Alternate Backspace Key
  48. CR     = CHR(13)  ' Carriage Return
  49. ESC    = CHR(27)  ' ESC character
  50. len    = 0        ' Initialize to 0 bytes in the input buffer
  51. text   = ""       ' Initialize to an empty input buffer
  52.  
  53. ;***********************************************************************
  54.  
  55. ; Main Program
  56.  
  57.                              ' in case the last invocation of flag.ppe saved
  58. RESTSCRN                     ' the screen, restore it now
  59.  
  60. CLREOL                       ' clear the line for input
  61. GOSUB displayprompt          ' display the new prompt
  62. GOSUB scanforfiles           ' build filenames array
  63.  
  64. ' While the user hasn't exited, get keystrokes and act on them.
  65. ' Exiting will occur when the caller presses ENTER.
  66.  
  67. WHILE (!exitflag) DO
  68.  
  69.   key = INKEY()  ' Get a keypress from the user
  70.  
  71.   if (key <> "") THEN  ' If the user pressed a key, then let's process it
  72.  
  73.     ' If it is the FIRST keystroke, signified by the buffer having 0 bytes
  74.     ' in it, then check to see if it is a SPACE.  If so, then we'll go into
  75.     ' MARK mode.  If not, then we'll process the keystrokes the same way that
  76.     ' PCBoard would .. gathering them up into a buffer.  Once the ENTER key
  77.     ' is pressed, we'll exit out and stuff PCBoard's keyboard buffer with the
  78.     ' keystrokes that were collected.
  79.  
  80.     IF (len = 0 & key = " ") THEN
  81.       oldy = GETY()
  82.       newy = 0
  83.  
  84.       PRINT CR
  85.       CLREOL
  86.       PRINT ESC+"[s"  ' save the current cursor position
  87.  
  88.       ' Let the caller know what he can do while in MARK mode
  89.       DISPFILE PPEPATH()+"FLAGBAR",GRAPH+LANG
  90.  
  91.       ' Move the cursor back to the first column
  92.       PRINT CR
  93.  
  94.       ' Find the first filename on the screen.
  95.       GOSUB findfile
  96.  
  97.       ' If a filename was found, then findfile highlighted it.  Now wait for
  98.       ' another keystroke to see if the user whats to mark this one, or move
  99.       ' on to another one, or exit out.  Marking is done by pressing ENTER,
  100.       ' moving to another file is done by pressing SPACE, viewing the file is
  101.       ' done by pressing "V", and exiting is done by pressing ESC.
  102.  
  103.       IF (filename <> "") THEN          '***** ADD the MOD BELOW for NUKEING ***'
  104.         WHILE (key != ESC & key != CR & UPPER(key) != "V" & UPPER(key) !="N" ) DO
  105.           key = INKEY()
  106.  
  107.           ' If the key pressed was a SPACE then the user has decided to skip
  108.           ' over that file.  So unhighlight it, then try to find another
  109.           ' file.  If a file is found, we'll stay in this loop.  If one is
  110.           ' not found, then we'll restore the original prompt and go back to
  111.           ' waiting for keystrokes in case the caller wants to start over
  112.           ' (marking files) or wants to manually (F)lag them instead.
  113.  
  114.           IF (key = " ") THEN
  115.             GOSUB unhighlight
  116.             GOSUB findfile
  117.             IF (filename = "") THEN
  118.               GOSUB restorecursor
  119.               GOSUB displayprompt
  120.               GOTO  bottom
  121.             ENDIF
  122.           ENDIF
  123.         ENDWHILE
  124.  
  125.         ' If we've gotten this far, then ESC, CR or V was pressed.  We'll
  126.         ' unhighlight the file, restore the prompt and then, if CR was pressed,
  127.         ' meaning the user wished to MARK that file, then will stuff PCBoard's
  128.         ' keyboard buffer with a FLAG command and the name of the file to flag.
  129.         ' If V was pressed, then we'll instead stuff the buffer with a command
  130.         ' to VIEW the file.
  131.  
  132.         GOSUB unhighlight
  133.         GOSUB restorecursor
  134.  
  135.         IF (key = CR) THEN
  136.           KBDSTUFF "F "+filename+CR
  137.           END
  138.         ELSEIF (UPPER(key) = "V") THEN
  139.           ' save the screen into PCBoard's memory so that we can restore it
  140.           ' when FLAG.PPE is called up again, then issue the view command
  141.           ' SAVESCRN                 '******* HERE AND BELOW FOR NUKE SUPPORT***
  142.           KBDSTUFF "V "+filename+CR
  143.         ELSEIF (UPPER(key) = "N") THEN
  144.           SAVESCRN
  145.           GETUSER
  146.           if ( cursec() => sysopsec()) then
  147.           FAPPEND 6,"FNUKE."+STRING(PCBNODE()),O_RW,S_DN
  148.             FPUTLN 6,filename+" "+string(curconf())
  149.           FCLOSE 6
  150.           PRINTLN "@X0FFile Flagged for Nukeing! or Credit Don't forget to run NUKE@X0F!"
  151.           DELAY 15
  152.           NEWLINE
  153.           RESTSCRN
  154.         ENDIF
  155.         ENDIF                    '**** NUKE SUPPORT MODS ENDS HERE*****
  156.       ELSE
  157.         GOSUB restorecursor
  158.       ENDIF
  159.  
  160.       GOSUB displayprompt
  161.       CONTINUE
  162.     ELSEIF (key == BS | key == BS2) THEN
  163.  
  164.       ' If the caller pressed backspace or delete, then delete the character
  165.       ' to the left, and remove it from the input buffer.  Of course, if the
  166.       ' caller hasn't typed anything yet, or if the caller has already
  167.       ' backspaced everything out, signified by the len being 0 (meaning there
  168.       ' are 0 bytes in the buffer), then we'll just loop back around waiting
  169.       ' for more keystrokes
  170.  
  171.       IF (len > 0) THEN
  172.         PRINT BS+" "
  173.         len  = len - 1
  174.         text = LEFT(text,len)
  175.       ELSE
  176.         CONTINUE
  177.       ENDIF
  178.  
  179.     ELSEIF (key == CR) THEN
  180.  
  181.       ' If it's a carriage return then set the flag to exit
  182.       exitflag = TRUE
  183.  
  184.     ELSEIF (LEN(key) > 1 | key < " ") THEN
  185.  
  186.       ' Special keys, such as UP, DOWN, etc, return multi-letter values such
  187.       ' as "UP" and "DOWN" when the INKEY() function is called.  Since we just
  188.       ' want to ignore special characters, we'll use the CONTINUE statement to
  189.       ' jump back to the top of the loop
  190.       '
  191.       ' We also want to avoid displaying "control characters" so anything
  192.       ' less than a SPACE should also be skipped.
  193.  
  194.       CONTINUE
  195.  
  196.     ELSEIF ((len = 0) & ((key = "?") | (UPPER(key) = "H"))) THEN
  197.  
  198.       ' If the user typed "?" or "H" then we want to display a help file.
  199.       ' First we'll save the current screen, then display the help file, and
  200.       ' then restore the saved screen after the caller has read the help file.
  201.  
  202.       SAVESCRN
  203.       NEWLINE
  204.       DISPFILE PPEPATH()+"FLAGHLP",GRAPH+LANG
  205.       NEWLINE
  206.       WAIT
  207.       RESTSCRN
  208.       CONTINUE
  209.  
  210.     ELSEIF ((key >= " ") & (len < 80)) THEN
  211.  
  212.       ' Here we are just gathering up keystrokes and putting them into an
  213.       ' input buffer.  As long as the keystrokes are greater than or equal to
  214.       ' a SPACE we'll just add them in until a limit of 80 characters is
  215.       ' reached.  PCBoard won't let you type more than 80 characters at that
  216.       ' prompt anyway so we might as well keep the same limit.
  217.  
  218.       text = text + key
  219.       len  = len + 1
  220.  
  221.     ENDIF
  222.  
  223.     PRINT key    ' Print any keystrokes the caller types
  224.   ENDIF
  225.  
  226. :bottom
  227. ENDWHILE
  228.  
  229. ' If we've gotten this far, then the caller has pressed ENTER so we'll stuff
  230. ' whatever the caller has typed into PCBoard's input buffer and let PCBoard
  231. ' process the request.
  232. '
  233. ' But first, if the command begins with V then it may be a view files command.
  234. ' Verify that assumption by checking to see if the user typed "V" and pressed
  235. ' ENTER (check length equal to 1) or if the user typed "V filename" (check
  236. ' for length greater than or equal to 3 for "F f")
  237.  
  238. text = RTRIM(text," ")
  239.  
  240. IF (UPPER(LEFT(text,1)) = "V") THEN
  241.   IF (LEN(text) = 1) THEN
  242.     CLREOL
  243.     filename = ""
  244.     PROMPTSTR 240,filename,12,MASK_FILE(),FIELDLEN
  245.     filename = RTRIM(filename," ");
  246.     IF (LEN(filename) = 0) THEN
  247.       CLREOL
  248.       KBDSTUFF CR
  249.       END
  250.     ENDIF
  251.     NEWLINE
  252.  
  253.     ' the lines below could be used to specify a different "default extension"
  254.     ' for archive files in different conferences - uncomment and adapt as
  255.     ' necessary to suit your needs
  256.     '
  257.     ' IF (INSTR(filename,".") = 0) THEN
  258.     '   IF (CURCONF() = 30) THEN
  259.     '     filename = filename + ".ARJ"
  260.     '   ELSEIF (CURCONF() = 50) THEN
  261.     '     filename = filename + ".ZOO"
  262.     '   ENDIF
  263.     ' ENDIF
  264.  
  265.     text = "V "+filename
  266.     ' save the screen to PCBoard's memory so that the next invocation of
  267.     ' FLAG.PPE will restore the screen
  268.     SAVESCRN
  269.   ELSEIF (LEN(text) >= 3) THEN
  270.     ' save the screen to PCBoard's memory so that the next invocation of
  271.     ' FLAG.PPE will restore the screen
  272.     CLREOL
  273.  
  274.     ' the lines below could be used to specify a different "default extension"
  275.     ' for archive files in different conferences - uncomment and adapt as
  276.     ' necessary to suit your needs
  277.     '
  278.     ' IF (INSTR(filename,".") = 0) THEN
  279.     '   IF (CURCONF() = 30) THEN
  280.     '     text = text + ".ARJ"
  281.     '   ELSEIF (CURCONF() = 50) THEN
  282.     '     text = text + ".ZOO"
  283.     '   ENDIF
  284.     ' ENDIF
  285.  
  286.     SAVESCRN
  287.   ELSE
  288.     KBDSTUFF CR
  289.     END
  290.   ENDIF
  291. ENDIF
  292.  
  293. KBDSTUFF text+CR
  294. END
  295.  
  296.  
  297. ;***********************************************************************
  298. '
  299. ' This subroutine restores the cursor position.  It does this using an ANSI
  300. ' command that simply restores a previously saved cursor position.  In
  301. ' addition, we'll clear the line before returning.
  302.  
  303. :restorecursor
  304. PRINT ESC+"[u"
  305. CLREOL
  306. RETURN
  307.  
  308.  
  309. ;***********************************************************************
  310. '
  311. ' This is a subroutine that displays the new prompt and then sets the color to
  312. ' the default for input.
  313.  
  314. :displayprompt
  315. DISPFILE PPEPATH()+"FLAGNEW",LANG
  316. DEFCOLOR
  317. RETURN
  318.  
  319.  
  320. ;***********************************************************************
  321. '
  322. ' This is a subroutine that checks the filenames() array to locate the next
  323. ' file on screen.  If RIPscrip is used, then special commands (which are
  324. ' passed via a mouse-click from the caller's terminal, are used to identify
  325. ' which file is desired.
  326. '
  327. ' If a valid filename is found, it is stored in a variable called filename.
  328. ' Also, it calls another subroutine to highlight the filename on the screen.
  329.  
  330. :findfile
  331. IF (rip) THEN
  332.   newy = 0
  333.   key = ""
  334.   WHILE (newy = 0) DO
  335.     key = INKEY()      ' watch for the next character
  336.     newy = ASC(key)
  337.     IF (newy >= 129 & newy <= 151) THEN
  338.       newy = newy - 128
  339.       IF (filenames(newy) <> "") THEN
  340.         GOSUB highlight
  341.         filename = filenames(newy)
  342.         RETURN
  343.       ELSE
  344.         newy = 0
  345.       ENDIF
  346.     ENDIF
  347.   ENDWHILE
  348. ELSE
  349.   WHILE (newy < oldy) DO
  350.     newy = newy + 1
  351.     IF (filenames(newy) <> "") THEN
  352.       GOSUB highlight
  353.       filename = filenames(newy)
  354.       RETURN
  355.     ENDIF
  356.   ENDWHILE
  357. ENDIF
  358.  
  359. ' no valid filename was found, return with an empty filename
  360. filename = ""
  361. RETURN
  362.  
  363.  
  364. ;***********************************************************************
  365. '
  366. ' This is a subroutine that highlights the filename moving the cursor to the
  367. ' correct line and then changing the color to black on white and printing the
  368. ' filename.  Prior to highlighting the filename, it saves a color image of the
  369. ' filename so that, when it comes time to unhighlight the file, the image can
  370. ' be restored.
  371.  
  372. :highlight
  373. ' move the cursor back to where it started, at the bottom, and then move
  374. ' it up to the appropriate line on the screen.
  375. PRINT ESC+"[u"+ESC+"["+STRING(oldy-newy)+"A"
  376.  
  377. ' get the file image (text & attributes) for later restoration
  378. fileimage = SCRTEXT(1,newy,13,TRUE)
  379.  
  380. ' then highlight the filename and return
  381. COLOR @X70              ' Change the bloody color back @X07
  382. PRINT filenames(newy)+CR
  383. RETURN
  384.  
  385.  
  386. ;***********************************************************************
  387. '
  388. ' This is a subroutine that unhighlights the filename by printing the file
  389. ' image, which includes color codes as well as the filename.
  390.  
  391. :unhighlight
  392. PRINT fileimage+CR
  393. RETURN
  394.  
  395.  
  396. ;***********************************************************************
  397. '
  398. ' This subroutine scans the screen at startup to see and fills an array called
  399. ' filenames() with the names of all files found on screen.  If RIPscrip is in
  400. ' use, it will also send out RIPscrip commands to define the location of the
  401. ' filenames on screen so that the caller can use a mouse to point and click.
  402.  
  403. :scanforfiles
  404. IF (GRAFMODE() = "R") THEN
  405.   rip = TRUE
  406. ENDIF
  407.  
  408. ' NOTE:  This loop is unnecessary because PPL automatically initializes
  409. '        all array elements to 0 or blank
  410. '
  411. ' FOR newy=1 TO 23
  412. '   filenames(newy) = ""   ' initialize the array elements
  413. ' NEXT
  414.  
  415. newy = 1
  416. WHILE (newy > 0) DO
  417.   ' get a filename off the screen ... if a filename is found, the filename
  418.   ' variable will be updated, if no more filenames are found, newy will be
  419.   ' set to 0.
  420.   SCRFILE newy, filename
  421.  
  422.   IF (newy <> 0) THEN
  423.     ' store the filename that was found into an array
  424.     filenames(newy) = filename
  425.  
  426.     ' If in RIPscrip mode, define the mouse region where the filename is
  427.     ' located.  The coordinates are defined in X,Y coordinates of 0,newy and
  428.     ' 13,newy+1.  The X coordinate (0 to 13) defines the length of the name.
  429.     ' The Y coordinate (newy to newy+1) defines the height of the name.
  430.     ' An 8x8 font is assumed.  The CHR(newy+128) is a "command" that we will
  431.     ' be using to communicate back to FLAG.PPE the position of the file being
  432.     ' selected via mouse click.
  433.     IF (rip) THEN
  434.       MOUSEREG 0,1,newy,13,newy+1,8,8,TRUE,FALSE," "+CHR(newy+128)
  435.     ENDIF
  436.     INC newy
  437.   ENDIF
  438. ENDWHILE
  439.  
  440. ' finish up the mouse region definitions
  441. IF (rip) THEN
  442.   MPRINT "!|#|#|#"+CR+chr(10)
  443. ENDIF
  444. RETURN
  445.  
  446. ;***********************************************************************
  447.