alguidelines/content/docs/NAVPatterns/3-cal-coding-guidelines/design/findset-findfirst-findlast/index.md
2022-02-24 14:45:35 +01:00

523 B

+++ title = "FINDSET FINDFIRST FINDLAST" weight = 600 tags = ["C/AL"] categories = ["Best Practice"] +++ FINDSET, FIND('+') or FIND('-') should only be used when NEXT is used and vice versa.

Bad code

IF Cust.FIND('-') THEN
    ERROR(CustIsBlockErr)

Good code

IF Cust.FINDFIRST THEN
    ERROR(CustIsBlockErr)

Bad code

IF Cust.FINDFIRST THEN
    REPEAT
        ...
    UNTIL Cust.NEXT = 0;

Good code

IF Cust.FINDSET THEN
    REPEAT
        ...
    UNTIL Cust.NEXT = 0;