IF SomeVeryVeryVeryLongFunctionName(ItemLedgerEntry."Posting Date", ItemLedgerEntry."Entry Type", ItemLedgerEntry."Document Type", ItemLedgerEntry."SourceNo") THEN BEGIN DoSomething(); END;
IF SomeVeryVeryVeryLongFunctionName( ItemLedgerEntry."Posting Date", ItemLedgerEntry."Entry Type", ItemLedgerEntry."Document Type", ItemLedgerEntry."SourceNo") THEN BEGIN DoSomething(); END;
IF SomeVeryVeryVeryLongFunctionName(ItemLedgerEntry."Posting Date", ItemLedgerEntry."Entry Type", ItemLedgerEntry."Document Type", ItemLedgerEntry."SourceNo") THEN BEGIN DoSomething(); END;
IF SomeVeryVeryVeryLongFunctionName(ItemLedgerEntry."Posting Date", ItemLedgerEntry."Entry Type", ItemLedgerEntry."Document Type", ItemLedgerEntry."SourceNo") THEN BEGIN DoSomething(); END;or sometimes variant 5
WITH ItemLedgerEntry DO IF SomeVeryVeryVeryLongFunctionName("Posting Date", "Entry Type", "Document Type", "SourceNo") THEN BEGIN DoSomething(); END;The reason is to be able easilly see when the IF condition ends and the executed code begins, and also to have the IF/THEN BEGIN/END on the same indentation level, so going with cursor up/down one will arrive at beginnig/end of the block.
Answers
Variant 3 is the most used.
Try to look at new code. Ex. Codeunit 80 has been rewritten, and it uses variant 3.
NAV still contains old code.
But you have to read it afterwards, so do what you like.
I understand all 3, so any developer can take over.
I'm folding the line with parameters when it is longer than approx 100 - 120 characters - this is to ensure that when I (or someone) will be merging the code in text editor the whole line fits in editor window when two editors (or a single window with two objects code) are positioned side-by-side
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03