Assigning table field to table field

aquafish

New Member
Hoping someone can help me understand why the following code does not work as I expect.

When the line Table1.Field1 = Table1.Field1 gets executed, the Table1.Field1 Integer value gets set to 12, which corresponds to the initial value set up for this field in the database schema. However, what I was trying to do is explicitly state that Field1 value should remain unchanged.

==================
Find Table1 where recid(Table1) = inputRecID exclusive-lock no-error.

If available Table1 then
do:
assign Table1.Field1 = If inputField <> 0 then Table1.Field1 = inputField
else Table1.Field1 = Table1.Field1
...
end.
===================
Issue is that if
 
Please ignore this thread.

The line "Table1.Field1 = Table1.Field1" was not being executed after all.

inputField was actually set to 12 as the variable was declared as "LIKE TABLE1.FIELD1". This meant that it's value was automatically being set to the schema default of 12 despite the fact that my program was not pogrammatically assigning inputField a value.
 
I suppose you have also realized that the else clause was unnecessary since all it is doing is leaving the value as it was.
 
Thanks Tamhas. I did contemplate why this was coded as so. I just thought they wanted to make it very obvious what was happening but you're right it seems such a waste.
 
Back
Top