How does EXIT function works

liizz
Member Posts: 125
How is the EXIT function used when there need be to return variable?
For e.g:
IF statement1 THEN
EXIT(FALSE);
ELSE
statement2;
EXIT(TRUE);
What does the EXIT(FALSE) and EXIT(TRUE) mean?
Please advise.
Thanks
Liizz
For e.g:
IF statement1 THEN
EXIT(FALSE);
ELSE
statement2;
EXIT(TRUE);
What does the EXIT(FALSE) and EXIT(TRUE) mean?
Please advise.
Thanks
Liizz
0
Comments
-
From the Classic Client, click on the Help menu and select 'C/SIDE Reference Guide'. In the Search tab, enter 'EXIT' and click the "list topics" button. There's a whole list of topics that you can read that explains the various C/AL commands, and EXIT is in there somewhere.0
-
I have already checked the EXIT function on Help.
Its a function that will exit either a true or a false variable.
But how to know when it should exit with TRUE or FALSE values.
This is my question.
This is a standard code on Classic:
IF ApprovalTemplate.FIND('-') THEN
EXIT(TRUE)
ELSE
EXIT(FALSE);
Lets say if the boolean return variable has been interchanged.
Thanks to clarify me.
Liizz0 -
The function is checking whether there is any Approval templte exists or not..
If record found then it is returning boolean TRUE
if not found FALSE
based on the return value from function the process may be different..0 -
liizz wrote:This is a standard code on Classic:
IF ApprovalTemplate.FIND('-') THEN
EXIT(TRUE)
ELSE
EXIT(FALSE);
If it was writtenEXIT(ApprovalTemplate.FIND('-'));
it would make more sense to read.David Singleton0 -
liizz wrote:I have already checked the EXIT function on Help.
Its a function that will exit either a true or a false variable.
EXIT is the command that you use to jump out of a function, and between the parentheses you define the value of the return value. In this particular case, the return value is a boolean, so it is TRUE or FALSE. You can define any data type in the return value, and EXIT with any value that belongs to that data type. If you don't define a return value, you simply say EXIT without a parameter.
So if your return value is a text data type, you can say EXIT('Bye Bye'), if it is a decimal you can say EXIT(3.14), etcetera.
Read the C/SIDE Reference Guide again. Open up some big codeunits and search for the EXIT command and see how it's used in the standard code. By doing this, you might actually learn something.1 -
Strange to say but EXIT is not listed in the online Help (NAV2009 SP1) and it has nothing in the Search option except a lot of entries with exit (in lowercase).
Thanks to Denster, we have a detailed explanation.Experience is what you get when you hoped to get money0 -
You must be in the code of an object when you go to help.
Here it is:EXIT Statement
The EXIT statement is used to control the flow of the execution. The following syntax shows an EXIT statement.
Copy Code
EXIT([<Value>])
An EXIT statement is used to interrupt the execution of a C/AL trigger. The interruption takes place even when the code is executed inside a loop or a similar structure. The EXIT statement is also used when a local function should return a value.
Using EXIT without a parameter in a local function corresponds to using the parameter value 0. The C/AL function will return the value 0 or '' (empty string).
A compile-time error occurs if EXIT is called with a return parameter from either of the following:
System-defined triggers
Local functions that do not return a value
Example
The following example shows the use of the EXIT statement in a local function. Assume that the IF statement is used to detect an error. If the error condition is met, then execution is stopped and the local function returns the error code 1.
Copy Code
FOR I := 1 TO 1000 DO BEGIN
IF Amount < Total THEN
EXIT(1);
A := Amount + Total;
END;Gerry Kistler
KCP Consultores1 -
I Found it in the Search using the filter EXIT(FALSE) / C/AL Repetitive Statements.
After scrolling down through to the end, I found the same text as you describe.
The FOR WHILE REPEAT help is in the first section of help text, so it is not that obvious.Experience is what you get when you hoped to get money0 -
colingbradley wrote:EXIT is not listed in the online Help (NAV2009 SP1) and it has nothing in the Search option except a lot of entries with exit (in lowercase).
I never said it was easy to findbut the C/SIDE Reference Guide is a gem that surprisingly many people never use.
0 -
colingbradley wrote:I Found it in the Search using the filter EXIT(FALSE) / C/AL Repetitive Statements.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions