Have a Fanuc LR mate 200id with a 30i B Controller and want to modify a Karel program statement to add several OR statements with integer values after the <4 value. Can I just insert <4 OR 3 OR 5 OR 8 OR etc....Logic is as follows:
• Line 67: IF (RI[2:HxBlnkGrip_CLSD]=ON AND R[1:Part Number]<4 Then;
• Line 68: CALL M_LOAD_CYCLE ;
• Line 69: JMP LBL[4] ;
Karel Instruction Help
-
rich43 -
September 15, 2016 at 9:41 PM -
Thread is Resolved
-
-
Have a Fanuc LR mate 200id with a 30i B Controller and want to modify a Karel program statementThat seems more like TP, not Karel ..
to add several OR statements with integer values after the <4 value. Can I just insert <4 OR 3 OR 5 OR 8 OR etc....Logic is as follows:
• Line 67: IF (RI[2:HxBlnkGrip_CLSD]=ON AND R[1:Part Number]<4 Then;
• Line 68: CALL M_LOAD_CYCLE ;
• Line 69: JMP LBL[4] ;No, that won't work. You'll have to compare each option with R[1:Part Number], or come up with a single statement that lets you do what you want.
Looks like you basically need to check whether R[1:Part Number] < 8, correct? You don't have 6 or 7 in there, but since you include 8, all the others will be smaller than that anyway.
-
rf103,
Thanks for your response and my mistake, you are correct TP and not Karel.
Also, your suggestion to compare each option with R[1:Part Number] =? may be my best option.
Could I do this. IF (RI [HxBlnkGrip_CLSD] AND R[1:Part Number]<4 OR R[1:Part Number] =7 Then;
Call_M_Load_Cycle
Thanks again
-
Yep, you could do that. The code would look like this:
Be aware of order of operations though. Numerical comparisons have a higher precedence than logical comparators, and the 'AND' comparator has a higher order than the 'OR' comparator.
-
Thank you,
Now if I had to add several OR statements, identical to the one just added but with different integer values, is there a better way of writing the line of code?
-
You could expand the IF statement to encompess the conditions you want. A mixed logic IF statement can support up to 20 items in it.
Otherwise you could break up the IF statement into multiple if statements.
For example:
Code: IF (RI[1:HxBlnkGrip_CLSD] AND R[1:Part Number]<4), JMP LBL[5] ; : IF (R[1:Part Number]=7), JMP LBL[5] ; : IF (R[1:Part Number]=11), JMP LBL[5] ; : IF (R[1:Part Number]=7=25), JMP LBL[5] ; : !None of the above are true... ; : JMP LBL[10] ; : ; : LBL[5:True] ; : CALL M_LOAD_CYCLE ; : LBL[10:End] ;
-
Thank you. Good Option.