• 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: functions as sort of first class objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: functions as sort of first class objects


  • Subject: Re: functions as sort of first class objects
  • From: Deivy Petrescu <email@hidden>
  • Date: Tue, 24 May 2016 07:42:58 -0400

> Hey Mitchell,
>
> h() does not exist.
>
> h does.  It is not a handler but a reference to a handler.
>
> You also need to reference a() & b() properly:
>
> ----------------------------------
> to a()
>   display alert "A"
> end a
>
> to b()
>   display alert "B"
> end b
>
> repeat with h in {my a(), my b()}
>   h
> end repeat
> ----------------------------------
>
> --
> Best Regards,
> Chris
>

Chris, I don’t believe your script does what you thing it does.
The calls for a and be happen at the  assignment, that is at the first line of  the repeat statement.
To verify this, put a delay in the repeat loop and you will see that it will "not be respected”, that is the two dialogs happens one right after the other.
To get what Mitchell wants you have to do the following:

to a()
	display alert "A"
end a

to b()
	display alert "B"
end b


repeat with h in {a, b}
	run script h
	delay 5
end repeat


Deivy Petrescu
email@hidden




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


  • Follow-Ups:
    • Re: functions as sort of first class objects
      • From: Christopher Stone <email@hidden>
References: 
 >functions as sort of first class objects (From: Mitchell L Model <email@hidden>)
 >Re: functions as sort of first class objects (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Library Use Statement Question
  • Next by Date: Re: Library Use Statement Question
  • Previous by thread: Re: functions as sort of first class objects
  • Next by thread: Re: functions as sort of first class objects
  • Index(es):
    • Date
    • Thread