• 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: handler failure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handler failure


  • Subject: Re: handler failure
  • From: John Delacour <email@hidden>
  • Date: Wed, 13 Nov 2002 15:12:49 +0000
  • Mac-eudora-version: 5.3a8

At 1:38 pm -0800 12/11/02, Chris Espinosa wrote:

AppleScript is not Pascal. To return a value from a function, you use
the Return command:

on doSomethingCool()
return "@*%^!!!"
end


But AppleScript is not perl either, and most AS expressions return a result, so the use of 'return' is nearly always superfluous and not the equivalent of 'return' in perl, which can only be used in a subroutine.

These two scripts will do the same thing, but the AS script doesn't require the 'return'.

set x to 1
ADD_ONE(x)

on ADD_ONE(param)
param + 1
end ADD_ONE


but this will _not_ work if I omit the line return $newval and
nor will 'print ADD_ONE($x)'


do shell script "perl -e'
$x = 1 ;
$x = ADD_ONE ($x) ;
print $x ;

sub ADD_ONE {
$newval = $_[0] + 1;
return $newval
}'"
_______________________________________________
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: handler failure (From: Chris Espinosa <email@hidden>)

  • Prev by Date: A Primer for Applescript...?
  • Next by Date: Re: handler failure
  • Previous by thread: Re: handler failure
  • Next by thread: Re: handler failure
  • Index(es):
    • Date
    • Thread