Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

If Then Else branch with or


pip
 Share

Recommended Posts

I need to add a condition branch to my post.

 

if (mi1$<>1)|

(mi1$<>2)|

(mi1$<>81)|

(mi1$<>82), mi1$=85

n$, "M", *mi1$, e$

 

This is what I have got at the moment, but something is not right as it always committes the last statement and makes mi1$=85. Anybody see what I am doing wrong.

Link to comment
Share on other sites

First off I think you are going to have to pass the mi$ value off to a different variable for checking, I generally do it in the tool change section

 

sav_mi1 = mi1$

 

Then try

 

code:

if sav_mi1 <> 1, | if sav_mi1 <> 2, | if sav_mi1 <> 81, | if sav_mi1 <> 82, mi1$ = 85

n$, "M", *mi1$, e$

I am not sure it's going to work on several level, the reason is the conditional statements don't seem to make sense

 

if mi1 is less or greater than 1

or

if mi1 is less or greater then 2

or

if mi1 is less or greater than 81

or

if mi1 is less or greater than 82

 

then mi1 is equal to 85

 

I really think you'll need to come up with a cleaner way to check for it.

 

What are you actually trying to check that varaiable for?

 

BTW, there is no IF,Then Else branching in your statement

Link to comment
Share on other sites

what is it equal to otherwise, the value set in it?

 

This might work then

 

code:

if sav_mi1 <> 1, | if sav_mi1 <> 2, | if sav_mi1 <> 81, | if sav_mi1 <> 82, 

[

mi1$ = 85

]

n$, "M", *mi1$, e$

with that 85 value than you can move it inside of the brackets, then that output will be part of the conditional check statement

Link to comment
Share on other sites

Try this:

 

if (mi1$ < 1 & mi1$ > 2) & (mi1$ < 81 & mi1$ > 82), mi1$ = 85

 

Then you will want to format the output. You should have something like this in your post:

 

#Common format statements

fs2 4 1 0 1 0 #Integer, not leading

 

If so, look for a section with a bunch of fmt's and add this line:

 

fmt M 4 mi1$ #Misc Integer 1 output

 

Then you can output the information:

 

n$, *mi1$, e$

Link to comment
Share on other sites

If mi1 is less than 1 AND mi1 is more than 2 AND mi1 is less than 81 and more than 82, mi = 85

 

 

which leaves the fours values

 

all four values need to be true for true for the statement to be true

 

if mi1 is equal to 1,2, 81 or 82 the statement is false, not setting of the value of mi1 to 85

 

The parenthesis determines 2 separate checks

 

so when it checks for 1 and 2 in the first set, if it finds it is set to 1 or 2, the statement is false, and it bails, if true it goes on to the second set, checking for 81 and 82 with the same conditions,

Link to comment
Share on other sites

still at work, how do you activate debug,

bug1 : 2 # 0=No display, 1=Generic list box, 2=Editor

bug2 : 30 # Append postline labels (column position)

bug3 : 0 # Append whatline number to each NC line?

bug4 : 1 # Append NCI line number to each NC line?

this is how mine is setup and fastmode is = 0

Still not outputting the lines in the nc file..

Link to comment
Share on other sites

quote:

if mi1 is equal to 1,2, 81 or 82 the statement is false, not setting of the value of mi1 to 85

That part I understand, but what if mi1 is 0 or 3 or any other number. The statement would still evaluate as False as far as I can think it through so I don't see how mi1 would ever be set to 85.

Link to comment
Share on other sites

I am going to try a different route for this funtion now..

In mi1 value will go like this

1 = datum 1

2 = datum2

3 = M81

4 = M82

I am not going to try and catch any mistakes but what I would like to do is when the condition is correct then set a string variable to the correct output.

IE mi1=1, datum$="datum #"

Any help please

Link to comment
Share on other sites

If you want to make sure mi1$ is set (correctly) to can set up an error message;

 

first create an error variable

code:

test_mi1_setting : 0   # variable switch for turning on "mi1 not set" error

set up the error message. You probably already have an error message area in your post

code:

smi1error  "ERROR -- misc integer 1 not set correctly"

set up the condition to pop the error;

code:

      if (mi1$<>1)|(mi1$<>2)|(mi1$<>81)|(mi1$<>82), test_mi1_setting = mprint(smi1error)

If mi1 doesn't equall the four choices an alarm will pop up on your monitor and show up on the post log file if you have it turned on.

Link to comment
Share on other sites

Thats what I love about this forum, always somthing new to learn. I like Tims approach of throwing an error if the programmer forgets something better than forcing the computer to choose (unless you can guarantee the computer will choose corectly).

Andy & Steve I think your both right. I think either equation would give the right result.

 

John, just a little FYI, in many programming languages the <> symbol is treated as a single operator that means not equal. So his orig equation would read as

 

if mi1 does not equal 1

 

instead of

 

if mi1 is less or greater than 1

 

You guys Rock!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...