• 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: numbers in a variable.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: numbers in a variable.


  • Subject: Re: numbers in a variable.
  • From: Paul Skinner <email@hidden>
  • Date: Thu, 31 Jul 2003 17:29:46 -0400

On Thursday, July 31, 2003, at 03:51 PM, kai wrote:

SNIP

set sampleText to "Printers
1 HP laserjet
2 HP inkjet
3 Canon color
Plotters
4 xerox
5 oce"

set {itemList, hdngList, numStr} to {{}, {}, "1234567890"}

repeat with newLine in sampleText's paragraphs
tell newLine's contents to if its character 1 is in numStr then
set itemList's end to it
else
set hdngList's end to it
end if
end repeat

{itemList, hdngList}

--> {{"1 HP laserjet", "2 HP inkjet", "3 Canon color", "4 xerox", "5 oce"},{"Printers", "Plotters"}}


Kai,
I love terse, but...

tell newLine's contents to if its character 1 is in numStr then

Whew!
It's like that bit of the pork chop that you just can't chew up!

Is there any advantage to that method over the less obsfucated ...


set sampleText to "Printers
1 HP laserjet
2 HP inkjet
3 Canon color
Plotters
4 xerox
5 oce"
set {itemList, hdngList, numStr} to {{}, {}, "1234567890"}

repeat with newLine in sampleText's paragraphs
set newLine to newLine's contents
if character 1 of newLine is in numStr then
set itemList's end to newLine
else
set hdngList's end to newLine
end if
end repeat

{itemList, hdngList}

-->{{"1 HP laserjet", "2 HP inkjet", "3 Canon color", "4 xerox", "5 oce"}, {"Printers", "Plotters"}}

PS
_______________________________________________
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.

References: 
 >Re: numbers in a variable. (From: kai <email@hidden>)

  • Prev by Date: Re: numbers in a variable.
  • Next by Date: [ANN] XMail 1.0.2
  • Previous by thread: Re: numbers in a variable.
  • Next by thread: Re: numbers in a variable.
  • Index(es):
    • Date
    • Thread