home *** CD-ROM | disk | FTP | other *** search
/ Carsten's PPE Collection / Carstens_PPE_Collection_2007.zip / S / SCUMN10.ZIP / FLAG.PPS < prev    next >
Text File  |  1994-06-13  |  16KB  |  451 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 (READLINE ((READLINE (PPEPATH()+"FLAG.CFG",PCBNODE()))+"FNUKE."+STRING(PCBNODE()),1) <> U_NAME()) do
  147.             IF (EXIST(READLINE (PPEPATH()+"FLAG.CFG",PCBNODE()))+"FNUKE."+STRING(PCBNODE())) DELETE (READLINE (PPEPATH()+"FLAG.CFG",1))+"FNUKE."+STRING(PCBNODE())
  148.             FAPPEND 6,(READLINE (PPEPATH()+"FLAG.CFG",PCBNODE()))+"FNUKE."+STRING(PCBNODE()),O_RW,S_DN
  149.               FPUTLN 6,U_NAME()
  150.             FCLOSE 6
  151.           ENDIF
  152.           FAPPEND 6,(READLINE (PPEPATH()+"FLAG.CFG",PCBNODE()))+"FNUKE."+STRING(PCBNODE()),O_RW,S_DN
  153.             FPUTLN 6,filename
  154.           FCLOSE 6
  155.           PRINTLN "@X0FF@X07i@X08le Flagged for Nukeing! Don't forget to run NUKE@X07R@X0F!"
  156.           DELAY 25
  157.           NEWLINE
  158.           RESTSCRN
  159.         ENDIF                    '**** NUKE SUPPORT MODS ENDS HERE*****
  160.       ELSE
  161.         GOSUB restorecursor
  162.       ENDIF
  163.  
  164.       GOSUB displayprompt
  165.       CONTINUE
  166.     ELSEIF (key == BS | key == BS2) THEN
  167.  
  168.       ' If the caller pressed backspace or delete, then delete the character
  169.       ' to the left, and remove it from the input buffer.  Of course, if the
  170.       ' caller hasn't typed anything yet, or if the caller has already
  171.       ' backspaced everything out, signified by the len being 0 (meaning there
  172.       ' are 0 bytes in the buffer), then we'll just loop back around waiting
  173.       ' for more keystrokes
  174.  
  175.       IF (len > 0) THEN
  176.         PRINT BS+" "
  177.         len  = len - 1
  178.         text = LEFT(text,len)
  179.       ELSE
  180.         CONTINUE
  181.       ENDIF
  182.  
  183.     ELSEIF (key == CR) THEN
  184.  
  185.       ' If it's a carriage return then set the flag to exit
  186.       exitflag = TRUE
  187.  
  188.     ELSEIF (LEN(key) > 1 | key < " ") THEN
  189.  
  190.       ' Special keys, such as UP, DOWN, etc, return multi-letter values such
  191.       ' as "UP" and "DOWN" when the INKEY() function is called.  Since we just
  192.       ' want to ignore special characters, we'll use the CONTINUE statement to
  193.       ' jump back to the top of the loop
  194.       '
  195.       ' We also want to avoid displaying "control characters" so anything
  196.       ' less than a SPACE should also be skipped.
  197.  
  198.       CONTINUE
  199.  
  200.     ELSEIF ((len = 0) & ((key = "?") | (UPPER(key) = "H"))) THEN
  201.  
  202.       ' If the user typed "?" or "H" then we want to display a help file.
  203.       ' First we'll save the current screen, then display the help file, and
  204.       ' then restore the saved screen after the caller has read the help file.
  205.  
  206.       SAVESCRN
  207.       NEWLINE
  208.       DISPFILE PPEPATH()+"FLAGHLP",GRAPH+LANG
  209.       NEWLINE
  210.       WAIT
  211.       RESTSCRN
  212.       CONTINUE
  213.  
  214.     ELSEIF ((key >= " ") & (len < 80)) THEN
  215.  
  216.       ' Here we are just gathering up keystrokes and putting them into an
  217.       ' input buffer.  As long as the keystrokes are greater than or equal to
  218.       ' a SPACE we'll just add them in until a limit of 80 characters is
  219.       ' reached.  PCBoard won't let you type more than 80 characters at that
  220.       ' prompt anyway so we might as well keep the same limit.
  221.  
  222.       text = text + key
  223.       len  = len + 1
  224.  
  225.     ENDIF
  226.  
  227.     PRINT key    ' Print any keystrokes the caller types
  228.   ENDIF
  229.  
  230. :bottom
  231. ENDWHILE
  232.  
  233. ' If we've gotten this far, then the caller has pressed ENTER so we'll stuff
  234. ' whatever the caller has typed into PCBoard's input buffer and let PCBoard
  235. ' process the request.
  236. '
  237. ' But first, if the command begins with V then it may be a view files command.
  238. ' Verify that assumption by checking to see if the user typed "V" and pressed
  239. ' ENTER (check length equal to 1) or if the user typed "V filename" (check
  240. ' for length greater than or equal to 3 for "F f")
  241.  
  242. text = RTRIM(text," ")
  243.  
  244. IF (UPPER(LEFT(text,1)) = "V") THEN
  245.   IF (LEN(text) = 1) THEN
  246.     CLREOL
  247.     filename = ""
  248.     PROMPTSTR 240,filename,12,MASK_FILE(),FIELDLEN
  249.     filename = RTRIM(filename," ");
  250.     IF (LEN(filename) = 0) THEN
  251.       CLREOL
  252.       KBDSTUFF CR
  253.       END
  254.     ENDIF
  255.     NEWLINE
  256.  
  257.     ' the lines below could be used to specify a different "default extension"
  258.     ' for archive files in different conferences - uncomment and adapt as
  259.     ' necessary to suit your needs
  260.     '
  261.     ' IF (INSTR(filename,".") = 0) THEN
  262.     '   IF (CURCONF() = 30) THEN
  263.     '     filename = filename + ".ARJ"
  264.     '   ELSEIF (CURCONF() = 50) THEN
  265.     '     filename = filename + ".ZOO"
  266.     '   ENDIF
  267.     ' ENDIF
  268.  
  269.     text = "V "+filename
  270.     ' save the screen to PCBoard's memory so that the next invocation of
  271.     ' FLAG.PPE will restore the screen
  272.     SAVESCRN
  273.   ELSEIF (LEN(text) >= 3) THEN
  274.     ' save the screen to PCBoard's memory so that the next invocation of
  275.     ' FLAG.PPE will restore the screen
  276.     CLREOL
  277.  
  278.     ' the lines below could be used to specify a different "default extension"
  279.     ' for archive files in different conferences - uncomment and adapt as
  280.     ' necessary to suit your needs
  281.     '
  282.     ' IF (INSTR(filename,".") = 0) THEN
  283.     '   IF (CURCONF() = 30) THEN
  284.     '     text = text + ".ARJ"
  285.     '   ELSEIF (CURCONF() = 50) THEN
  286.     '     text = text + ".ZOO"
  287.     '   ENDIF
  288.     ' ENDIF
  289.  
  290.     SAVESCRN
  291.   ELSE
  292.     KBDSTUFF CR
  293.     END
  294.   ENDIF
  295. ENDIF
  296.  
  297. KBDSTUFF text+CR
  298. END
  299.  
  300.  
  301. ;***********************************************************************
  302. '
  303. ' This subroutine restores the cursor position.  It does this using an ANSI
  304. ' command that simply restores a previously saved cursor position.  In
  305. ' addition, we'll clear the line before returning.
  306.  
  307. :restorecursor
  308. PRINT ESC+"[u"
  309. CLREOL
  310. RETURN
  311.  
  312.  
  313. ;***********************************************************************
  314. '
  315. ' This is a subroutine that displays the new prompt and then sets the color to
  316. ' the default for input.
  317.  
  318. :displayprompt
  319. DISPFILE PPEPATH()+"FLAGNEW",LANG
  320. DEFCOLOR
  321. RETURN
  322.  
  323.  
  324. ;***********************************************************************
  325. '
  326. ' This is a subroutine that checks the filenames() array to locate the next
  327. ' file on screen.  If RIPscrip is used, then special commands (which are
  328. ' passed via a mouse-click from the caller's terminal, are used to identify
  329. ' which file is desired.
  330. '
  331. ' If a valid filename is found, it is stored in a variable called filename.
  332. ' Also, it calls another subroutine to highlight the filename on the screen.
  333.  
  334. :findfile
  335. IF (rip) THEN
  336.   newy = 0
  337.   key = ""
  338.   WHILE (newy = 0) DO
  339.     key = INKEY()      ' watch for the next character
  340.     newy = ASC(key)
  341.     IF (newy >= 129 & newy <= 151) THEN
  342.       newy = newy - 128
  343.       IF (filenames(newy) <> "") THEN
  344.         GOSUB highlight
  345.         filename = filenames(newy)
  346.         RETURN
  347.       ELSE
  348.         newy = 0
  349.       ENDIF
  350.     ENDIF
  351.   ENDWHILE
  352. ELSE
  353.   WHILE (newy < oldy) DO
  354.     newy = newy + 1
  355.     IF (filenames(newy) <> "") THEN
  356.       GOSUB highlight
  357.       filename = filenames(newy)
  358.       RETURN
  359.     ENDIF
  360.   ENDWHILE
  361. ENDIF
  362.  
  363. ' no valid filename was found, return with an empty filename
  364. filename = ""
  365. RETURN
  366.  
  367.  
  368. ;***********************************************************************
  369. '
  370. ' This is a subroutine that highlights the filename moving the cursor to the
  371. ' correct line and then changing the color to black on white and printing the
  372. ' filename.  Prior to highlighting the filename, it saves a color image of the
  373. ' filename so that, when it comes time to unhighlight the file, the image can
  374. ' be restored.
  375.  
  376. :highlight
  377. ' move the cursor back to where it started, at the bottom, and then move
  378. ' it up to the appropriate line on the screen.
  379. PRINT ESC+"[u"+ESC+"["+STRING(oldy-newy)+"A"
  380.  
  381. ' get the file image (text & attributes) for later restoration
  382. fileimage = SCRTEXT(1,newy,13,TRUE)
  383.  
  384. ' then highlight the filename and return
  385. COLOR @X70              ' Change the bloody color back @X07
  386. PRINT filenames(newy)+CR
  387. RETURN
  388.  
  389.  
  390. ;***********************************************************************
  391. '
  392. ' This is a subroutine that unhighlights the filename by printing the file
  393. ' image, which includes color codes as well as the filename.
  394.  
  395. :unhighlight
  396. PRINT fileimage+CR
  397. RETURN
  398.  
  399.  
  400. ;***********************************************************************
  401. '
  402. ' This subroutine scans the screen at startup to see and fills an array called
  403. ' filenames() with the names of all files found on screen.  If RIPscrip is in
  404. ' use, it will also send out RIPscrip commands to define the location of the
  405. ' filenames on screen so that the caller can use a mouse to point and click.
  406.  
  407. :scanforfiles
  408. IF (GRAFMODE() = "R") THEN
  409.   rip = TRUE
  410. ENDIF
  411.  
  412. ' NOTE:  This loop is unnecessary because PPL automatically initializes
  413. '        all array elements to 0 or blank
  414. '
  415. ' FOR newy=1 TO 23
  416. '   filenames(newy) = ""   ' initialize the array elements
  417. ' NEXT
  418.  
  419. newy = 1
  420. WHILE (newy > 0) DO
  421.   ' get a filename off the screen ... if a filename is found, the filename
  422.   ' variable will be updated, if no more filenames are found, newy will be
  423.   ' set to 0.
  424.   SCRFILE newy, filename
  425.  
  426.   IF (newy <> 0) THEN
  427.     ' store the filename that was found into an array
  428.     filenames(newy) = filename
  429.  
  430.     ' If in RIPscrip mode, define the mouse region where the filename is
  431.     ' located.  The coordinates are defined in X,Y coordinates of 0,newy and
  432.     ' 13,newy+1.  The X coordinate (0 to 13) defines the length of the name.
  433.     ' The Y coordinate (newy to newy+1) defines the height of the name.
  434.     ' An 8x8 font is assumed.  The CHR(newy+128) is a "command" that we will
  435.     ' be using to communicate back to FLAG.PPE the position of the file being
  436.     ' selected via mouse click.
  437.     IF (rip) THEN
  438.       MOUSEREG 0,1,newy,13,newy+1,8,8,TRUE,FALSE," "+CHR(newy+128)
  439.     ENDIF
  440.     INC newy
  441.   ENDIF
  442. ENDWHILE
  443.  
  444. ' finish up the mouse region definitions
  445. IF (rip) THEN
  446.   MPRINT "!|#|#|#"+CR+chr(10)
  447. ENDIF
  448. RETURN
  449.  
  450. ;***********************************************************************
  451.