• 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: Johnny AppleScript <email@hidden>
  • Date: Tue, 12 Oct 2004 23:12:17 -0600

On 04/10/12 6:38 PM, "Martin Orpen" <email@hidden> wrote:

> set biglist to {}
> set opList to {"*", "+", "/", "-"}
> repeat 1000 times
>   set end of biglist to random number from 1 to 1000
>   set end of biglist to some item of opList
> end repeat
> set n to do shell script "echo \"scale=8 \n" & (biglist as string) & "1\" |
> bc"
> n

Do you have time for a couple of questions?

When I compile the above in SE 2, the last command line compiles like this:

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

I see it's because of '/n' (newline), but I wonder, is this intentional on
your part;i.e., did you stick that in there knowing it would compile
visually different than written? Or does your script editor somehow not
auto-compile that newline command?

To sort of answer my own question, I see that the newline is required to
make the script work, but I find it a bit odd that escaping the newline
('\\n') breaks the script. Why is the escape character being passed? Is it
because the core script line is enchased in double-quotes? And is this just
a quirk that you have found the workaround for?

I'm pleased that it works, but the compiled result just bugs me as far as
formatting goes.

 _______________________________________________
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>
    • Re: String to sum -- another method
      • From: Johnny AppleScript <email@hidden>
References: 
 >Re: String to sum (From: Martin Orpen <email@hidden>)

  • Prev by Date: Re: This is ridiculous
  • Next by Date: Re: String to sum -- another method
  • Previous by thread: Re: String to sum
  • Next by thread: Re: String to sum -- another method
  • Index(es):
    • Date
    • Thread