Re: Too simple to find an answer for...
Re: Too simple to find an answer for...
- Subject: Re: Too simple to find an answer for...
- From: Allen Watson <email@hidden>
- Date: Thu, 29 Jul 2004 19:28:45 -0700
On or near 7/29/04 3:52 PM, Martin Orpen at email@hidden
observed:
>
on 29/7/04 9:33 pm, Andrew Oliver at email@hidden wrote:
>
>
> If what you're trying to do is sum (i.e. add) all the integers, you'll
>
> either need to loop through them, or use some OSAX that can do it for you
>
> (without checking, I'm guessing the Satimage OSAX will do this 0- it does
>
> just about everything else ;) )
>
>
That's not necessarily true:
>
>
>
set MyNumberList to {5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2}
>
set oldDelims to AppleScript's text item delimiters
>
set AppleScript's text item delimiters to " + "
>
set myResult to do shell script "echo " & (MyNumberList as string) & " |
>
bc"
>
set AppleScript's text item delimiters to oldDelims
>
myResult
>
>
-->"58"
>
>
>
It's just a bit of fun :-)
That doesn't really have to use shell script; AppleScript does math also:
set MyNumberList to {5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2}
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to " + "
set myResult to (run script (MyNumberList as string))
set AppleScript's text item delimiters to oldDelims
myResult
-->"58"
--
<email@hidden>
Scripts for OE and Entourage: <
http://allenwatson.thinkaccess.net/Scripts/>
Entourage questions: <
http://www.entourage.mvps.org/>
_______________________________________________
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.