Bad getnext?

Tyler Cameron Style cmaitson at telus.net
Fri Oct 14 11:14:28 PDT 2005


I am having an odd problem.  I am doing a lookup to a file that I want
to iterate through all records for.  Since this is a library function,
I don't want to use indices for this lookup.  I look up the file using
record# 1.  Fine and dandy so far.

I then use a loop to iterate through the records, using a getnext:

  30 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: lookup original = (@PY{"@"{@QU)  r=(ro) -e
  31 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: ca ne "Y" and rb ne ""
       Then: lookup backup = (@PY{"@backup")  r=(rb) -ep
  32 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
loop02s  If: 
       Then: '---go thru all requested records checking for changes
  33 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: not original
       Then: goto loop02e
  34 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: show original(@RN)
  35 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: ca eq "Y" and @PY eq "ncust" and original(4) ne ""
       Then: lookup backup = ("ncust@"{@QU)  k=(original(4))   i=A -nx
  36 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: ca eq "Y" and @PY eq "kinotox" and original(1) ne ""
       Then: lookup backup = ("kinotox@"{@QU)  k=(original(1))   i=A -nx
  37 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: not backup
       Then: goto loop02n
  38 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: i="1"; ms=""; nf=NUMFIELD(original)
  39 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
loop01s  If: 
       Then: 
  40 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: i gt nf    'all fields examined, exit
       Then: goto loop01e
  41 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: FIELDVAL(original,i) eq FIELDVAL(backup,i)
       Then: goto loop01n
  42 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: lookup log = log_changes@  r=free  -e
  43 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: log(1)=@PY; log(2)=@QU; log(3)=ro; log(4)=id; log(5)=i
  44 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: log(6)=FIELDNAME(original,i); log(7)=FIELDVAL(backup,i)
  45 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: log(8)=FIELDVAL(original,i); log(10)=@TD; log(11)=TM
  46 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: log(12)="UPDATE"
  47 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 'debug code
       Then: show "@CHANGE"<original(@RN)
  48 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: write log
  49 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
loop01n  If: 
       Then: i=i+"1"; goto loop01s
  50 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
loop01e  If: 
       Then: 
  51 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: 
       Then: copy original to backup; write backup
  52 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
         If: original(@RN) gt "33180"        'debug code
       Then: show "@"<original(@RN)<backup(@RN)
  53 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
loop02n  If: ca eq "Y" and original
       Then: getnext original; goto loop02s
  54 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
loop02e  If: 
       Then:

However, when it gets to the last record, I get an error (in this
instance original & backup are lookups to ncust):

*** A filePro Error Has Occurred ***

On File: /hd1/hd1/appl/filepro/ncust/indexhh.A

Output Processing
Line Number: 53
   Record Number: 1
Lookup File Name: ncust
    Using Record:


Lookup failed.
Correct the key field(s) and try again.

Why is this?  Especially since I am not even using indexhh.A for
original - I should be iterating through the records with no index.
The getnext should just set original to be null, so that the condition
at loop02s can be tested and the loop exited.  Instead, it bombs out.
I usually iterate using indices, and I've never encountered this
problem before.  Is it related to the fact that I am iterating using
record#?  If so, how the heck do you tell when you've reached the end
of the file, then?

     Tyler




More information about the Filepro-list mailing list