Page 1 of 1

enum equivalent?

Posted: Wed Nov 18, 2015 3:35 pm
by 2hup
Hello LiveCoders,
I haven't found anything in documents or here that talks about enumerations in LiveCode. Am I missing something?

Thanks,
Brad

Re: enum equivalent?

Posted: Wed Nov 18, 2015 4:27 pm
by dunbarx
Hi.

Do you mean the ordering of elements of a defined set?

Craig Newman

Re: enum equivalent?

Posted: Wed Nov 18, 2015 5:09 pm
by FourthWorld
LiveCode does not currently include an enum function. In fact, thinking back on all the other tools I've used in this family of languages I can only recall one, SuperCard, that had an enum function.

But I'll bet we can write one for you easily enough. What would you like to do with it?

Re: enum equivalent?

Posted: Wed Nov 18, 2015 5:35 pm
by 2hup
dunbarx wrote:Hi.

Do you mean the ordering of elements of a defined set?

Craig Newman

Basically just looking for an object type with a defined a set of constants that I can use to track different things, like application state. Not a deal breaker for me, but this kind of functionality helps. I am a C/C# developer, and use enums for lots of different things.

Re: enum equivalent?

Posted: Tue Dec 01, 2015 6:00 pm
by MaxV
Hi 2hup,
an enum is like a button of type option.
Probably you should see custom properties, setprop, and getprop.
However you can use any list, array, or comma defined list in the same way of an enum.

Re: enum equivalent?

Posted: Tue Dec 01, 2015 6:14 pm
by dunbarx
Now I am confused.
an enum is like a button of type option.
2Hup, can you give an example of what you are trying to do? Is it object functionality, or language functionality?

Craig

Re: enum equivalent?

Posted: Thu Dec 03, 2015 8:27 pm
by 2hup
Sorry for the delay in this response - I have been working on other projects for a bit.

I hope this is not insulting. I am a c# developer, so here is a reference link, in case you are not familiar with this concept.
http://www.dotnetperls.com/enum

I use this data type for a lot of different things, but it is basically a set of values that are defined. When an object of this type is instantiated, the developer, or user(if exposed to the user) can only set the value to what is in the pre-defined set.

Hope that helps.

Re: enum equivalent?

Posted: Thu Dec 03, 2015 9:38 pm
by dunbarx
Hi.

If you are talking about a fixed, accessible one-to-one correspondence among elements of some kind in a data set of some kind, there are several ways to accomplish this. Arrays, custom properties and others come to mind. Mind you, LC is typeless, though I bet this will not matter at all.

But do you have enough experience with LC to give a more concrete example of what you are looking for?

Craig