Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

poffs, a report to display(log) lines with a matched string in a thread posted

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • poffs, a report to display(log) lines with a matched string in a thread posted

    this is not the poffs program/database for anybody interested in that
    i was just trying to use a short title for this thread.
    this program can search poffs database files and the poffs program is but much faster.
    this program only places those lines containing the searched string close for viewing purposes

    i had to wright this program for myself
    i wanted to know how keywords where being used in code and in a fast manner.
    when using various functions that are in windows dll files that come with the os,
    the functions can have a lot of different parameters where one or more are used, and that is where this program has helped me.

    i choose to search the lines from all poffs database files, poffs being such a great source of information.
    then i use poffs to see the details, there by saving myself a lot of time on how to use certain function, statements, etc.
    the program will do its best to combine lines that are continued, leaving comments in places, it is far from perfect, it is a simple tool, and because there seems to be no newer poffs updates in the immediate future, i will stop coding this project at this point.

    the exe is at my temporay website
    this was a quick and dirty program
    the program could be use to search you powerbasic source files or any text files for that matter.
    the files searched can have lines ended with a linefeed or carriagereturn+linefeed

    Code:
    'poffstxt.bas
    'pbcc 4.04
    'poffs text search
    'results can be redirected to file which is the best way imho
    '
    
    #COMPILE EXE
    '#DIM ALL
    GLOBAL gstexttofind AS STRING
    GLOBAL gshowtitles AS LONG
    
    
    FUNCTION readfilereadlines(BYVAL sfile AS STRING) AS LONG
    STATIC slastfilename AS STRING
    LOCAL afiletext() AS STRING
    LOCAL displaytitles  AS LONG
    LOCAL poffsfile AS LONG
    displaytitles=gshowtitles
    poffsfile=1&
    OPEN sfile FOR BINARY ACCESS READ WRITE LOCK SHARED AS #1
    PRINT "reading file "+sfile
    REDIM afiletext(0& TO 0&)
    TEMP&=LOF(1)
    A$=SPACE$(TEMP&)
    GET #1,1&,A$
    CLOSE 1
    IF temp&>9 THEN IF LEFT$(A$,9)<>"'MESSAGE " THEN displaytitles=0&:poffsfile=0&
    REPLACE $CRLF WITH $LF IN A$
    numberoflines&=PARSECOUNT(a$,$LF)
    REDIM afiletext(1& TO numberoflines&)
    PARSE a$,afiletext(),$LF
    
    a$=""
    b$=""
    
    
    FOR i&=1& TO numberoflines&
    A$=afiletext(i&)
    IF displaytitles THEN
      IF LEFT$(a$,1)="'" THEN
        IF LEFT$(A$,9&)="'MESSAGE " THEN  LASTMESSAGE$=MESSAGE$:MESSAGE$=RIGHT$(A$,LEN(A$)-9):messageplus$="":ITERATE FOR
        IF LEFT$(A$,8&)="'FORUM: " THEN   messageplus$=afiletext(i&):ITERATE FOR
        IF LEFT$(A$,8&)="'TOPIC: " THEN   messageplus$=messageplus$+" "+afiletext(i&):ITERATE FOR
        IF LEFT$(A$,7&)="'NAME: " THEN    messageplus$=messageplus$+" "+afiletext(i&):ITERATE FOR
        IF LEFT$(A$,7&)="'DATE: " THEN    messageplus$=messageplus$+" "+afiletext(i&):ITERATE FOR
      END IF
    END IF
    A$=" "+A$+" "
    IF TALLY(A$,"_") THEN
      TEMP$=UCASE$(A$)
      REPLACE " " WITH "" IN TEMP$
      TEMP$=TRIM$(TEMP$)
      IF TALLY(TEMP$,"_'") THEN B$=B$+$CRLF+A$:ITERATE FOR
      IF RIGHT$(TEMP$,1)="_" THEN B$=B$+$CRLF+A$:ITERATE FOR
    END IF
    
    IF  LEN(B$)>0& THEN
        temp$=UCASE$(B$+A$)
        REPLACE "  " WITH " " IN TEMP$
        TEMP&=TALLY(TEMP$,UCASE$(gstexttofind))
        ELSE
        temp$=UCASE$(A$)
        REPLACE "  " WITH " " IN TEMP$
        TEMP&=TALLY(TEMP$,UCASE$(gstexttofind))
    END IF
    
    IF TEMP& THEN
      IF slastfilename<>sfile THEN
           STDOUT
           STDOUT
           STDOUT REPEAT$(LEN("FILENAME="+SFILE),"=")
           STDOUT  "filename="+sfile
           STDOUT REPEAT$(LEN("FILENAME="+SFILE),"=")
      END IF
      slastfilename=sfile
      IF displaytitles THEN
         IF MESSAGE$<>LASTMESSAGE$ THEN
           LASTMESSAGE$=MESSAGE$
           STDOUT
           REPLACE "'" WITH "" IN MESSAGEPLUS$
           REPLACE "  " WITH " " IN MESSAGEPLUS$
           STDOUT REPEAT$(LEN(MESSAGEPLUS$),"_")
           STDOUT MESSAGE$
           STDOUT MESSAGEPLUS$
           STDOUT REPEAT$(LEN(MESSAGEPLUS$),"_")
         END IF
      ELSE
       IF poffsfile THEN  STDOUT:STDOUT REPEAT$(79*2,"_")
      END IF
    
    
    
      IF LEN(B$)>0& THEN
          STDOUT USING$("&","line: "+B$+$CRLF+A$)
       ELSE
          STDOUT USING$("&","line: "+A$)
      END IF
    END IF
    
    B$=""
    NEXT I&
    CLOSE
    REDIM afiletext(0& TO 0&)
    END FUNCTION
    
    
    
    FUNCTION PBMAIN () AS LONG
    commandline$=" "+UCASE$(TRIM$(COMMAND$))+" "
    gshowtitles=0&
    IF TALLY(COMMANDLINE$," SHOWTITLES ") THEN
        gshowtitles=1&:REPLACE " SHOWTITLES " WITH " " IN COMMANDLINE$
        END IF
    COMMANDLINE$=TRIM$(COMMANDLINE$)
    IF LEN(COMMANDLINE$)=0& THEN
          PRINT     "progam can search any file(s), but was written for poffs dat files"
          PRINT     "place the filename or wildcard of files on the command line"
          PRINT     "output can be redirected using > or >> with a filename afterwards"
          PRINT     "put SHOWTITLES on command line to print the thread headers for poffs files"
          GOTO finished
          END IF
    
    PRINT "files to search "+commandline$
    LINE INPUT "search for =",gstexttofind
    temp$=TRIM$(gstexttofind)
    IF LEN(temp$)=0& THEN GOTO finished
    REPLACE "  " WITH " " IN gstexttofind
    TEMP$=gstexttofind
    REPLACE " " WITH "[space]" IN TEMP$
    
    PRINT  commandline$+" files searched for = "+temp$
    STDOUT commandline$+" files searched for = "+temp$
    sfilename$=DIR$(commandline$)
    again:
    CLOSE
    IF sfilename$="" THEN GOTO finished
    readfilereadlines(sfilename$)
    sfilename$=DIR$
    GOTO again
    finished:
    END FUNCTION
    Last edited by Paul Purvis; 3 Apr 2008, 04:30 PM.
    p purvis

  • #2
    improved program
    better reporting of lines
    faster search
    more compatible with *.bas files
    replaced double or more spaces in words searched for and lines being searched down to one space, easier to search and located matches.
    easier to see where lines are continued with the _ character
    better display of results when the file being searched is not a poffs database file.
    updated exe and bas is on my website
    Last edited by Paul Purvis; 3 Apr 2008, 04:42 PM.
    p purvis

    Comment

    Working...
    X