Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Field name != variable name?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00100420
Message ID:
00100476
Views:
42
>I put this in chatter because I've already found the solution, but I'm curious why it was a problem in the first place.
>
>I have the following code:
>
>public clname
>clname = ""
>public cfname
>cfname = ""
>
>Clname = left(newname,at(",", newname)-1)
>Cfname = right(newname,len(newname)-at(",", newname)-1)
>
>select 0
>use (bal_file) alias bal
>select bal
>
>scan for alltrim(bal.client_num) = alltrim(ClNum)
> replace bal.lname with Clname
> replace bal.fname with Cfname
>endscan
>
>(newname comes in to the program as a parameter, and bal_file is defined earlier)
>
>It splits up newname into clname and cfname just fine according to a messagebox. But when I open the bal file, it _changes_ the value of those two variables to a completely different name! I went round and round with it, with no clue why it should be changing the variables when I didn't tell it to. Finally, in desperation, I changed the variable names. That did it.
>
>The best I can figure out is it thinks clname and cfname are equivilent to the field names bal.lname and bal.fname. So when I open the bal file, it fills in the global variables with the fields it finds there in the first record.
>
>But why? lname != clname. This doesn't make sense.
>
>My solution was to change the variables to cl and cf. That fixed it, but it's still got me baffled as to why it happened in the first place.
>
>Thanks,

Are you sure you haven't got fields called "clname" and "cfname". When I first started at this company, I was dumped with some progs using vars that matched field names - grew me some more gray hairs with that. Fox looks for fields before vars.
Nigel B Coates
NBC Software Services
Dublin, Ireland.
eMail: Nigel.Coates@NBCSoftware.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform