FIND('=><')

zakretzakret Member Posts: 7
Hi

What means IF NOT FIND('=><')? How can I understand it? Where can I use it?

Best regards
Tomasz Zakrecki

Comments

  • krikikriki Member, Moderator Posts: 9,110
    It means to find a record
    1) '=' that has the same primary key (it is like a get)
    2) if 1) doesn't find anything, it searches a record that comes after current record, using the current key
    3) if 2) doesn't find anything, it searches a record that comes before current record, using the current key

    I never used a find with all 3 characters in it.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • DenSterDenSter Member Posts: 8,307
    You don't want to use that, it is 3 table scans in one command, and it is one of the most idiotic statements in C/AL. It is one of the things to look for when you run into performance problems. FIND('-') (or FINDSET or FINDFIRST, whichever you need) should be enough.
  • gedasgedas Member Posts: 87
    Hi
    It could be used only in native db. In earler versions it was only statements looks for ANY record in table and it was fastest. Now we have "isempty".
    Never use it in SQL as denster said.
    And we don't need it now :D
    GB
  • David_CoxDavid_Cox Member Posts: 509
    Don't Know how isempty relates to find nearest, as an example a variant of this code is used in the find date functions (PeriodFormManagement) in Navision, if you are looking for a period relating to a selected date, within the period, Navision uses this code to Find the nearest Match, IE: Date Type::Month, and input a Starting Date of 10/10/06, FIND('=<>') will return the record for the 10th Month, 1st Oct - 31st Oct 2006.

    So it is not redundant and has a good use in the Navision World! :?

    Maybe this explains a use and is the answer zakret wanted?

    Note: '=><' would have returned November in the example, Equal to, Greater Than then Less Than:

    Kriki's answer being the correct one.
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • wakestarwakestar Member Posts: 207
    '=><' or "find nearest" is also used navision internal...

    when you look at some Forms (5050,41,42,43,etc.) you'll find something like
    Form - OnFindRecord()
    RecordFound := FIND(Which);  
    ....
    

    place a breakpoint and you'll see that the variable 'Which' has the value '=><' when you open the form, delete a record, post an order, etc...

    but
    IF NOT FIND('=><')
    
    checks if no records can be found
  • David_CoxDavid_Cox Member Posts: 509
    OK! did not read the question well enough. :oops:
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • gedasgedas Member Posts: 87
    Hi,
    1.
    Part from Application designer guide page 625:
    ...
    Providing the ISEMPTY Alternative to FIND
    The new ISEMPTY function utilizes an existing driver function and allows a less expensive, non-cursor, SQL statement to be used for determining whether or not a filtered set is empty. [-X
    ...
    2. FIND('=<>') generates the SAME 'select' in SQL as FIND('-'), so we have no differences between FIND('=<>') and FIND('-').
    FIND('+') add DESC in the 'select' (changes returned recordset order). FIND('=') add statement WHERE by keys values to 'select'. :-$

    3. Maybe FIND('=<>') could be used, but i didn't any see reasons. How it could return nearest in SQL?? :?:
    GB
  • DenSterDenSter Member Posts: 8,307
    wakestar wrote:
    but
    IF NOT FIND('=><')
    
    checks if no records can be found
    Not exactly, because when you replace it with IF ISEMPTY, then your card form will be empty, and the list form on F5 will be empty as well. So the two are not the same.
  • wakestarwakestar Member Posts: 207
    DenSter wrote:
    wakestar wrote:
    but
    IF NOT FIND('=><')
    
    checks if no records can be found
    Not exactly, because when you replace it with IF ISEMPTY, then your card form will be empty, and the list form on F5 will be empty as well. So the two are not the same.

    it's a bit confusing when you talk about forms..... because ISEMPTY and FIND are both Record-Functions....

    Simple - Sample with Codeunit

    Customer.SETRANGE("No.",'10000'); // --->Customer exists
    MESSAGE(FORMAT(Customer.ISEMPTY)); // ----> False
    MESSAGE(FORMAT(NOT Customer.FIND('=><'))); // ---->False

    Customer.SETRANGE("No.",'10000X'); // --->Customer doesn't exist
    MESSAGE(FORMAT(Customer.ISEMPTY)); // ----> True
    MESSAGE(FORMAT(NOT Customer.FIND('=><'))); //---->True

    So, same results... or am I still wrong??
  • David_SingletonDavid_Singleton Member Posts: 5,479
    If no record is found, then both functions give the same result, but if a record is found then they are totally different.

    The two functions ARE NOT interchangeable. They are used for different reasons.
    David Singleton
  • DenSterDenSter Member Posts: 8,307
    wakestar wrote:
    it's a bit confusing when you talk about forms.....
    Don't know why this is confusing, because it was you that asked about a form trigger, and my reply was based on the last sentence in your post.
    wakestar wrote:
    '=><' or "find nearest" is also used navision internal...

    when you look at some Forms (5050,41,42,43,etc.) you'll find something like
    Form - OnFindRecord()
    RecordFound := FIND(Which);  
    ....
    

    place a breakpoint and you'll see that the variable 'Which' has the value '=><' when you open the form, delete a record, post an order, etc...

    but
    IF NOT FIND('=><')
    
    checks if no records can be found
  • wakestarwakestar Member Posts: 207
    hmm... sorry guys if my post was a bit misleading, but I didn't ask anything... or was there a question mark?
    all I tried to explain is.. when somebody writes (as the topic starter did)
    IF NOT FIND('=><') THEN
      Call_A_MethodToFillInSomeBasicData
     ....
    

    Then I expect that the developer wants to do something ONLY when there arent any records in the table or the filtered range.... same as
    IF ISEMPTY THEN
      Call_A_MethodToFillInSomeBasicData
    

    of course ISEMPTY is the better way of coding
  • David_CoxDavid_Cox Member Posts: 509
    These are not the same, FIND will Return a Record if one exists within the filters, and ISEMPTY Just returns a boolean check as to if records exist within the filters, I have not used ISEMPTY but I assume it is used the same way we use the COUNT or COUNTAPPROX in the Native

    IF MyRec.COUNTAPPROX <> 0 THEN
    MyRec.FIND('-');

    IF NOT MyRec.ISEMPTY THEN
    MyRec.FINDFIRST;

    I think ISEMPTY is really for SQL as COUNTAPPROX returns 1 for an empty recordset in SQL and Causes an Error.
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • DenSterDenSter Member Posts: 8,307
    wakestar wrote:
    of course ISEMPTY is the better way of coding
    Again... that depends on what you want to do.... FIND will return a record if there is one, ISEMPTY will return a boolean. Use as needed.

    In the OnFinRecord form trigger, you cannot replace FIND('=><') with ISEMPTY. I have tried and it does not behave the same way. ISEMPTY IS NOT a replacement for FIND(Which) when Which equals '=><'.
  • MbadMbad Member Posts: 344
    Leave the code as it is. The way its supposed to work is making a find in the filtered recordset. If you think about what happens when you find the last record(ctrl+end) it makes perfect sense and cannot be replaced by a boolean(isempty) since that wont get you the last record.
    If you are in doubt you can always try to check the c7side reference guide(F1) look under onfindrecord.
  • LinLin Member Posts: 40
    Thanks everyone.

    I was just curious as its used in parts of standard Navision but as Gedas says it produces exactly the same SQL statement as a FIND('-') so I was unsure if it had a purpose or whether it was left over code from native navision.

    Interesting what David Cox has said about dates - I will keep that in the back of my head for now, it could come in handy in the future.

    :D
Sign In or Register to comment.