• 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: convert string to a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: convert string to a list


  • Subject: Re: convert string to a list
  • From: "Arthur J. Knapp" <email@hidden>
  • Date: Thu, 01 Aug 2002 17:23:41 -0400

> Date: Thu, 1 Aug 2002 13:04:56 -0400
> From: "Mark J. Miller" <email@hidden>
> Subject: convert string to a list

> Don't know if this can be done. I want to take a string and read it
> one character at a time.

To directly answer your Subject line:

set aString to "Hello World"

set aList to every character of aString
--
--> {"H", "e", "l", "l", "o", " ", "W", "o", "r", "l", "d"}


> ... Do I have to first write it out to a file
> and then read it back in...

Now that would be funny!!! ;-)


> For example:
> I want to take "The quick brown fox" and be able to check each
> character "T" "h" "e" " " "q" "u"...

set str to "The quick brown fox"

-- Method 1
--
repeat with x from 1 to length of str

set oneChar to character x of str

if ( oneChar = "T" ) then
-- stuff
else if ( oneChar = "h" ) then
-- stuff


-- Method 2
--
repeat with oneChar in str

( oneChar = "q" ) --> ALWAYS false, oneChar is a reference

( oneChar's contents = "q" ) --> true or false

set oneChar to oneChar's contents --> dereference
( oneChar = "q" ) --> true or false



{ Arthur J. Knapp, of <http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
}
_______________________________________________
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.

  • Prev by Date: Re: {}'s end
  • Next by Date: save documents problem
  • Previous by thread: Re: convert string to a list
  • Next by thread: (help?!?) GraphicConverter: setting pixel(s) for definition of selection
  • Index(es):
    • Date
    • Thread