home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PWAULTP3.ZIP / PWAPRGMS.A02 / PWA95 / PWANK082.ZIP / FLAGV.PPS < prev    next >
Text File  |  1995-04-09  |  18KB  |  566 lines

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