Help on saving object/variable names and values for later recall 
Author Message
 Help on saving object/variable names and values for later recall

Would someone point me in the right direction.  I want to save
object/variables and their current values to a file, but just cannot seem to
figure out the right approach.

I've saved data in a sequential file in the form of  two fields - the object
name and it's value  e.g. :

"Text1", 98,123
"Text2 ,  22,143

But when I open the file, how can I get this to result in restoring the
values to the name as Text1=98,123 and Text2=22,143.

My apologies for such a simple question, but I'm stuck in no man's land.



Sat, 22 Sep 2001 03:00:00 GMT  
 Help on saving object/variable names and values for later recall

Quote:

> Would someone point me in the right direction.  I want to save
> object/variables and their current values to a file, but just cannot seem to
> figure out the right approach.

> I've saved data in a sequential file in the form of  two fields - the object
> name and it's value  e.g. :

> "Text1", 98,123
> "Text2 ,  22,143

> But when I open the file, how can I get this to result in restoring the
> values to the name as Text1=98,123 and Text2=22,143.

Hi,

Loop through the controls collection, check the controls name and assign the
value

i.e.

   for c=0 to me.controls.count-1
     if me.controls(c).name=TheName then
         me.controls(c).text=TheValue
     endif
   next

Michaela



Mon, 24 Sep 2001 03:00:00 GMT  
 Help on saving object/variable names and values for later recall
Michaela

A note of caution here. Your solution leads to saving the data in the same
way. Unfortunately, the system isn't then future-proof. If, for example, the
textbox txtOutsandingBalance is later renamed as txtOutstandingBalance (for
obvious reasons), any files saved before the change become useless.

A better way is to use logical names which will not change. These names
should be set up as constants which are used in the input and output
procedures. The purpose of the data is what's important.

--
Regards
{*filter*}

Remove '!no!spam!' to reply by e-mail.

Quote:


>> Would someone point me in the right direction.  I want to save
>> object/variables and their current values to a file, but just cannot seem
to
>> figure out the right approach.

>> I've saved data in a sequential file in the form of  two fields - the
object
>> name and it's value  e.g. :

>> "Text1", 98,123
>> "Text2 ,  22,143

>> But when I open the file, how can I get this to result in restoring the
>> values to the name as Text1=98,123 and Text2=22,143.

>Hi,

>Loop through the controls collection, check the controls name and assign
the
>value

>i.e.

>   for c=0 to me.controls.count-1
>     if me.controls(c).name=TheName then
>         me.controls(c).text=TheValue
>     endif
>   next

>Michaela



Mon, 24 Sep 2001 03:00:00 GMT  
 Help on saving object/variable names and values for later recall

Quote:

> Michaela

> A note of caution here. Your solution leads to saving the data in the same
> way. Unfortunately, the system isn't then future-proof. If, for example, the
> textbox txtOutsandingBalance is later renamed as txtOutstandingBalance (for
> obvious reasons), any files saved before the change become useless.

> A better way is to use logical names which will not change. These names
> should be set up as constants which are used in the input and output
> procedures. The purpose of the data is what's important.

I'm not responsible for anyone changing his/hers program ;-) ;-)

Of course you can also assign a 'keyword' to the tag-property.

 i.e.
       if me.controls(c).tag=keyword then

Michaela



Mon, 24 Sep 2001 03:00:00 GMT  
 Help on saving object/variable names and values for later recall
Michaela

Quote:

>I'm not responsible for anyone changing his/hers program ;-) ;-)

Interesting point. I strongly disagree.

If I was maintaining a program with a TextBox whose name I thought was
inappropriate, I would feel free to change its name (and all references to
it within the form) since it is a local item. I would never expect an
external reference to it (that's what interface properties and methods are
for). By storing its name on a file, you have, effectively, made an external
reference to it.

If, however, I saw some constants which were used in the input and output
procedures, I would think carefully about changing them.

--
Regards
{*filter*}

Remove '!no!spam!' to reply by e-mail.

Quote:


>> Michaela

>> A note of caution here. Your solution leads to saving the data in the
same
>> way. Unfortunately, the system isn't then future-proof. If, for example,
the
>> textbox txtOutsandingBalance is later renamed as txtOutstandingBalance
(for
>> obvious reasons), any files saved before the change become useless.

>> A better way is to use logical names which will not change. These names
>> should be set up as constants which are used in the input and output
>> procedures. The purpose of the data is what's important.

>I'm not responsible for anyone changing his/hers program ;-) ;-)

>Of course you can also assign a 'keyword' to the tag-property.

> i.e.
>       if me.controls(c).tag=keyword then

>Michaela



Mon, 24 Sep 2001 03:00:00 GMT  
 Help on saving object/variable names and values for later recall
Interesting debate... and I appreciate both of your replies.  For this
purpose the textbox names will be changed in the app,  I simply used the
default names to illustrate my problem (including the dead brain cells I
possess).   Looping through the controls, although as pointed out could be
problematic if I change the program, it will work fine this way....

Thanks for all of the advice.... and no, I won't hold anyone responsible <s>


Quote:
> Michaela

> >I'm not responsible for anyone changing his/hers program ;-) ;-)

> Interesting point. I strongly disagree.



Mon, 24 Sep 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Help changing an object's name via a variable's value

2. Need value of object where object name is variable

3. declare the value from a variable as a object name

4. CHOOSECOLOR - storing lpCustColors for later recall

5. The value of a variable (String type) is the name of a variable

6. Variable Name to Variable value.

7. DateTimePicker -Manually entered value Not Saved less than 5 seconds later

8. Variable values as variable names

9. converting an object variable (name of a file) into a string variable

10. Need help saving OLE Object field value to a file on disk

11. variable in place of object name Help?

12. Storing Listbox values in tables and recalling

 

 
Powered by phpBB® Forum Software