Page 1 of 1

DCGET Valid condition

Posted: Mon Jan 10, 2022 8:50 am
by Maxz
In a particular GET sequence (typically the 1st) Is it possible to perform a validation only if the content of the variable has been modified?

@ DCGET var1 VALID {|| Check_Load() }
@ DCGET var2
@ DCGET var3
...

DCREAD GUI

function Check_Load
LOCAL lRet:=.F.
SEEK var1
IF FOUND()
load_data()
lRet:=.T.
ENDIF
RETURN lRet


if the first get of the sequence loads for example the data from a database record (using Valid clause), every time you confirm the last get of sequence, automatically you return to the first one by reloading all the data again (because VALID clause is performed always using ENTER key )

thanks

max

Re: DCGET Valid condition

Posted: Mon Jan 10, 2022 9:27 am
by Maxz
I've found this statement in Valid clause searching in Xsample1.prg:

VALID {|o| IIF(o:get:changed, Check_Load() ,.T.)}

Seems to work well.

Re: DCGET Valid condition

Posted: Tue Jan 11, 2022 1:28 am
by skiman
Hi,

Just for your information, If you want to avoid to return to the first get when you enter on the last, there is ENTEREXIT as an option for dcgetoptions.

Re: DCGET Valid condition

Posted: Tue Jan 11, 2022 3:06 am
by Maxz
from Express doc:
ENTEREXIT will exit the dialog if the ENTER key is pressed. The
exact behavior is determined by the DC_EnterExitMode() function.
The default behavior is to exit the dialog when the ENTER keys is
pressed in the "last GET"
. If this option is not used, then pressing
the ENTER key in the last GET will cause the first GET to receive
focus provided that SET WRAP is ON, otherwise pressing ENTER in the
last GET will have no affect.

my purpose is to keep the LOOP of the GETs but not validate the first GET, responsible for loading the data during its validation

if that function is enabled, I exit the sequence as soon as I press enter in the last input field