That Exit Statement again (return values)

Alfonso Pertierra Said Functions returning values in Navision can do it in some ways: a) by passing a Var parameter and modifying it with the value. b) by defining the returning variable and modifying it’s value with the result. c) by using exit(value) function. Methods a and b are really similar ones (the difference is that you don’t need to pass a variable as parameter for returning the result). Method c is almost as method b, but it terminates execution of the function. But also did you know if your run a codeunit as CODEUNIT.RUN It returns a FALSE if a run time error occurs and does not display the message on the screen if you catch the return value. ie IF NOT(CODEUNIT.RUN) THEN Deal with error; You don’t know what error has occured just that one has. Paul Baxter

I appreciate the dedicated help on this issue using return values, but i really would assume this is basic knowledge to anyone doing programming. And that is actually why i closed the topics before. But feel free to continue this discussion… Soren Nielsen, moderator Integration/Developer NOLUG

Or maybe i should put this in another way: I would not trust anyone to do programming on my system, if they don’t know these BASICS of programming. At least just taking a look at the online help would tell you what it is doing :slight_smile: Soren Nielsen, moderator Integration/Developer NOLUG

I have never seen in the online help that a codeunit returns a False if a runtime error occurs. Even if you put an ERROR statement in the codeunit the message is not diplayed on the screen. I have seen several qualified navision application designers wonder why they don’t see what they expect to see. If you know about it all well and good, but if you don’t thenyou wonder why your code acts differently between a ‘post’ and ‘post batch’. Now talking about the online help what the syntax on navisions IN statement again.

Paul may i then lead your attention to the online help (press F1 :-)), and look at this:


[Ok] := Codeunit.RUN(Number [, Record]) Ok Data type: boolean If you do not include the optional return value, and an error occurs while the system is executing the codeunit, it terminates the execution of the C/AL code that called this codeunit. If you include the return value and theres an error, the system continues to execute the calling C/AL code. This means you must handle any errors. The possible values are shown below. If Ok is… It means that… TRUE No errors occurred FALSE An error occurred during the execution of the codeunit If you include the return value, the system automatically clears the variables used in the codeunit object before and after it executes the object. If you use the return value in an IF statement which is inside a write transaction, a run-time error occurs unless you commit your data updates before you call Codeunit.RUN.

Concerning the IN I can tell you how it works, but i guess you already know. True the online help does not cover everything, but at least with the background given by the solution developer training you should be good to go. Soren Nielsen, moderator Integration/Developer NOLUG Edited by - SNielsen on 2001 May 14 19:16:39