dbTalk Databases Forums  

VFP 6: Name Substitution

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss VFP 6: Name Substitution in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gene Wirchenko
 
Posts: n/a

Default VFP 6: Name Substitution - 09-13-2004 , 05:01 PM






If a is an object and b is the name of a property or column, what
is the best way of accessing the property/column?

I was using
a.&b
but tried to use name substitution, namely
a.(b)
The former works, but the latter does not. What is the correct way
for using name substitution here?

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.

Reply With Quote
  #2  
Old   
Eric Selje
 
Posts: n/a

Default Re: VFP 6: Name Substitution - 09-13-2004 , 06:35 PM






How about this:

To get the value of the property/column:

? eval("a."+b)

To set the value of the property:

STORE (value) TO ("a."+b)
NOTE: ("a."+b) = (value) doesn't work. Interesting "feature" of the ol'
STORE command.

To assign a value to a column:

REPLACE ("a."+b) WITH (value)

Hope this helps,

Eric



Gene Wirchenko wrote:
Quote:
If a is an object and b is the name of a property or column, what
is the best way of accessing the property/column?

I was using
a.&b
but tried to use name substitution, namely
a.(b)
The former works, but the latter does not. What is the correct way
for using name substitution here?


Reply With Quote
  #3  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: VFP 6: Name Substitution - 09-14-2004 , 10:08 AM



Eric Selje <eric_selje (AT) vid (DOT) uscourts.gov> wrote:

Quote:
How about this:

To get the value of the property/column:

? eval("a."+b)

To set the value of the property:

STORE (value) TO ("a."+b)
NOTE: ("a."+b) = (value) doesn't work. Interesting "feature" of the ol'
STORE command.

To assign a value to a column:

REPLACE ("a."+b) WITH (value)

Hope this helps,
That is horribly ugly. I will stick with
a.&b
Why does
a.(b)
not work? I can not see a reason why it should not work. It is
consistent with other uses of ().

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #4  
Old   
Jack Jackson
 
Posts: n/a

Default Re: VFP 6: Name Substitution - 09-14-2004 , 11:43 AM



On Tue, 14 Sep 2004 08:08:38 -0700, Gene Wirchenko
<genew (AT) mail (DOT) ocis.net> wrote:

Quote:
Eric Selje <eric_selje (AT) vid (DOT) uscourts.gov> wrote:

How about this:

To get the value of the property/column:

? eval("a."+b)

To set the value of the property:

STORE (value) TO ("a."+b)
NOTE: ("a."+b) = (value) doesn't work. Interesting "feature" of the ol'
STORE command.

To assign a value to a column:

REPLACE ("a."+b) WITH (value)

Hope this helps,

That is horribly ugly. I will stick with
a.&b
Why does
a.(b)
not work? I can not see a reason why it should not work. It is
consistent with other uses of ().
I don't see it as consistent with other uses. All of the other uses
that I am aware of have the () replacing a single text string (e.g.
REPLACE (abc) ...) in a command. In this case you want to replace
part of a syntactic expression that can occur almost anywhere
including in expressions.

It would make expressions be a little strange. a = (b).c would use
replacement but a = (b) would not. Parentheses would have two
meanings in expressions which might be confusing.



Reply With Quote
  #5  
Old   
Eric Selje
 
Posts: n/a

Default Re: VFP 6: Name Substitution - 09-14-2004 , 12:06 PM



Hello Gene,

I guess beauty is in the eye of the programmer. I cringe when I see
macro substitution because I think "performance penalty." I think this
was justified a few years back with some testing.

Eric

Gene Wirchenko wrote:

Quote:
That is horribly ugly. I will stick with
a.&b
Why does
a.(b)
not work? I can not see a reason why it should not work. It is
consistent with other uses of ().

Reply With Quote
  #6  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: VFP 6: Name Substitution - 09-14-2004 , 05:55 PM



[reordered to chronological]

Eric Selje <eric_selje (AT) vid (DOT) uscourts.gov> wrote:

Quote:
Gene Wirchenko wrote:

That is horribly ugly. I will stick with
a.&b
Why does
a.(b)
not work? I can not see a reason why it should not work. It is
consistent with other uses of ().

I guess beauty is in the eye of the programmer. I cringe when I see
macro substitution because I think "performance penalty." I think this
was justified a few years back with some testing.
It is. I am thinking of the other performance penalty, the one
that involves the programmers having to look at the code. It is much
quicker to check something like
a.&b
than the other constructs that I have seen posted in this thread.

Given the choice of something that runs fast and is a bear to
verify and something that can be easily verified but runs more slowly,
I will generally go for the second. Correct answers trump incorrect
answers.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #7  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: VFP 6: Name Substitution - 09-14-2004 , 05:55 PM



Jack Jackson <jacknospam (AT) pebbleridge (DOT) com> wrote:

Quote:
On Tue, 14 Sep 2004 08:08:38 -0700, Gene Wirchenko
genew (AT) mail (DOT) ocis.net> wrote:
[snip]

Quote:
That is horribly ugly. I will stick with
a.&b
Why does
a.(b)
not work? I can not see a reason why it should not work. It is
consistent with other uses of ().

I don't see it as consistent with other uses. All of the other uses
that I am aware of have the () replacing a single text string (e.g.
REPLACE (abc) ...) in a command. In this case you want to replace
Not a text string -- that would be & -- but a name. It is called
name substitution. My proposed usage is a name being substituted.

Quote:
part of a syntactic expression that can occur almost anywhere
including in expressions.
No, only a name. If I want arbitrary substitution, I can use &.

Quote:
It would make expressions be a little strange. a = (b).c would use
replacement but a = (b) would not. Parentheses would have two
meanings in expressions which might be confusing.
Parentheses have two meanings *now*: ordering of operations and
subscripting. Are you confused? I suspect no.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #8  
Old   
Fred Taylor
 
Posts: n/a

Default Re: VFP 6: Name Substitution - 09-15-2004 , 02:41 AM




"Gene Wirchenko" <genew (AT) mail (DOT) ocis.net> wrote in message

Quote:
Given the choice of something that runs fast and is a bear to
verify and something that can be easily verified but runs more slowly,
I will generally go for the second. Correct answers trump incorrect
answers.
Absolute truth in programming:

Cheap, fast, accurate. Pick two.

Fred
Microsoft Visual FoxPro MVP




Reply With Quote
  #9  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: VFP 6: Name Substitution - 09-15-2004 , 09:20 PM



"Fred Taylor" <ftaylor (AT) mvps (DOT) org!REMOVE> wrote:

Quote:
"Gene Wirchenko" <genew (AT) mail (DOT) ocis.net> wrote in message

Given the choice of something that runs fast and is a bear to
verify and something that can be easily verified but runs more slowly,
I will generally go for the second. Correct answers trump incorrect
answers.

Absolute truth in programming:

Cheap, fast, accurate. Pick two.
Quite. Note that correct is per the spec and not in an absolute
sense. If three digits of precision is good enough, then getting the
correct three digits satisfies the correctness requirement. (Imagine
simulating a slide rule.)

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.