Re: encode url without OSAX
Re: encode url without OSAX
- Subject: Re: encode url without OSAX
- From: Nigel Garvey <email@hidden>
- Date: Sat, 30 Jun 2001 12:27:14 +0100
Paul Berkowitz wrote on Fri, 29 Jun 2001 20:44:04 -0700:
>
On 6/29/01 8:12 PM, "Brian" <email@hidden> wrote:
>
> set x to "the quick brown fox"
>
> set y to every text item of x
>
> repeat with i in y
>
> if i = " " then
>
> set i to " "
>
> end if
>
> end repeat
>
> return y as string
>
>
>
> but the result still shows the <spaces> as <spaces> rather than s.
>
>
>
> Any ideas what I'm missing/doing wrong/don't understand?
>
>
>
You're merely re-setting 'i', a variable, each time it's equal to " ".
>
You're not changing anything in the the list y. You want to do this :
[Good script snipped]
Also, 'i' is never equal to " ". With this kind of repeat, the value of
'i' is a reference to an item in the thing being looped through, not the
value of the item itself. 'Greater than' and 'less than' comparisons work
here, but 'equal to' comparisons don't. You'd need to use the
dereferencing operator 'contents of':
repeat with i in y
if contents of i = " " then
set contents of i to " "
end if
end repeat
Another solution would be:
set applescript's text item delimiters to {" "}
set y to text items of x
set applescript's text item delimiters to {" "}
set x to y as string
set applescript's text item delimiters to {""}
return x
NG