General information
Title:
Field name != variable name?
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,
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only