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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

String Functions

acs_alan
1-Newbie

String Functions

Hello,

I wish to take a string and make some modificiation. I have found the 'String Functions' section but it has been no help.

Problem 1:

I have a text element with the following text inside:

85x2
86x20
87x14
88x8
89x10
90x10
91
92x2
93
94

Now I need these to be seperate text elements roughly in the same position...I am finding the string functions limited and I am unsure how to do this inside Isodraw can anyone help?

Problem 2:

I have the following text element:

13x2

I need to seperate the 13 and the x2 into their own elements, I have tried using the FIND (source, search, start) as explained in the 'String Functions' section to always find the X and then I can hopefully start to remove the X and text after the X into another text element but unfortunately my isodraw crashes when I use FIND() in conjunction with the MESSAGE function. If I use the FIND() on its own Isodraw returns the error: "Unknown Macro Command"

MACRO Test

DEFINE str AS string

str = "13x4"

MESSAGE "Result: " + find(str, x, 1)

END MACRO

(Note I could not see the code button)

Does anyone have any suggesions?

Thank you

Alan

Message was edited by: Alan Porter

Message was edited by: Alan Porter

4 REPLIES 4

The find command appears to be missing a detail in the documentation. Change your macro line to look like this: MESSAGE "Result: " + find(str, "x:, 1). The quotes are necessary around the search criteria.

Here is the answer to problem 2.

Macro Test
Define str As String
Define First as String
Define Last as String
Define Middle as Integer
Define Start_First as Integer
Define Start_Last as Integer

str = "13x4"

Middle=find(str, "x", 1)

Start_First=Middle-1
Start_Last=Len(str)-Middle

First=Left(str,Start_First)
Last=Right(str,Start_Last)

Message "First: " + First + $NewLine + "Last: " + Last

End Macro

Attached is the start of problem 2. Right now, the way it works is by selecting the text element. Then launch the command and it parses it and shoots a message up with each line (line feed is the delimiter). As idicated in the code, there is a spot where you could actual write the text elements out separately. Easiest way is to determine the start of the element you want toi replace, and then use that as your starting position for the new text. Each addition then also adds a set distance to a variable for the placement of the next text line.

Thanks for the assistance, and my apologies for the late response. I havnt tried the code you have suggested or supplied but I will do, I just wanted to say thank you before more time passed.

Thanks

Alan

Top Tags