How to jump in code?
nverma
Member Posts: 396
I am working on Report. If a certain condition is meet I want to jump from here to another point in the code.
Is there like a JUMP command or GOTO command in NAV to make it go from one place in code to another?
Is there like a JUMP command or GOTO command in NAV to make it go from one place in code to another?
0
Comments
-
Nop. But there also is no need of them. I still remember from school, that using of GOTO was a bad style even in BASIC
0 -
at the beginning of the code, I am doing a check, but if the condition of the check is true, I want it to skip bunch of statements and go to another place in the code...so i would need some sorta of command that will let me jump if the condition is true.0
-
IF <condition = TRUE> THEN BEGIN //execute code for when the condition is true END ELSE BEGIN //execute code for when the condition is not true END;
Conversely:IF <condition = FALSE> THEN BEGIN //execute code for when the condition is not true END ELSE BEGIN //execute code for when the condition is true END;
Or, if you only want to run certain code if the condition is false, and execute the rest regardless of the condition:IF <condition = FALSE> THEN BEGIN //execute code for when the condition is not true END; //execute the rest of the code
0 -
If the "IF (Customer.Birthdate = 0D) THEN" is true, I want it jump from the ****************** to the ================ at the bottom. How can I make that happen.
This is the code I have.
IF (Customer.Birthdate = 0D) THEN // If Birthday date is empty, sets Primary Consumer Type to empty
BEGIN
Job."Primary Consumer Type" := Job."Primary Consumer Type"::" ";
END;
*****************************************************************************************************
NumberOfDays:= (InputDate - BirthDay); // Gets the difference between the two dates
PrimaryType := NumberOfDays / 365; // Divides the NumberOfDays with 365 to get total number of year
CASE PrimaryType OF
1..17: // If the value is between 1 - 17, sets Primary Consumer Type
BEGIN // to Child
Job."Primary Consumer Type" := Job."Primary Consumer Type"::Child;
END;
18..64: // If the value is between 18 - 64, sets Primary Consumer Type
BEGIN // to Adult
Job."Primary Consumer Type" :=Job."Primary Consumer Type"::Adult;
END;
ELSE
BEGIN // If the value is greater than 65, sets Primary Consumer Type
// to Senior 65 and over
Job."Primary Consumer Type" := Job."Primary Consumer Type"::"Senior 65 and over";
END;
END;
IF (Customer.Birthdate = 0D) THEN // If Birthday date is empty, sets Primary Consumer Type to empty
BEGIN
Job."Primary Consumer Type" := Job."Primary Consumer Type"::" ";
END;
======================================================================================================
ProgressDialog.UPDATE(1,Job."No.");
ProgressDialog.UPDATE(2,"Consumer No.");
ProgressDialog.UPDATE(3, ROUND(Counter/TotalRecords*10000,1));0 -
Dude really? You want me to write your code?
There is no "jump" command, but if you want to execute some code based on a condition, you use an IF statement. Figure it out, try something, see if it works, adjust if it doesn't. A large part of being a developer is the ability to figure out this type of stuff.0 -
Since you don't know the option yet perhaps you should lose the case statement.
years = today - birthyear;
if years = 0 then begin
do whatever *personally I would error message out forcing a date into this field if it's so important.
end else begin
if (years > 0) and (years < 18) then begin
"Primary Consumer Type" := "Primary Consumer Type"::Child
end else begin
if (years > 17) and (years < 65) then begin
"Primary Consumer Type" := "Primary Consumer Type"::adult
end else begin
etc etc etc
haven't tested:: if years in [1..18] then begin etc etc ( if it works it's better)
** sometimes its good to step back after working on something so hard.
don't overcomplicate. It's not that hard to figure out.0 -
Yeah I would personally program it differently too, but what the particular question comes down to is the proper use of an IF THEN ELSE construct. He needs to get out of the "I need to jump" mindset, and think about which lines of code need to be executed based on that condition. All he needs is to add an ELSE block in the right position.0
-
Thanks. I got it working. The else worked in that If statement. That was so stupid of me. I dont know why I didnt think of that.0
-
-
Makes me cry sometimes seeing what level of "programmers" are working in Navision. I feel sorry for their customers/employers. ](*,)0
-
What, you didn't have a first day/week/year? You came in fully functioning with nothing left to learn?Duikmeester wrote:Makes me cry sometimes seeing what level of "programmers" are working in Navision. I feel sorry for their customers/employers. ](*,)0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions


