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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Redacting Text in a parameter

RCNewton
11-Garnet

Redacting Text in a parameter

Hello everyone, I have a simple question. I am sure it can be done but I have little experience with restricted parameters other than setting up drop-down boxs. 

 

I have a parameter that has a value -  ****** (xxxx-xxxxxxxxxxxxxxxx)

 

Is there a way I can filter this out to just get ****** as a parameter. (Please note that the ******* are different lengths.) 

I would love to just stop before the "("

 

Any help is appreciated. 

 

Cheers

RCN

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

I think you can do this simply, as long as the ***** stuff doesn't contain a "(". Let's say you have two parameters:

stringIN = "******* (XXXXXXXX.XXXXXXX)"
stringOUT

You want to use EXTRACT to set stringOUT to just the stuff before the "(". If the case is as simple as I've stated, that is done like this:

indexEnd = SEARCH ( stringIN, "(" )
IF indexEnd > 1
  stringOUT = EXTRACT ( stringIN, 1, ( indexEnd - 1 ) )
ENDIF

Note: If there's no "(" in stringIN, or there's no text prior to the "(", stringOUT remains unchanged. If there is a space between the beginning of stringIN and the "(" and you don't want it, use ( indexEnd - 2 ) instead of ( indexEnd - 1 ).

View solution in original post

2 REPLIES 2

I think you can do this simply, as long as the ***** stuff doesn't contain a "(". Let's say you have two parameters:

stringIN = "******* (XXXXXXXX.XXXXXXX)"
stringOUT

You want to use EXTRACT to set stringOUT to just the stuff before the "(". If the case is as simple as I've stated, that is done like this:

indexEnd = SEARCH ( stringIN, "(" )
IF indexEnd > 1
  stringOUT = EXTRACT ( stringIN, 1, ( indexEnd - 1 ) )
ENDIF

Note: If there's no "(" in stringIN, or there's no text prior to the "(", stringOUT remains unchanged. If there is a space between the beginning of stringIN and the "(" and you don't want it, use ( indexEnd - 2 ) instead of ( indexEnd - 1 ).

Patriot_1776
22-Sapphire II
(To:RCNewton)

Ken (and others here) is way better than I am at programming, but, you could make your parameter that reads "xxxx-xxxxxxxxxxxxxxxx" a sum of 2 other parameters.  For instance, we would have a part that is comprised of the cage code (5-digits), separated by a dash, from the vendor part number.  So, you could make parameters that were named "COMBINED_PART_NUMBER", "CAGE_CODE", and "VENDOR_PART_NUMBER".  The relation COMBINED_PART_NUMBER = CAGE_CODE + "-" + VENDOR_PART_NUMBER.  I believe that's the syntax, my license server is down.....again.....so I can't check my example parts.

 

EDIT:  Up and running again...finally.  Yup, the syntax is correct.  The quotes are needed for text strings (whatever you want to say, a space, a dash etc.), the plus sign "adds" them, and the parameters (for their value) don't need quotes.  I use this a lot for my library fasteners.

 

Best of luck!

Top Tags