home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_BAS / PRO98SRC.ZIP / PCBTYPE.BAS < prev    next >
BASIC Source File  |  1994-01-12  |  4KB  |  130 lines

  1. sub pcbtype (fi$,s$,response$)
  2. ' this subroutine types a PC-Board style file list to the screen and
  3. ' prompts the user to select one or more files.  the selected files are
  4. ' return in response$.  s$ contains the search parameters.  s$ can be
  5. ' blank for all files, or can be a "since" date, or can be a search
  6. ' string.  The format of the pcb can be pretty loose, but must contain
  7. ' a | in any line that is to be continued from the previous line, and
  8. ' must contain a standard 8 digit date parsed with dashes. somewhere in
  9. ' the first line of each entry.  I.E.:
  10.  
  11. 'PROZOL.ZIP     219242   01-09-94   This is the complete prozol package
  12. '                                 | without source, of course.  Written
  13. '                                 | by Erik Olson in PowerBASIC 3.0
  14. '
  15. ' the first two lines of the file are a header and are not scanned, only
  16. ' printed.  This routine will be expanded to allow "Mark" and other options
  17. s$=ucase$(s$)
  18.  
  19. ' if s$ is a date then copy it into to d$
  20.  
  21. if dir$(fi$)="" then exit sub
  22. FF=FREEFILE
  23. open fi$ for input as #ff
  24. if eof(ff) then close #ff:exit sub else line input #ff, h1$:prozoprint h1$+CrLf$
  25. if eof(ff) then close #ff:exit sub else line input #ff, h2$:prozoprint h2$+CrLf$
  26. if eof(ff) then close #ff:exit sub else line input #ff, a$
  27. nonstop=0 'if enabled, pausing is off
  28. ln=0 'number of lines that have displayed
  29. do until eof(ff)
  30.         lntmp=1
  31.         do    ' build an image of one entry, store next entry line 1 in b$
  32.                 if eof(ff) then exit do
  33.         line input #1,b$
  34.                 if left$(ltrim$(b$),1)="|" then
  35.                         replace "|" with " " in b$
  36.                     a$=a$+CrLf$+b$
  37.                     incr lntmp ' number of lines in this entry
  38.         else
  39.                     exit do
  40.                 end if
  41.         loop
  42. ' now a$ is an entry.  We must check to see if it meets our criteria
  43. ' if it does meet our criteria then ln=lntmp, lntmp=0 else ln=0
  44. if len(d$) then
  45.     ' check date
  46. else
  47.     if s$="" then
  48.             meets=%true
  49.                 ln=ln+lntmp
  50.                 lntmp=0
  51.     else
  52.     if instr(ucase$(a$),s$) then
  53.             meets=%true
  54.                 ln=ln+lntmp
  55.         else
  56.             meets=%false
  57.                 lntmp=0
  58.         end if
  59.     end if
  60.  
  61. end if
  62.  
  63. if meets then
  64.  
  65. if nostop=0 then
  66. ' if it won't scroll to far, display a$, otherwise askfile
  67.     if ln<20 then
  68.             prozoprint a$ + CrLf$
  69.                 lntmp=0
  70.     else
  71.         gosub askfile
  72.                 ln=0
  73.                 if quitnow% then exit do
  74.     end if
  75. end if
  76.  
  77. ' if nonstop=1 or if we didn't display it before, display it now
  78. if nonstop or lntmp>0 then
  79.     prozoprint a$+CrLf$
  80.         ln=lntmp ' carry forward line counter
  81.     lntmp=0
  82. end if
  83.  
  84. end if ' if meets
  85.  
  86. meets%=0
  87.  
  88. ' set a$ to b$ for next iteration.
  89. k$=ucase$(prozoinkey$):if k$=chr$(27) or k$="X" or k$="S" or k$="Q" then exit do
  90. if not eof(ff) then a$=b$: else if ln>0 then gosub askfile
  91. if quitnow% then exit do
  92. loop
  93. close #ff
  94. exit sub
  95.  
  96. askfile:
  97. if eof(ff) then
  98.  prozoprint "(End of List) .. Enter selection(s) or press [ENTER] --> "
  99.  k$=prozoinput$
  100. else
  101.  prozoprint "[S]top, [N]on-stop, [D]ownload, or [ENTER] for more --> "
  102.  k$=prozoinput$
  103. end if
  104. if GoFlag% then quitnow%=%true:return
  105. if k$="" then
  106.         if not eof(ff) then prozocls:prozoprint h1$+CrLf$:prozoprint h2$+CrLf$
  107.         return
  108. end if
  109. k$=ucase$(k$)
  110. if k$="S" or k$="Q" then quitnow%=%true:return
  111. if k$="N" then nonstop=%true:return
  112. if k$="D" then
  113.     prozoprint "Enter filename(s): "
  114.         response$=prozoinput$
  115.         if Goflag% then quitnow%=%true : return
  116.         if response$="" then return
  117.         response$=ucase$(response$)
  118.         quitnow%=%true
  119. else
  120.         if len(k$)>1 then
  121.                 response$=ucase$(k$)
  122.                 quitnow%=%true
  123.         else
  124.                 goto askfile
  125.         end if
  126. end if
  127.  
  128. return
  129. end sub
  130.