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
  • good Day

    please use case in an Select-Statement, instead of If-else:


    
    SELECT/C1.INPUT
    
        CASE/1
    
        ...
    
        END_CASE
    
        CASE/2
    
        ...
    
        END_CASE
    
        DEFAULT CASE
    
        ...
    
        END_DEFAULT CASE
    
    END_SELECT
    
    



    
    SELECT/LEFT(PN,13)
    
        CASE/"111E1111G0003"
          ASSIGN/PN="111E1111G0003-10"
        END_CASE
    
        CASE/"111E1111G0004"
          ASSIGN/PN="111E1111G0004-10"
        END_CASE
    
    END_SELECT
    
    



    by the way, thats the same:
       ASSIGN/PN2=LEFT(PN,13)+"-10"
    

    i dont understand what exactly you want to archiv :/
Reply
  • good Day

    please use case in an Select-Statement, instead of If-else:


    
    SELECT/C1.INPUT
    
        CASE/1
    
        ...
    
        END_CASE
    
        CASE/2
    
        ...
    
        END_CASE
    
        DEFAULT CASE
    
        ...
    
        END_DEFAULT CASE
    
    END_SELECT
    
    



    
    SELECT/LEFT(PN,13)
    
        CASE/"111E1111G0003"
          ASSIGN/PN="111E1111G0003-10"
        END_CASE
    
        CASE/"111E1111G0004"
          ASSIGN/PN="111E1111G0004-10"
        END_CASE
    
    END_SELECT
    
    



    by the way, thats the same:
       ASSIGN/PN2=LEFT(PN,13)+"-10"
    

    i dont understand what exactly you want to archiv :/
Children
No Data