IBMiAccess




Results 1 to 11 of 11

Thread: Difference between %EOF & Not %Found

  1. #1
    Sr. Product Specialist FaStOnE's Avatar
    Join Date
    Nov 2005
    Location
    Phoenix, AZ
    Age
    51
    Posts
    2,611
    Rep Power
    3998

    Difference between %EOF & Not %Found

    Gentlepeeps:

    Can someone go over a simplistic definition of the difference between:

    Code:
    Chain SKU SKUMst;
    If Not %eof( SKUMst );
    
    EndIF;
    and

    Code:
    Chain SKU SKUMst;
    If %Found( SKUMst )
    
    EndIF;
    And why would you use one over the other?

    Thanks!
    -Rick

    _____________________________

    Need a Managed File Transfer Solution -OR- iSeries Encryption?
    GoAnywhere and Crypto Complete by Linoma Software


  2. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Age
    21
    Posts
    1,000,000
     

  3. #2
    Analyst GLS400's Avatar
    Join Date
    May 2006
    Location
    connecticut
    Posts
    1,906
    Rep Power
    5809

    Re: Difference between %EOF & Not %Found

    Hey FaStOnE:

    Found this:
    Where %Eof, %Equal, and %Found may be used



    This is from a V4R2 article in News400, but I still refer to it to make sure I'm using the right BIF.

    Chain - %Found
    Check - %Found
    CheckR - %Found
    Delete - %Found
    LookUp - %Equal, %Found
    Read - %Eof
    ReadC - %Eof
    ReadE - %Eof
    ReadP - %Eof
    ReadPE - %Eof
    Scan - %Found
    SetGT - %Found
    SetLL - %Equal, %Found
    Write (subfile only) - %Eof
    here:
    http://www.think400.dk/adhoc_2.htm#eks0019


    Chain/EOF......like Oil/Water


    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

  4. #3
    Lord of the Dance
    Join Date
    Aug 2008
    Location
    Memphis - Nashville TN
    Posts
    1,692
    Rep Power
    4716

    Re: Difference between %EOF & Not %Found

    Can someone go over a simplistic definition of the difference between:

    Code:
    Chain SKU SKUMst;
    If Not %eof( SKUMst );
    
    EndIF;

    The really simple answer is that a failed chain does not set the file pointer to end of file. So a failed chain would almost always execute the code within the NOT %eof( file ) section.

    Basically, you use the bif %found with chain operations, %eof with read(x) operations, and %equal with setll if you want the setll to tell you if the key was found.
    Michael Catalani
    Manager of eCommerce Development
    Acceptance Insurance Corporation
    www.AcceptanceInsurance.com
    www.ProvatoSys.com

  5. #4
    Analyst BenThurley's Avatar
    Join Date
    Dec 2006
    Location
    Southampton (UK)
    Age
    32
    Posts
    818
    Rep Power
    2534

    Re: Difference between %EOF & Not %Found

    You have been redirected to this page

    Some reasons:

    1) Your ISP has been 'blacklisted' in SORB's or others

    2) The IP address you're using has been 'blacklisted' or is in my .htaccess


    I thought it was like this. %Eof is switched on when you attempt to move the record pointer past the last record. %Found is switched on when an exact match is found for the key you used to do the lookup with.

    In general this means you use %Eof with reads and %Found with chains. However, take the following examples.

    PHP Code:
    Setll (Key1:Key2FILE;
    If %
    Found(FILE);
    ... 
    PHP Code:
    Chain (Key1:Key2FILE;
    If %
    Found(FILE);
    ... 
    Both of these code blocks are perfectly valid. Both are effectively checking if a particular record exists in FILE. The difference is the Setll one will run faster because it doesn't have to read the record. If you just want to check the record exists, you should use Setll. If you want to check it exists and then use that record, you should use chain.
    Ben

  6. #5
    Sr. Product Specialist FaStOnE's Avatar
    Join Date
    Nov 2005
    Location
    Phoenix, AZ
    Age
    51
    Posts
    2,611
    Rep Power
    3998

    Re: Difference between %EOF & Not %Found

    I guess I just couldn't see the reason for the "Chain If NOT %Eof()" piece. But, we found this in come code that is having iffy results.

    Just wanted some feedback...

    Thanks peeps!
    -Rick

    _____________________________

    Need a Managed File Transfer Solution -OR- iSeries Encryption?
    GoAnywhere and Crypto Complete by Linoma Software


  7. #6
    Experienced Forum Member arrow483's Avatar
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    1,741
    Rep Power
    4224

    Re: Difference between %EOF & Not %Found

    One of the big problems with Chain and %EOF is because the %EOF is not set by chain, it might still be set on by a prior operation. The CHAIN will not reset.

  8. #7
    Lord of the Dance
    Join Date
    Aug 2008
    Location
    Memphis - Nashville TN
    Posts
    1,692
    Rep Power
    4716

    Re: Difference between %EOF & Not %Found

    Quote Originally Posted by BenThurley View Post

    I thought it was like this. %Eof is switched on when you attempt to move the record pointer past the last record. %Found is switched on when an exact match is found for the key you used to do the lookup with.
    On the SETLL, the %found will be true if there is a record in the file it can position to. It's not the same as a %found on a chain, which means the exact key has to be in the file. In order to use SETLL in lieu of the CHAIN op code, you would need to check the %EQUAL bif for the condition.
    Michael Catalani
    Manager of eCommerce Development
    Acceptance Insurance Corporation
    www.AcceptanceInsurance.com
    www.ProvatoSys.com

  9. #8
    Analyst
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    1,603
    Rep Power
    9599

    Re: Difference between %EOF & Not %Found

    Copied from the RPG Reference:
    1. %EOF
    %EOF returns 1 if the most recent read operation or write to a subfile ended in an end of file or beginning of file condition; otherwise, it returns 0. The operations that set %EOF are:
    • READ (Read a Record) on page 750
    • READC (Read Next Changed Record) on page 753
    • READE (Read Equal Key) on page 755
    • READP (Read Prior Record) on page 758
    • READPE (Read Prior Equal) on page 760
    • WRITE (Create New Records) on page 821 (subfile only).


    The following operations, if successful, set %EOF(filename) off. If the operation is not successful, %EOF(filename) is not changed. %EOF with no parameter is not changed by these operations.
    • CHAIN (Random Retrieval from a File) on page 611
    • OPEN (Open File for Processing) on page 737
    • SETGT (Set Greater Than) on page 781
    • SETLL (Set Lower Limit) on page 785


    2. %FOUND

    %FOUND returns 1 if the most recent relevant file operation found a record, a string operation found a match, or a search operation found an element. Otherwise, this function returns 0. The operations that set %FOUND are:
    File operations:
    • CHAIN (Random Retrieval from a File) on page 611
    • DELETE (Delete Record) on page 633
    • SETGT (Set Greater Than) on page 781
    • SETLL (Set Lower Limit) on page 785

    String operations:
    • CHECK (Check Characters) on page 614
    • CHECKR (Check Reverse) on page 617
    • SCAN (Scan String) on page 776

    Note: Built-in function %SCAN does not change the value of %FOUND.

    Search operations: LOOKUP (Look Up a Table or Array Element) on page 689

    If %FOUND is used without the optional file_name parameter, then it returns the value set for the most recent relevant operation. When a file_name is specified, then it applies to the most recent relevant operation on that file.

    For file operations, %FOUND is opposite in function to the ″no record found NR″ indicator.

    Birgitta

  10. #9
    Code400 Newbie
    Join Date
    Aug 2012
    Location
    Philippines
    Posts
    5
    Rep Power
    0

    Re: Difference between %EOF & Not %Found

    If...

    Code:
    Chain (Key1) File1;
    If %Found(File1);
       DoW Not %EoF(File1);
          // something something
       ReadE (Key1) File1;
       EndDo;
    EndIf;
    ...is the very ugly version of...

    Code:
    SetLL (Key1) File1;
    ReadE (Key1) File1;
    DoW Not %EoF(File1);
       // something something
    ReadE (Key1) File1;
    EndDo;
    can i just simply change the old (ugly) code to the newer one?? i think that some records were not read in a similar looking line in my work because it uses chain/eof like that.... oil/water i tell you...

  11. #10
    Harbinger of Doom tomholden's Avatar
    Join Date
    Dec 2007
    Location
    Lebanon, Tennessee, United States
    Posts
    4,335
    Rep Power
    8658

    Re: Difference between %EOF & Not %Found

    yes but i would check %EQUAL after the SETLL if no matching record is found you can bypass the loop since there's nothing for it to process.
    I'm not anti-social, I just don't like people -Tommy Holden

  12. #11
    Code400 Newbie
    Join Date
    Aug 2012
    Location
    Philippines
    Posts
    5
    Rep Power
    0

    Re: Difference between %EOF & Not %Found

    thanks tom, i just learned something new today

  13. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

Facebook Comments


Similar Threads

  1. Time difference in sql
    By ashwani.bhat in forum SQL
    Replies: 2
    Last Post: August 25th, 2008, 04:05 AM
  2. Time Difference
    By vinomails in forum SQL
    Replies: 4
    Last Post: July 10th, 2008, 01:50 PM
  3. Replies: 3
    Last Post: February 8th, 2007, 06:43 AM
  4. Difference b/w SNDUSRMSG and SNDMSG
    By jenin in forum CLP/CLLE
    Replies: 3
    Last Post: November 15th, 2006, 10:43 PM
  5. RPG and RPGLE Difference
    By Revathi Muruges in forum RPG/RPGLE
    Replies: 3
    Last Post: May 6th, 2005, 10:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •