Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hello,
I am able to set relations in repeat region as below:
if asm_mbr_name == "PRT0001"
CAD_SAP_PLM_IDX = "1000"
else
CAD_SAP_PLM_IDX = RPT_INDEX
endif
I would like to understand how to use else if into relation. My scenario is as below:
Thank you in advance.
Regards
Ketan
Solved! Go to Solution.
Remember that for every "if" you need and an "endif" at the end.
I have a word doc that I can cut and paste as needed (a sample of that file):
IF asm_mbr_pn == "9594"
NEWQTY = "0.5"
ELSE
IF asm_mbr_pn == "9556"
NEWQTY = "0.5"
ELSE
IF asm_mbr_pn == "9151"
NEWQTY = "0.5"
ELSE
ENDIF
ENDIF
ENDIF
By stacking up all the ifs. Each if statement has to end with an endif.
if asm_mbr_name == "PRT0001"
CAD_SAP_PLM_IDX = "1000"
else
if asm_mbr_name == "PRT0002"
CAD_SAP_PLM_IDX = "1001"
else
if asm_mbr_name == "PRT0003"
CAD_SAP_PLM_IDX = "1002"
else
CAD_SAP_PLM_IDX = RPT_INDEX
endif
endif
endif
Remember that for every "if" you need and an "endif" at the end.
I have a word doc that I can cut and paste as needed (a sample of that file):
IF asm_mbr_pn == "9594"
NEWQTY = "0.5"
ELSE
IF asm_mbr_pn == "9556"
NEWQTY = "0.5"
ELSE
IF asm_mbr_pn == "9151"
NEWQTY = "0.5"
ELSE
ENDIF
ENDIF
ENDIF
For those of us who have trouble keeping track of our if statements, it's really helpful to indent the statements:
if asm_mbr_name == "PRT0001"
CAD_SAP_PLM_IDX = "1000"
else
if asm_mbr_name == "PRT0002"
CAD_SAP_PLM_IDX = "1001"
else
if asm_mbr_name == "PRT0003"
CAD_SAP_PLM_IDX = "1002"
else
CAD_SAP_PLM_IDX = RPT_INDEX
endif
endif
endif
Then it's easy to see if you're missing an "endif", and which "else" goes with which "if". Just remember that Creo doesn't care about whitespace (spaces and tabs), so if you were to write:
if asm_mbr_name == "PRT0001"
CAD_SAP_PLM_IDX = "1000"
else
if asm_mbr_name == "PRT0002"
CAD_SAP_PLM_IDX = "1001"
endif
Creo thinks the "endif" goes with the last "if", not the first "if". When things go wrong in a nested if statement, it's often because we get confused about where we are when writing the statements. Indenting the code helps to get your thinking straight.
To summarize, there is no built in "ELSE IF" in Creo. You can get the same effect by using "ELSE", then another "IF", then another "ELSE" and so on, but deeply nested "IF" and "ELSE" statements can get tough to follow.
For repeat region relations I prefer to set the default value and then check for the other conditions. (The last one set "wins".)
CAD_SAP_PLM_IDX = RPT_INDEX
IF ASM_MBR_NAME == "PRT0001"
CAD_SAP_PLM_IDX = "1000"
ENDIF
IF ASM_MBR_NAME == "PRT0002"
CAD_SAP_PLM_IDX = "1001"
ENDIF
Thank you all for help.