Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replacing value in Grid
Message
From
28/07/2023 06:32:00
 
 
To
26/07/2023 12:34:49
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01686818
Message ID:
01686874
Views:
38
>>>2. REPLACE YourColumn WITH SomeValue IN YourTable -&& Put this code there where you want to update cursor
>>
>>needs the "for empty(YourColumn)" at least (which takes care of the implicit "!IsNull/YourColumn)" of if)
>>
>>IMO code not caring for record pointer move (same as in orig code) is bad style.
>>Therefore I'd opt for SQL - update and second line moving record pointer explicit if really intended,
>>(Or at least comments, why implicit record pointer move of replace kine is intended)
>>
>>Not going into record/table lock as _tally/Reccount of grid cursor probably small to make it irrelavant
>>
>>my .22€
>>thomas
>
>There is NO need of FOR after REPLACE, WHY you need this?
>If I want to replace data in the current record of the cursor the I just replace it

Because the original command invluded it
lcReplaceCmd = 'REPLACE ' + lcControlSource + ' IN (lcCursorName) WITH (lcNewValue) ;
    FOR RECNO() = lnRow AND EMPTY(EVAL("' + lcControlSource + '"))'.
* lcReplaceCmd resolves to a sting housing cmd
* REPLACE FI.REF  IN (lcCursorName) WITH (lcNewValue) ;FOR RECNO() = lnRow AND EMPTY(EVAL("FI.REF"))
*-- equal to
* REPLACE FI.REF  IN (lcCursorName) WITH (lcNewValue) ;FOR RECNO() = lnRow AND EMPTY(FI.REF)
so only empy values are to be replaced in original code.
#
That code is bracketed by an
IF VARTYPE(EVAL(lcControlSource)) = "C"  
&& Check if the field is a string (character)which only fails on record level,
which blocks only when that particular record has .null. in FI.REF
any field type check on table level should be done only once / earlier / not on each record,
so that line is probably as garbage as
IF USED(lcCursorName) AND !EMPTY(lcCursorName) AND TYPE("lcCursorName") = "C"
as testing type after accessing it with use makes no sense at all.

regards
thomas
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform