Jump to content

PCM if else endif - Question


---
 Share

Recommended Posts

Good day!

I'm still fairly new to PCM. I have some experience w/ PCDMIS, but the syntax for PCM is confusing me. What I have are to separate straightness reported as (two) characteristics. Then utilizing a Result Element, I want to report the larger of the two straightness results. Below is my code:

if getActual ("Straightness_0").actual < getActual ("Straightness_90").acual then getRESULTS (getActual("Straightness_90").actual) else if getRESULTS (getActual("Straightness_0").actual) endif

This, however, is not working. Can someone take a look and point out what I'm doing wrong? Thanks so much.
Link to comment
Share on other sites

Please sign in to view this quote.

What kind of error does it throw out?
At first glance I see a typo:
if getActual ("Straightness_0").actual < getActual ("Straightness_90").acual then...
if getActual ("Straightness_0").actual < getActual ("Straightness_90").actual then...

Just an idea, try max() command.

Oh, and what is your intention here?
getRESULTS (getActual("Straightness_90").actual)
maybe?
getRESULTS = (getActual("Straightness_90").actual)
Link to comment
Share on other sites

Please sign in to view this quote.

IDK anything about PCM but you could just use "minimum" and "maximum" feature characteristic and mask the other two .
Link to comment
Share on other sites

Thank you both for replying. John I could do that, but I try to make my programs self-sufficient...not sure if that's the right way to describe it. It's rare that anyone here has to cover for me. If they do, the less questions they have the less phone calls I get while I'm on vacation. lol

Dane, the type-o was my bad. I'm in the "fun" situation of having to use one pc for my work on the CMM and a laptop for documentation purposes of my job. I just dictate what I had wrong.

My intention is to only report the highest reading. Basically I have two straightness checks that are both masked off. I'm using the Result Element to grab the larger of the two.

I had tried the max() code but, again, I can't seem to figure out the syntax. The examples Calypso give down below are too incomplete to truly determine what needs to be done. The few PCM codes I have figured out have been triall and error w/ a mixture of dumb luck.
Link to comment
Share on other sites

If you want to play with PCM, and you also want to clarify and put an end to the obvious questions, i invite you to play around with putting comments/formulas in the comment section.
Its quirky because the comment section is setup for text, and not math, so you need to do a little fudging to get it to work right.

"Straightness_0 " + formatL( (getActual("Straightness_0").actual)) +cr()+ "Straightness_90 " + formatL( (getActual("Straightness_90").actual))

You also may need to multiply or divide by 25.4 depending on your machine setup situation, the line would look like
formatL((getActual("Straightness_90").actual/25.4))

I use comments as shown to show the Min & Max profile deviations without cluttering the page with separate items, i also show the base + bonus tolerances when dealing with bonus

fdjhkfdjhfgdjhfd.JPGfgdjhkfgdjhkfgdjhkfe.JPG

Link to comment
Share on other sites

Christopher,

play around with numbers:

display(min(5,2,4,8,12))
display(max(5,2,4,8,12))
remember to select the code before executing it.

edit:
or as defined variables:

varA = 5
varB = 2
varC = 4
varD = 8
varE = 12

display(min(varA,varB,varC,varD,varE))
display(max(varA,varB,varC,varD,varE))
Link to comment
Share on other sites

Please sign in to view this quote.

You're using the if-then-else staements in the wrong way. I marked the errors in the quote above. "else" and "else if" are not the same. If you use "else if", you need to specify another condition and another "then", which isn't necessary here. Just use "else" instead, then it should work.
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
Good Morning,

Hey Norbert, got another syntax question for you. I am trying to report the difference of two readings, but report as a positive value.
This is what I have:

"if getActual("Result Element1").actual<0 then getActual("Result Element1").actual*(-1) endif"

I wish there was a PCM syntax guide to look through. The "HELP" in Calypso isn't very helpful w/ regards to PCM. Can show me what I'm doing wrong? Thank you sir.
Link to comment
Share on other sites

Please sign in to view this quote.

I would omit the whole if construction here and just use the abs() function instead:
abs(getActual("Result Element1").actual)
But to answer the initial question: The problem in your if statement depends on what you're trying to do here. Is it supposed to be a formula somewhere in a feature or a characteristic? Or is it part of some more PCM code in some pre- or post settings?

If it's supposed to be a formula then "if" statements don't work there.
If it's part of some real PCM code, then you need to tell Calypso what it should do with the part after "then". Just stating a "getActual" there isn't enough. You need to either assign the result to a variable or embed it in an output statement, like this:
// assign to a variable
if getActual("Result Element1").actual<0 then
     MyValue = getActual("Result Element1").actual*(-1)
endif

// output
if getActual("Result Element1").actual<0 then
     display(getActual("Result Element1").actual*(-1))
endif
Of course you can also do other things with the result, but doing something you must.
Link to comment
Share on other sites

Can't believe I didn't think about doing an absolute. Embarrassing...

Thank you for the explanation of the code. Really appreciate it sir.
Link to comment
Share on other sites

 Share

×
×
  • Create New...