• 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: any way to tell if a script has a 'return' statement?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: any way to tell if a script has a 'return' statement?


  • Subject: Re: any way to tell if a script has a 'return' statement?
  • From: has <email@hidden>
  • Date: Fri, 26 Oct 2001 19:54:38 +0100

Donald S. Hall wrote:

>Thanks to everyone who took the time to reply. It appears there is no easy
>way to tell if the script has returned a value that should be saved

Well, not unless your 'parent' script has psychic powers.;)

AS is not intelligent; it doesn't "want" to do, or not do, things - it just
does what you tell it to. If your script is returning values when you don't
want it to, it's because you haven't _told_ it _not_ to. Therefore, when
you don't want a script to return a value, make sure that the last line of
that script doesn't generate one - and the simplest way to ensure that is
to use "return" without an expression as the last line.

Your mail suggests there are only a few scripts that return results that
you do want, so for the least work it'd be quicker to modify just those
ones. This is cool. My own approach would be to return a record containing
a single property called "LogThisValue" (i.e. a name that isn't going to
crop up accidentally). This'll be simpler and more robust than
concatenating a ">" as you were suggesting.

Your version was pretty confused (i.e. incorrect:), mind. If you want me to
give a crit, I'll be happy to do so (though maybe offlist would be more
convenient).


Anyway, here's what I'd use:

try
set myVar to LogThisValue of run script test
log myvar --or whatever logging code you're using
end try


And in those scripts where you DO want the returned value, instead of using:

return foobar

use:

return {LogThisValue:foobar}


(Remember to replace "foobar" with the name of the variable you want returned.)


This way it won't matter a toffee what the other scripts return (or don't
return). They'll just be ignored.

HTH

has


  • Prev by Date: Re: how do you tell what folder a file is in? - how to tell if a file exists part
  • Next by Date: Re: how do you tell what folder a file is in?
  • Previous by thread: Re: any way to tell if a script has a 'return' statement?
  • Next by thread: OT: Open Source Apple Mods
  • Index(es):
    • Date
    • Thread