Jump to content
  • Advertisement
Sign in to follow this  
devronious

[.net] help with general question...

This topic is 4620 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to set a value to an int variable located at Gedcom.Header.Value ie: Gedcom.Header.Value = 1; But I need the location to change to set other values using the same prefix, ie: Gedcom.Header.StringValue = "0"; The question is this, how do I use the root Gedcom.Header and combine it with different endings ie: .Value and .StringValue to set each fields value? I thought maybe I could put the composite location in strings like this: "Gedcom.Header" + ".StringValue" and "Gedcom.Header" + ".Value" But I don't know how to use the string to set the values of each. Thanks in advance, Devin

Share this post


Link to post
Share on other sites
Advertisement
sooo what language are you using? And I dont get what your asking exactly...
Do you want to do something like:
Gedcom.Header.StringValue = Gedcom.Header.Value; ?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
using c#. What I'm trying to do is set a value in a class using a string as the address ie:

"Gedcom.Header.Value" = 1;

But of course the string "Gedcom.Header.Value" does not point to the location of Gedcom.Header.Value and thus wont set it's value to 1 like the following would:

Gedcom.Header.Value = 1;

So how can I tell the compiler that the string represents a .Net address?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I'm using a data file to tell me where the values are.

Share this post


Link to post
Share on other sites
make a std::map to map a string to a location:
map<string, int *> my_map;
my_map["Gedcom.Header.Value"] = &Gedcom.Header.Value;

then you can apply a value to a location:
*(my_map["Gedcom.Header.Value"]) = 1;

The only drawback to this is that one map can only store pointers to one type of data. So, you still have
a slight problem of needing several maps for your integers, strings and such. In wich case you may want to
have a look at "dators" to store your data.

A dator will always take a string input to set the value, but a dator is linked to a static variable of another
type, and automagically converts your strings to the proper type. But, I don't have any code for setting
this up in C#. :(

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks, I like the map technique!

-Devin

p.s. Muhammad, I'm using it in a directX app?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!