cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

pro-program question

snellutla
1-Newbie

pro-program question

Hi Guys,

IF A < 4

IF A < 3

B = “P”

ENDIF

ELSE

B = “Q”

ENDIF

C = “XXX –YY - &A &B”

I want to achieve C based on A and B values

For ex: if A = 5 --> B = Q

And C = XXX – YY – 5 B

Where as C = “XXX –YY - &A &B” is returning XXX –YY - &A &B and which makes sense as the above line considering it as a single string value.

Could anyone assist me in achieving this in pro-program relations?

Thanks,

Sharath
This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
4 REPLIES 4

Hi Sharath,

To concatenate a string parameter to a string, simply use + (i.e. "XXX -
YY - " + A). If your parameter A is an integer, you need to convert it
to a string and use ITOS(A) in your relations. If your parameter A is a
real number, I'm not sure of a quick way to handle that as there is no
"real to string" function that I'm aware. ITOS will handle a real
number, but the result will be rounded off.

Here's how I would write your relations:

IF A < 4
IF A < 3
B = "P"
ELSE
B = "Q"
ENDIF
ENDIF

C = "XXX - YY - " + A + " " + B

or

C = "XXX - YY - " + ITOS(A) + " " + B

Hope this helps,
Tyler

Thanks for the response,

Input parameter A is real number. Is there any wqay to add it to "C" (string).

Tyler/Sharath,



If you want to convert the real number to string, the relation would be
similar to this:

X1= FLOOR(REAL_NUMBER)

X2= REAL_NUMBER-X2



IF X2> 0 /*Checks to make sure the number wasn't already an integer

X=ITOS (X1) + "." + ITOS(X2*1000) /* NOTE: this is for a 3 place
decimal, use multiplier values accordingly

ELSE

X=ITOS(X1) + ".000"

ENDIF



Robert Tobin
Fowler Engineering

Thanks for the help.

Sharath

Top Tags