• 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: enumerated types: best way to fake them?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: enumerated types: best way to fake them?


  • Subject: Re: enumerated types: best way to fake them?
  • From: Paul Berkowitz <email@hidden>
  • Date: Fri, 01 Nov 2002 12:58:10 -0800

On 11/1/02 12:34 PM, "Michael Sullivan" <email@hidden> wrote:

> Sigh. I know I should just use strings, but I can't help myself.
> Working with lisp a bit lately is making me yearn for a symbol type in
> AS.
>
> Has anyone come up with a better idea for this sort of thing? Or do you
> just use integer flags or strings. What I'm really hoping is that
> someone will tell me that there *is* enumerated type support in AS (even
> C style would be okay), and I just didn't know where to look to find the
> syntax.
>
> Anyone got any comments at all on the subject?

Would you consider declaring apple, orange and banana as properties with
integer values at the top of the script? Since apple, orange and banana are
not pre-defined by AppleScript, surely you have to declare their values
yourself? (I know, for example, that in VBA all pre-defined 'enumerated'
constants really are 'enumerated': they always have have a 'long' numerical
value.)

property apple : 1
property orange : 2
property banana : 3


set fruit to apple
eat(fruit)


on eat(food)
if food = apple
display dialog "Not bad but a bit mealy"
else if food = banana
display dialog "I fling feces at you."
else if food = orange
display dialog "Ah! Refreshing!"
end if
end eat





--
Paul Berkowitz
_______________________________________________
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: 
 >enumerated types: best way to fake them? (From: email@hidden (Michael Sullivan))

  • Prev by Date: Re: Parsing comments from HTML...
  • Next by Date: Re: enumerated types: best way to fake them?
  • Previous by thread: enumerated types: best way to fake them?
  • Next by thread: Re: enumerated types: best way to fake them?
  • Index(es):
    • Date
    • Thread