Index problems

Bob Stockler bob at trebor.iglou.com
Wed Aug 11 13:05:11 PDT 2004


On Wed, Aug 11, 2004 at 01:18:54PM -0400, Tim Fischer wrote:
[snip]
| I know what you mean - I have seen that before.  Again, I have 20,000
| records with 499 fields each.  There's really no way I can go through each
| of those 9,980,000 fields to check for corruption.  
| 
| Does anyone have a way to automate checking for this type of issue?

Yes . . . if one has GAWK and the KornShell.

About eight years or so ago I wrote a shell script I called
"eureka" (because I'd finally found a simple way to read
filePro key files and use regular expressions to search them).

EUREKA promts for a filePro File name, then writes a KornShell
script and GAWK program in that file's directory.  On executing
the script, the GAWK program reads through the key file in record
number order.

By default the GAWK program performs these sample operations:

  # Samples:

    # point out saved empty records:
    if ( $0 ~ /^ +$/ ) print "Record Number:", RN, "- Saved, but empty."

    # skip saved empty records:
    if ( $0 ~ /^ +$/ ) next

    # print the filePro Record Number & the first 60 characters of the record:
    printf( "%5d - %-60.60s\n", RN, $0 )

But it could be edited, for example, to count the number of
records in one or more ZIP Codes by inserting this code just
below the "# Samples:" line:

    if ( ZIP == 40220 ) array[40220] += 1
    # else if ( ZIP == 40222 ) array[40222] += 1
    next

and inserting this code at the top of the action matching the
END pattern:

    print "ZIP Code 40220 total:", array[40220]
    # print "ZIP Code 40222 total:", array[40222]
    exit

Note that fields may be addressed by their field number or by
their name in the map file (suitably massaged to be acceptable
variable names).

The problem at hand could be addressed by:

    if ( $0 ~ /[^\001 -~]/ ) print "Non ASCII character in record #", RN
or:
    if ( $0 ~ /[^\001 -~]/ ) {
      for ( Field = 1; Field <= NF; Field++ ) {
        if ( $Field ~ /[^\001 -~]/ )
          printf "Non ASCII char in field %d, record %d\n", Field, RN
      }
    }

I'll email it as a gzipped attachment to anyone who might be
interested in playing with it.

Bob

PS - If one is on SCO UNIX it can also read the filePro info
     in @cd, @cb, @bd, @ub and @ud.  This requires a compiled
     program.  I do have the source code for it, though.  Let
     know if you'd also like either or both of these.

-- 
Bob Stockler - bob at trebor.iglou.com
Author: MENU EDIT II - The BEST Creator/Editor/Manager for filePro User Menus.
Fully functional (time-limited) demos available by email request (specify OS).


More information about the Filepro-list mailing list