Question Something like ENUM but dynamic

morogg

New member
Joined
Apr 25, 2013
Messages
3
Programming Experience
3-5
Hi all,
I have a problem that bother me and I wonder if I can get some sugestions here!
I have to build a dll which will expose some functions to users! I have to use for some of the functions parameters some guidance for users( like ENUM does), in order to remove inserting wrong data! ENUM is doing a perfect job in that matter but is no way to get dynamic data for that and rebuilding the dll each time a new value is inserted is not an option! The help that I need is if there is a way around or a different solution for that problem!

thank you for your time
 
f you don't know the values at compile time then you can't use an enumeration; it's that simple. If you have a dynamic list then you'll need to store the values externally, e.g. in an XML file or a database. You will then have to use type String or Integer for your parameters and validate the values based on your external list.
 
Thank you for your response, it is confirming what I thought, but, there is no other possibility to restrict user option when he has to insert an string or integer? Something that will appear before the function is launched, as in validation case? I search a lot for a solution and I believe there is not such possibility but, maybe someone has found an solution? :)
Thank you for your time!

PS: sorry for my english, not my mother language
 
If you're talking about the user making a selection in the UI then you can do as I said and store a list of options in a file or database and then load that data into the app, displaying the choices in a ComboBox or ListBox or the like. In your code though, you'll just be using Integers or Strings to represent the data; most likely a String name/description and an Integer ID.
 
morogg, how about you tell us more about what you're wanting your app to do and we'll guide you from there?
 
Well, I work on dll for logging errors! In the table I have some fields like Priority or Status, which, right now, have some clear values EX: Priority :id:1= description:Error / id:2= Description:Warning. etc.
What I need is when the programmer will use my dll functions not to be obliged to remember what id=1 means or what id is requested for status "Pending". The enum is perfect for that kind of stuff, i can expose function parameter as enum "priority" and let user to choose directelly "Warning" or " Information", but later modifications may occur in DB and recompiling the dll is not a very desired solution!

thanks for your time,
moro
 
Back
Top