odd lookup problem
Richard Kreiss
rkreiss at gccconsulting.net
Tue Nov 9 11:01:58 PST 2010
> -----Original Message-----
> From: Kenneth Brody [mailto:kenbrody at spamcop.net]
> Sent: Monday, November 08, 2010 9:13 PM
> To: rkreiss at gccconsulting.net
> Cc: Filepro-list at lists.celestial.com
> Subject: ***SPAM*** Re: ***SPAM*** Re: ***SPAM*** Re: odd lookup
> problem
>
> On 11/8/2010 2:46 PM, Richard Kreiss wrote:
> [...]
> > Modified code which didn't work:
> >
> > 192 ------- - - - - - - - - - - - - - - - -
> > ◄ If: ◄
> > Then: lv=master_code&"99" ◄
> > 193 ------- - - - - - - - - - - - - - - - -
> > ◄ If: ◄
> > Then: lookup SALES = sales_journal k=lv i=C -nL ◄
> > 194 ------- - - - - - - - - - - - - - - - -
> > ◄ If: SALES ◄ This line shows false in
> debugger
> > Then: GOTO next_w ◄
> [...]
> > Working code:
> >
> > 192 ------- - - - - - - - - - - - - - - - -
> > ◄ If:
> > Then: lv=master_code&"99"
> > 193 ------- - - - - - - - - - - - - - - - -
> > ◄ If:
> > Then: lookup SALES = sales_journal k=lv i=C -nL
> > 194 ------- - - - - - - - - - - - - - - - -
> > ◄ If: NOT sales
> > Then: GOTO ask_sv
> > 195 ------- - - - - - - - - - - - - - - - -
> > ◄ If: SALES and sales(4) = master_code
> > Then: GOTO next_w
> [...]
> > In the above version, line 195 shows true. This was tested before I added
> the check for the master_code in the sales journal as the next lowest value
> could be someone else's record when using next lowest.
> >
> > Master_code in in the form NNNN-NNNNN
> >
> > Again, my question is why is line 194, the not statement, necessary for line
> 195 to be true when it doesn't apply when doing an exact match lookup?
>
> Assuming identical values for field "lv", and identical data and index.C in the
> "sales_journal" file, there is no reason that "if: sales" would be false in the
> first version and "if: not sales" would be false in the second version.
>
> Now, in the second version, the "if: not sales" is required because, without it,
> the "if" on line 195 would error out if the lookup failed, due to the reference
> to "sales(4)".
I added that lookup after realizing that if: SALES could be true but the record found did not belong to the person whose record I was looking for. Ergo, test for matching master_code.
However, this is a separate issue. (Note, too, that in the
> second version, the test for sales on line 195 is redundant, as it must be true
> if the line is reached.)
>
> --
> Kenneth Brody
After an off list discussion with Bruce Easton, he had pointed out that if: (SALES ) is superfluous at line 195. This has been remove from my code.
I think that when using either next lower or next greater, the NOT FILENAME is necessary as it is possible that the lookup would be passed the last value in the index or before the first value in the index. Although in this real world case, there are records on either side of the lookup value.
Richard
More information about the Filepro-list
mailing list