hexagon logo

Case statement help

Having trouble getting this to work. In the input field I have entered 3. My c1 variable should be 1.378 in the auto circle at the end of the code. it is showing in my auto feature as the 5th case - as if it is returning a false value? Can anyone look at the code below and see the issue?
2011 Mr1 - offline seat.
Thanks!!

DO/
C20 =COMMENT/INPUT,NO,FULL SCREEN=NO,
enter a digit for part number.
81024905 TYPE - 1
81024904 TYPE - 2
81024903 TYPE - 3
81024901 TYPE - 4
81024900 TYPE - 5
SELECT/C20.INPUT
CASE/1
ASSIGN/A1=4.132
ASSIGN/B1=.378
ASSIGN/C1=1.614
ASSIGN/D1=.704
END_CASE/
CASE/2
ASSIGN/A1=4.073
ASSIGN/B1=.473
ASSIGN/C1=1.496
ASSIGN/D1=.704
END_CASE/
CASE/3
ASSIGN/A1=4.014
ASSIGN/B1=.496
ASSIGN/C1=1.378
ASSIGN/D1=.704
END_CASE/
CASE/4
ASSIGN/A1=3.955
ASSIGN/B1=.555
ASSIGN/C1=1.26
ASSIGN/D1=.604
END_CASE/
CASE/5
ASSIGN/A1=3.896
ASSIGN/B1=.614
ASSIGN/C1=1.142
ASSIGN/D1=.604
END_CASE/
END_SELECT/
UNTIL/C20.INPUT >1 OR C20.INPUT <5
BOLT HOLE 2=FEAT/CONTACT/CIRCLE/DEFAULT,CARTESIAN,OUT,LEAST_SQR
THEO/<0,0.03,0>,<0,-1,0>,C1,0
ACTL/<0,0.03,0>,<0,-1,0>,1.142,0
TARG/<0,0.03,0>,<0,-1,0>
START ANG=0,END ANG=360
ANGLE VEC=<1,0,0>
DIRECTION=CCW
SHOW FEATURE PARAMETERS=NO
SHOW CONTACT PARAMETERS=YES
NUMHITS=3,DEPTH=0,PITCH=0
SAMPLE HITS=0,SPACER=0
AVOIDANCE MOVE=BOTH,DISTANCE=0.5
FIND HOLE=DISABLED,ONERROR=NO,READ POS=NO
SHOW HITS=NO
  • kbotta,
    Have you tried running it yet? I've found that on my offline seat I'll get the last variable that I inserted, as it is doing in your case. However, when I run the program it runs correctly.
  • Your kidding?! no, i have not tried running it yet. i will in a bit and let you know what I find...
    Thanks for that info!
    Kevin
  • Wlayton is correct, however, I'd do it in another manner.

    You are using a while clause to determine if the circle should be executed or not. I'd use a label to return the operator to the selection screen again if they choose to enter anything lower than 1 and higher than 5.

    Like this:

    TOP        =LABEL/
    C20        =COMMENT/INPUT,NO,FULL SCREEN=NO,
                enter a digit for part number.
                81024905 TYPE - 1
                81024904 TYPE - 2
                81024903 TYPE - 3
                81024901 TYPE - 4
                81024900 TYPE - 5
                IF_GOTO/C20.INPUT < 1 OR C20.INPUT > 5,GOTO = TOP
                SELECT/C20.INPUT
                CASE/1
                ASSIGN/A1=1
                ASSIGN/B1=1
                ASSIGN/C1=1
                ASSIGN/D1=1
                END_CASE/
                CASE/2
                ASSIGN/A1=2
                ASSIGN/B1=2
                ASSIGN/C1=2
                ASSIGN/D1=2
                END_CASE/
                CASE/3
                ASSIGN/A1=3
                ASSIGN/B1=3
                ASSIGN/C1=3
                ASSIGN/D1=3
                END_CASE/
                CASE/4
                ASSIGN/A1=4
                ASSIGN/B1=4
                ASSIGN/C1=4
                ASSIGN/D1=4
                END_CASE/
                CASE/5
                ASSIGN/A1=5
                ASSIGN/B1=5
                ASSIGN/C1=5
                ASSIGN/D1=5
                END_CASE/
                END_SELECT/
    CIR1       =FEAT/CONTACT/CIRCLE/DEFAULT,CARTESIAN,IN,LEAST_SQR
                THEO/<0,0,0>,<0,0,1>,C1
                ACTL/<0,0,0>,<0,0,1>,2
                TARG/<0,0,0>,<0,0,1>
                START ANG=0,END ANG=360
                ANGLE VEC=<1,0,0>
                DIRECTION=CCW
                SHOW FEATURE PARAMETERS=NO
                SHOW CONTACT PARAMETERS=NO


    You'd need to edit the variables values to suit your application though - before running this...
  • i like that. I'll give it a try! Thansk Guys!
  • It has now made my case/ end case red. Also, picked the last selection vs my selected "3".
    Do you see anything wrong with this??
    TOP        =LABEL/
    C20        =COMMENT/INPUT,NO,FULL SCREEN=NO,
                enter a digit for part number.
                81024905 TYPE - 1
                81024904 TYPE - 2
                81024903 TYPE - 3
                81024901 TYPE - 4
                81024900 TYPE - 5
                SELECT/C20.INPUT
                IF_GOTO/C20.INPUT<1 OR C20.INPUT >5,GOTO = TOP
                [COLOR=#ff0000]CASE[/COLOR]/1
                ASSIGN/A1=4.132
                ASSIGN/B1=.378
                ASSIGN/C1=1.614
                ASSIGN/D1=.704
                [COLOR=#ff0000]END_CASE[/COLOR]/
                [COLOR=#ff0000]CASE[/COLOR]/2
                ASSIGN/A1=4.073
                ASSIGN/B1=.473
                ASSIGN/C1=1.496
                ASSIGN/D1=.704
                [COLOR=#ff0000]END_CASE[/COLOR]/
                [COLOR=#ff0000]CASE[/COLOR]/3
                ASSIGN/A1=4.014
                ASSIGN/B1=.496
                ASSIGN/C1=1.378
                ASSIGN/D1=.704
                [COLOR=#ff0000]END_CASE[/COLOR]/
                [COLOR=#ff0000]CASE[/COLOR]/4
                ASSIGN/A1=3.955
                ASSIGN/B1=.555
                ASSIGN/C1=1.26
                ASSIGN/D1=.604
                [COLOR=#ff0000]END_CASE[/COLOR]/
                [COLOR=#ff0000]CASE[/COLOR]/5
                ASSIGN/A1=3.896
                ASSIGN/B1=.614
                ASSIGN/C1=1.142
                ASSIGN/D1=.604
                [COLOR=#ff0000]END_CASE[/COLOR]/
                END_SELECT/
  • 1) as said before expressions will be evaluated during execution - if you just hover the cursor over the variable pcdmis goes backwards in the program looking for the first variable with that name to display
    2) you have your SELECT/IF reveresed.

    SELECT/C20.INPUT
    IF_GOTO/C20.INPUT<1 OR C20.INPUT >5,GOTO = TOP

    should be:
    IF_GOTO/C20.INPUT<1 OR C20.INPUT >5,GOTO = TOP
    SELECT/C20.INPUT
  • Wouldn't a default_case with an attached GOTO have had the same result? That way if he needed to add more in the furture less modification would be needed. Just a question.
  • I've always prefered to use the simple IF/GOTO statement. No end statements required, just simple (KISS) programming.
    (also.... 'spaces' in ID's? numbers, letters, and the underscore only to be safe!)

    TOP        =LABEL/
    C1         =COMMENT/INPUT,NO,'enter value for part number
                                ,1 = part a
                                ,2 = part b
                                ,3 = part c
                                ,4 = part d
                                ,5 = part e'
                IF_GOTO/C1.INPUT<1,GOTO = TOP
                IF_GOTO/C1.INPUT>5,GOTO = TOP
                IF_GOTO/C1.INPUT<2,GOTO = L1
                IF_GOTO/C1.INPUT<3,GOTO = L2
                IF_GOTO/C1.INPUT<4,GOTO = L3
                IF_GOTO/C1.INPUT<5,GOTO = L4
                GOTO/L5
    L1         =LABEL/
                COMMENT/DOC,NO,PART-A
                ASSIGN/V1 = 1
                ASSIGN/V2 = 2
                ASSIGN/V3 = 3
                ASSIGN/V4 = 4
                GOTO/L6
    L2         =LABEL/
                COMMENT/DOC,NO,PART-B
                ASSIGN/V1 = 11
                ASSIGN/V2 = 12
                ASSIGN/V3 = 13
                ASSIGN/V4 = 14
                GOTO/L6
    L3         =LABEL/
                COMMENT/DOC,NO,PART-C
                ASSIGN/V1 = 21
                ASSIGN/V2 = 22
                ASSIGN/V3 = 23
                ASSIGN/V4 = 24
                GOTO/L6
    L4         =LABEL/
                COMMENT/DOC,NO,PART-D
                ASSIGN/V1 = 31
                ASSIGN/V2 = 32
                ASSIGN/V3 = 33
                ASSIGN/V4 = 34
                GOTO/L6
    L5         =LABEL/
                COMMENT/DOC,NO,PART-E
                ASSIGN/V1 = 41
                ASSIGN/V2 = 42
                ASSIGN/V3 = 43
                ASSIGN/V4 = 44
                GOTO/L6
    L6         =LABEL/
    P001       =AUTO/CIRCLE,SHOWALLPARAMS = YES,SHOWHITS = NO
                THEO/0,0,0,0,0,1,V3
                ACTL/0,0,0,0,0,1,33
                TARG/0,0,0,0,0,1
                THEO_THICKNESS = 0,RECT,IN,STRAIGHT,LEAST_SQR,ONERROR = NO,$
                AUTO MOVE = BOTH,DISTANCE = 7,RMEAS = None,None,None,$
                READ POS = NO,FIND HOLE = NO,REMEASURE = NO,$
                NUMHITS = 4,INIT = 0,PERM = 0,SPACER = 3,PITCH = 0,$
                START ANG = 0,END ANG = 0,DEPTH = 3,$
                ANGLE VEC = 1,0,0
    


    When I ran it offline, I told it that it was part 3, and you can see the actual diameter came out as a match for the #3 variable.
  • If you insert a break point before your logic begins the program will run continuously up to the break point and will then stop and allow you to step through the program line by line in single block mode. During this time the execution is considered to be live and you can hover your cursor over any variable to see the value as it will be during normal part execution. You can also edit the code in this mode so you don't have to make a list of all the changes you want to make and the go back after the execution has completed and put them all in. You can make your changes right then and there as the code is executing.

    Some things still won't execute exactly right. For example, I have seen relearn scans continue to execute with the last populated variable values even though when you hover over the variable itself it shows a different value. Still, even with a few glitches, this is a very valuable debugging method. You can do this in both offline and online mode but I would be a bit cautious about dynamically changing the code in online mode.