• 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: String to sum
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String to sum


  • Subject: Re: String to sum
  • From: Mr Tea <email@hidden>
  • Date: Wed, 13 Oct 2004 00:18:02 +0100

This from Martin Orpen - dated 12/10/04 9·04 pm:

> set n to do shell script "echo \"scale=8 \n" & (biglist as string) & "\" | bc
> -s2"

Er, yes, but what does this mean? What is Œscale=8¹? what is Œ| bc ­s2¹?
Perhaps it does what¹s needed here but I like to understand what¹s going on
in my scripts, rather than just pasting in Œmagic code¹ that works because
it works. I'm not completely averse to the use of shell script capabilities
in AppleScript, but don't want to learn a load of stuff that duplicates what
AS can do already.

The handler I had knocked up, which, as I noted previously, was more
efficient than 'run script' was simply this:

on calcthis(calc, n1, n2)
    if calc is "+" then set rslt to n1 + n2
    if calc is "-" then set rslt to n1 - n2
    if calc is "/" then set rslt to n1 / n2
    if calc is "*" then set rslt to n1 * n2
    return rslt
end calcthis

Is there any real advantage in using 'else' here, instead of a bunch of
plain old 'if's?

That's just a side question, really, because all of the above is made
redundant by the 'evalformula' command in the Satimage Osax (thanks,
Emmanuel :-) )

set n1 to "5"
set n2 to "4.1"
set calc to "+"

evalformula (n1 & calc & n2) as string
--> "9.1"



Nick
pp Mr Tea

--


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: String to sum
      • From: Martin Orpen <email@hidden>
References: 
 >Re: String to sum (From: Martin Orpen <email@hidden>)

  • Prev by Date: List mom?
  • Next by Date: Re: Test image properties?
  • Previous by thread: Re: String to sum
  • Next by thread: Re: String to sum
  • Index(es):
    • Date
    • Thread