hexagon logo

If, else_if statement.

I am trying to do pn verification based on a selected input for the operator and it always results in the last else_if statement being assigned. if i hover over the PN at the end of the code it's 111E1111G0006-10. I expected if i put in the first part number it'd reassign it and jump to the end. Here is the code....

$$ NO,
------------------------------
Verify PN is set correctly
------------------------------
SELECT/PN
IF/ LEFT(PN,13)=="111E1111G0003"
ASSIGN/PN="111E1111G0003-10"
END_IF/
ELSE_IF/ LEFT(PN,13)=="111E1111G0004"
ASSIGN/PN="111E1111G0004-10"
END_ELSEIF/
ELSE_IF/ LEFT(PN,13)=="111E1111G0005"
ASSIGN/PN="111E1111G0005-10"
END_ELSEIF/
ELSE_IF/ LEFT(PN,13)=="111E1111G0006"
ASSIGN/PN="111E1111G0006-10"
END_ELSEIF/
ELSE/
COMMENT/OPER,NO,FULL SCREEN=YES,AUTO-CONTINUE=NO,
"============================================= ="
"Part Number "+PN+" is not a valid choice for this inspection."
"Please select a different part number."
"Press OK to end program and re-select part number."
"============================================= ="
GOTO/ASKSPC
END_ELSE/
END_SELECT/
PN_VERIFIED=LABEL/
$$ NO,
PN
Parents
  • I had added the select statements after i thought it wasn't working. it turns out it was working fine I was just hovering over the variable expecting it to show the current value. In the end i put an operator comment with the variable in the comment and it output the correct value. As Far as it purpose it is so when the operator chooses a value from a drop down menu or scans the paperwork or types something in that it forces the assign value. The data get ingested into a database based off the part number. Basically it will verify the part number and continue or kick them back until they input the correct number. The paperwork may not contain the -10 and the drop down list will have a friendly name after the part number that we don't care about but helps them to quickly identify if they choose not to use the scanner to input the part number.

    I like the select, end_select, case, end_case, default_case, end_defaultcase method as it looks cleaner and easier to understand. Thank you for explaining that.
Reply
  • I had added the select statements after i thought it wasn't working. it turns out it was working fine I was just hovering over the variable expecting it to show the current value. In the end i put an operator comment with the variable in the comment and it output the correct value. As Far as it purpose it is so when the operator chooses a value from a drop down menu or scans the paperwork or types something in that it forces the assign value. The data get ingested into a database based off the part number. Basically it will verify the part number and continue or kick them back until they input the correct number. The paperwork may not contain the -10 and the drop down list will have a friendly name after the part number that we don't care about but helps them to quickly identify if they choose not to use the scanner to input the part number.

    I like the select, end_select, case, end_case, default_case, end_defaultcase method as it looks cleaner and easier to understand. Thank you for explaining that.
Children