Cancel
Showing results for 
Search instead for 
Did you mean: 

Edit String

Genius
Genius

Hello!

 

Problem:

Is there a way to edit strings in Simtalk at a particular position?

 

For e.g.

If there is a string named Word with value "see", and I want to change it to "sea".

In other programming languages, we can manipulate strings like we do with arrays. Can we do something like that here?

like Word[3] := "a"?

 

Having a method for it in Simtalk would be helpful.

 

The Real Problem:

I am trying to generate a PartID for MUs based on other User defined attributes. More like a batch number or Serial number for a product. This includes a letter for Model name, a letter for color, a letter for size(S,M,L), and the 6 digits for date of production. It should look like "ARM240418" where A- Model, R-Red, M-medium size.

 

I think I will be able to do it if I can pick up this information from the User defined attributes and write it to a new string. However, I can't seem to find a way to do it.

 

Thanks.

Sanchay

 

 

 

2 REPLIES

Re: Edit String

Phenom
Phenom

Try this code to replace a character at the defined location with "x"

 

var s : string :="abc"

var cLoc : integer :=3

print incl("x",omit(s,cLoc,1),cLoc)

Re: Edit String

Genius
Genius

This works. Thanks.