enum equivalent?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
2hup
Posts: 24
Joined: Tue Nov 17, 2015 8:03 pm

enum equivalent?

Post by 2hup » Wed Nov 18, 2015 3:35 pm

Hello LiveCoders,
I haven't found anything in documents or here that talks about enumerations in LiveCode. Am I missing something?

Thanks,
Brad

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: enum equivalent?

Post by dunbarx » Wed Nov 18, 2015 4:27 pm

Hi.

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

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: enum equivalent?

Post by FourthWorld » Wed Nov 18, 2015 5:09 pm

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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

2hup
Posts: 24
Joined: Tue Nov 17, 2015 8:03 pm

Re: enum equivalent?

Post by 2hup » Wed Nov 18, 2015 5:35 pm

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.

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: enum equivalent?

Post by MaxV » Tue Dec 01, 2015 6:00 pm

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.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: enum equivalent?

Post by dunbarx » Tue Dec 01, 2015 6:14 pm

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

2hup
Posts: 24
Joined: Tue Nov 17, 2015 8:03 pm

Re: enum equivalent?

Post by 2hup » Thu Dec 03, 2015 8:27 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: enum equivalent?

Post by dunbarx » Thu Dec 03, 2015 9:38 pm

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

Post Reply