delete chars from string

This one should be easy, but I’m stumped.


set diskMaxSizex to (do shell script "diskutil resizeVolume /dev/" & bootDiskSlice & " limits | grep \"Maximum\" | awk '{print $5}'") as string
display dialog diskMaxSizex
set diskMaxSize to ((characters 2 thru -1 of diskMaxSizex) as string) --to remove '(' character
display dialog diskMaxSize

In AS Editor, it works as expected.

In XCode, diskMaxSizex is (2506521911
I wanted to strip the ( char, but I end up with
diskMaxSize 2/5/0/6/5/2/1/9/1/1

Any idea why the forward slashes are being added…?
thx
-t-

Why not just pipe your result to sed, as in this example :

âž” echo ‘(2506521911’ | sed s~(~~
2506521911

It’s because somewhere else in your code you have set text item delimiters to the slash, and have failed to reset them. As well as fixing that, you should use “text 1 thru -2 of diskMaxSizex” – that’s a lot more efficient than making a list and coercing it to text.

Thanks guys. You were correct about leaving an old delimiter set. I had saved the orig. delimiters, had a block of code, but in that, I changed the delimiters twice. In the second half, I saved the delimiters again which didn’t save the orig delimiter, but saved the first change, so when I reset at end, it put it back to the first change, not apple’s orig. delimiters.

And thanks for tip on text 1 thru -2. I didn’t know you could do that.

And eremita, it’s because I think in simple steps so my code tends to be written that way :wink:

Thanks again for the help.