[code][/code]tags around your code to keep it readable. Then you usually don't need to post the code as image also. Use the ¶ - button, then Code from the pull-down menu to insert the tags.
IF <Condition> THEN <Statement> [ELSE <Statement>]Then there is the Compound Statement, a special type of statement which looks like
BEGIN [[Statement];]* END';' goes between statements (syntax) but the style guide asks for it at the end of each statement
IF "Balance (LCY)" = 0 THEN BEGIN myrec.SETRANGE("Customer No.","No."); IF myrec.FINDSET THEN BEGIN REPEAT IF myrec.Open THEN BEGIN ERROR(openIsTrue); END; UNTIL myrec.NEXT = 0; END ELSE BEGIN ERROR(postIsNotAvailable); END; END ELSE BEGIN ERROR(SaldoisNotZero); END;This code now has many more BEGINs and ENDs than are required, and the style guide tells you to remove them, but most programmers like to have them in anyway.
Answers
dont "END; ELSE BEGIN" -> do "END ELSE BEGIN"
You also should get used to how code is formatted (indented) in NAV. There is a style guide, but basically just do it like standard code does it. Rules here beeing:
- BEGIN is on the same line as the statement needing the block
- END is indented the same as the statement needing the block
- END ELSE BEGIN is written like this on one line
Most languages have control structures which define blocks. Those blocks are often indicated by { ... }C/AL has syntax like Pascal. Control structures are defined in terms of statements, not blocks, thus Then there is the Compound Statement, a special type of statement which looks like ';' goes between statements (syntax) but the style guide asks for it at the end of each statement
This might help you sort out the syntax, and the formatting of source code. So, your code should look more like This code now has many more BEGINs and ENDs than are required, and the style guide tells you to remove them, but most programmers like to have them in anyway.
thanks for your valuable Feedback, and my apologies for writing my code in a bad form.