[.net] help with general question...
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
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; ?
Do you want to do something like:
Gedcom.Header.StringValue = Gedcom.Header.Value; ?
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?
"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?
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#. :(
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#. :(
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement