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

EXTRACT relations function

SOLVED
Level 11

EXTRACT relations function

I'm setting up some relations to extract portions of a master parameter into other parameters.

 

So far, everything went as expected. Until I got to the end of the string. The last bit of the master parameter may vary between one and 5 characters. If I enter the length bit of the extract relation as 5, it doesn't like when the master parameter has fewer than 5 characters.

 

Is there a way to get around this issue?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: EXTRACT relations function

well in that case it is simply:

 

if string_length(extract_parameter)>22

parameter = extract(extract_parameter,23,string_length(extract_parameter) - 22)

endif

5 REPLIES 5

Re: EXTRACT relations function

If I am reading your question right you are running into an issue in which the extract function is trying to extract more characters than exist in some cases. This returns a null which causes the relation to fail.

 

The way to get around this is to check the length of the string prior to executing the extract function.

 

if string_length(extract_parameter)>5

parameter = extract(extract_parameter,1,5)

endif

Re: EXTRACT relations function

Use the string_length() function to determine how many characters to extract.

http://support.ptc.com/help/creo/creo_pma/usascii/#page/fundamentals%2Ffundamentals%2Ffund_seven_sub...

Re: EXTRACT relations function

I did think about trying to use string length. With that last portion being between 1 and 5 characters (at the end of 22 other characters) I was hoping there was a more elegant solution than nesting a bunch of "IF STRING_LENGTH" statements together.

 

Something that would tell the system to just extract all characters past the 22nd one, regardless of how many exist.

Re: EXTRACT relations function

well in that case it is simply:

 

if string_length(extract_parameter)>22

parameter = extract(extract_parameter,23,string_length(extract_parameter) - 22)

endif

Highlighted

Re: EXTRACT relations function

Thanks a ton. Exactly what I needed.