• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: encode url without OSAX
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: encode url without OSAX
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: repeat with i from 1 to count items of the selection (9.1)
  • Next by Date: Re: Writing without opening (was: Login Applescript won't write to file)
  • Previous by thread: Re: encode url without OSAX
  • Next by thread: Re: encode url without OSAX
  • Index(es):
    • Date
    • Thread