C/AL Code

Stan09Stan09 Member Posts: 63
Hi,
What is the meaning of this record filter:
record.find('=<>').

thank you for your answer.

Comments

  • bbrownbbrown Member Posts: 3,268
    Stan09 wrote:
    Hi,
    What is the meaning of this record filter:
    record.find('=<>').

    thank you for your answer.


    The system will first try to find a record that matches, otherwise it will find the record before, or the record after.
    There are no bugs - only undocumented features.
  • KYDutchieKYDutchie Member Posts: 345
    Hi,

    I think that is called the "find nearest" or "find any".
    This was used in old versions, here is the help description from version 2.6.
    That might help you.


    [Ok :=] Record.FIND([Which])


    Ok

    Data type: boolean

    If you omit this optional return value, a run-time error occurs if the system cannot find the record. If you include a return value, the system assumes you will handle any errors. Ok can have these values:


    If Ok is... It means the record was...
    TRUE Found
    FALSE Not found
    Record

    Data type: record

    On input, Record identifies the record you want the system to find. On output, there are two possibilities:


    If the record was... Then...
    Found The system returns the record in Record and sets any FlowFields in the record to zero. You must update them using CALCFIELDS.
    Not found A run-time error occurs, if you omitted the return value Ok.
    Which

    Data type: text or code

    Tells the system how to perform the search. The system searches through the table until either it finds the record or there are no more records. Each character in this string can be present only once. You can combine the '=', '<' and '>' characters.


    This... Tells the system to search for...
    '=' A record that equals the key values (default)
    '>' A record that is larger than the key values
    '<' A record that is less the key values
    '+' The last record in the table ('+' can only be used alone)
    '-' The first record in the table ('-' can only be used alone)
    If SearchStr contains '=', '>' or '<', you must assign values to all fields of the current and primary keys before you call FIND.

    Comments
    FIND retrieves the first record that meets the conditions set by SearchStr and the filters associated with Record. The search path reflects the sort order defined by the current key. If the current key is not the primary key, there is a chance that several records might have the same values in current key fields. If this happens, the system uses the sort order defined by the primary key as the search path.


    Example
    This C/AL code shows how to use the FIND function.

    d.OPEN('Search for customer number...\'
    + '#1##################');
    d.INPUT(1, Customer."No.");
    IF Customer.FIND THEN
    MESSAGE('The customer was found.\' +
    'Customer No. %1 is:\' +
    '%2', Customer."No.", Customer.Name)
    ELSE
    MESSAGE('Sorry, that customer could not be found...');

    First, the system prompts you to enter a customer number to search for:

    Search for customer number...

    If the number you enter does not exist, the system displays this message:

    Sorry, that customer could not be found...

    If the system finds the number in the Customer table, it could display:

    The customer was found.
    Customer number AAA 1050 is:
    AAA Furniture Manufacturing

    Regards,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • helmhelm Member Posts: 46
    Read this http://www.mibuso.com/howtoinfo.asp?FileID=22 about record.find('=<>') and lots of other useful tips about C/AL.
  • Stan09Stan09 Member Posts: 63
    Thank you very much, your help is useful.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    FIND('=><') is pretty much redundant now with cached RAID arrays.

    In simple terms when Navision was able to directly interact with disks, the function was faster in some cases. Now it offers no benefit.

    In most cases you can use FIND('-'), FINDFIRST, or FINDSET to get the same result. In some cases the best option is to use ISEMPTY. But you need to look at what the code is doing and make the right change.
    David Singleton
  • bbrownbbrown Member Posts: 3,268
    FIND('=><') is used to find the closest record if an exact match cannot be found.
    There are no bugs - only undocumented features.
Sign In or Register to comment.