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