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.
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));
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.
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.
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.
Comments
RIS Plus, LLC
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));
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.
RIS Plus, LLC
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.
http://www.BiloBeauty.com
http://www.autismspeaks.org
RIS Plus, LLC
RIS Plus, LLC
RIS Plus, LLC