Re: Today's Question - poke a character in a string
Re: Today's Question - poke a character in a string
- Subject: Re: Today's Question - poke a character in a string
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 31 Jul 2002 01:12:32 -0700
On 7/31/02 12:36 AM, "email@hidden" <email@hidden> wrote:
>
I'm working with long strings (400 to 4000 characters),
>
searching for occurances of specific symbols, such as
>
double-greater-than (ASCII 200) and replacing them with
>
greater than symbols.
>
>
Is there a way to tell AppleScript to
>
>
set character 400 of MyLongString to ">"
>
>
instead of going:
>
>
set MyLongString to (characters 1 thru (CurrentIndex-1) of MyLongString) &
>
">" & (characters (CurrentIndex+1) thru end of MyLongString) as string
>
You can't set 'character x' of myLongString. I suppose you could do it this
way:
set fooishlyLongList to (every character of MyLongString)
set item CurrentIndex of fooishlyLongList to ">"
set MyLongString to fooishlyLongList as strng
But you should never use 'characters as string', especially for long
strings. It has to get a list (two lists in your original statement) which
is slow and inefficient, then a coercion (two for yours). Much better is:
set MyLongString to (text 1 thru (CurrentIndex - 1) of MyLongString) &
">" & (text (CurrentIndex +1 ) thru end of MyLongString)
Of course it doesn't look quite so arduous if you write that as:
set s to text 1 thru (c - 1) of s & ">" & text (c + 1) thru -1 of s
But then again, you might forget what that is all about. (Would you?)
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.