Sign in to follow this  
devronious

[.net] help with general question...

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this