Hey as long as we're sharing code, here's something I wrote in PICK that
does "AND" logic searching.  So you can find all the lines with, for
example, WRITE and AR.REC on the same line.

Many times I find myself having to search through code for things like
INVOICE and what I'm really looking may be where another program might be
calling the INVOICE program, but end up with a million hits of the literal
'INVOICE' being printed, etc., and this way I can tailor the search to look
for PERFORM and INVOICE on the same line and bingo, I get just what I need!

To convert this to Unidata would require the INDEX command to be changed to
FINDSTR, POINTER-FILE to SAVEDLISTS, and modify the ID for the list to have
000 (three zeros) appended to the end.  Oh, and the LOCATE is a tad
different as well.....

(I used the name MULTISCAN because I liked the movie 'The Fifth Element' and
it just cracks me up to hear Multipass.  Guess you had to be there.... ;-)

Allen
www.tortillafc.com

  * MULTISCAN - Find records based on AND logic
  *
  LINES.PER.PAGE = 57
  LIST.NAME = ""
  LIST.LIST = ""
  PRINT 'Use ITEM1~ITEM2 type of entry for boolean AND search'
  PRINT 'This will also search for exact names if that option is selected'
  PRINT "Enter file name : ":;INPUT FILENAME
  PRINT 'Look for : ':;INPUT LOOK.FOR
  PRINT 'Enter List Name: ':;INPUT LIST.NAME
  PRINT 'Exact name match? (Y/N) : ':;INPUT EXACT.MATCH
  OPEN '', FILENAME       TO FHAND ELSE PRINT FILENAME:' not found'   ;STOP
  OPEN '', 'POINTER-FILE' TO PF    ELSE PRINT 'POINTER-FILE not found';STOP
  MSG = 'SELECT ':FILENAME
  EXECUTE MSG
  LOOK.FOR  = CHANGE(LOOK.FOR,'~',@AM)
  ANDY.COUNT = DCOUNT(LOOK.FOR,@AM)
  *  SELECTED = @SYSTEM.RETURN.CODE
  *  CALL PRINTER.ON("","")
  LOOP
    READNEXT ID ELSE EXIT
    READ REC FROM FHAND, ID THEN
      LNS = DCOUNT(REC,@AM)
      ADD.IT = 0
      FOR I = 1 TO LNS
        DATA.LINE = REC<1>
        DEL REC<1>
        IF EXACT.MATCH = 'Y' THEN
          EXACT.LINE = CHANGE(DATA.LINE,' ',@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,"'",@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,',',@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,'"',@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,'(',@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,')',@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,'=',@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,'+',@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,'-',@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,'/',@AM)
          EXACT.LINE = CHANGE(EXACT.LINE,'*',@AM)
        END
        FOUND.COUNT = 0
        FOR J = 1 TO ANDY.COUNT
          POS = 0
          SEARCH.VALUE = LOOK.FOR<J>
          POS = INDEX(DATA.LINE,SEARCH.VALUE,1)
          IF POS THEN
            IF EXACT.MATCH = 'Y' THEN
              LOCATE SEARCH.VALUE IN EXACT.LINE SETTING GOT.IT ELSE GOT.IT =
0
              IF GOT.IT THEN
                FOUND.COUNT+=1
              END
            END ELSE
              FOUND.COUNT+=1
            END
          END
          IF FOUND.COUNT = ANDY.COUNT THEN
            PRINT ID
            PRINT 'Line: ':I:' ':DATA.LINE
            PRINT
            ADD.IT = 1
          END
        NEXT J
      NEXT I
      IF LIST.NAME > "" THEN
        IF ADD.IT THEN
          LIST.LIST<-1> = ID
        END
      END
    END
  REPEAT
  *  CALL PRINTER.OFF("","")
  *  CALL PRINTER.CLOSE("","")
  PRINT 'DONE'
  IF LIST.NAME > "" THEN
    IF LIST.LIST > "" THEN
      WRITEU LIST.LIST ON PF, LIST.NAME
    END
  END
  STOP
  END

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Friday, September 09, 2005 13:15
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Is there a UniData equivalent to the UV SEARCH
command?


I wrote a program for searching through any file. It should work on both
U2 DBs, though I'm not a whiz at UD and don't have a UD system available
for testing, but I've pasted the source below my sig.

--
Karl Pearson
IT Director, ATS Industrial Supply, Inc.
http://www.atsindustrial.com
Toll-free: 800-789-9300 x29
Direct2Desk: 801-978-4429
Facsimile: 801-972-3888
--
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to