Page 1 of 1

VALID and HIDE

Posted: Wed Jun 09, 2010 6:18 am
by gnewcomb
Can someone explain why after the execution of the valid in example 1 the focus is set on the appropriate Amount get, but in example 2 the focus remains on the Work Order Type get? After a second execution of the valid in example 2 the focus is set to the appropriate Amount get.

Code: Select all

// example 1
Procedure Main()

LOCAL GetList[0], GetOptions, cWorkOrderType, cValidType, nAmountA, nAmountB

DCGETOPTIONS AUTORESIZE

cWorkOrderType := cValidType := SPACE(1)
nAmountA := nAmountB := 0

@ 1,0 DCSAY 'Work Order Type' GET cWorkOrderType ;
   VALID {|| cWorkOrderType $ 'AB' }

@ 2,0 DCSAY 'Amount A' GET nAmountA ;
   HIDE {|| cWorkOrderType # 'A' }

@ 2,0 DCSAY 'Amount B' GET nAmountB ;
   HIDE {|| cWorkOrderType # 'B' }

DCREAD GUI FIT ADDBUTTONS OPTIONS GetOptions

RETURN

Code: Select all

// example 2
Procedure Main()

LOCAL GetList[0], GetOptions, cWorkOrderType, cValidType, nAmountA, nAmountB

DCGETOPTIONS AUTORESIZE

cWorkOrderType := cValidType := SPACE(1)
nAmountA := nAmountB := 0

@ 1,0 DCSAY 'Work Order Type' GET cWorkOrderType ;
   VALID {|| IIF( cWorkOrderType $ 'AB', ( cValidType := cWorkOrderType, .t. ), .f. ) }

@ 2,0 DCSAY 'Amount A' GET nAmountA ;
   HIDE {|| cValidType # 'A' }

@ 2,0 DCSAY 'Amount B' GET nAmountB ;
   HIDE {|| cValidType # 'B' }

DCREAD GUI FIT ADDBUTTONS OPTIONS GetOptions

RETURN

Re: VALID and HIDE

Posted: Wed Jun 09, 2010 7:21 am
by Tom
The VALID clause is evaluated before something happens to the second get and it's HIDE clause. This should work:
Procedure Main()

LOCAL GetList[0], GetOptions, cWorkOrderType, cValidType, nAmountA, nAmountB

DCGETOPTIONS AUTORESIZE

cWorkOrderType := cValidType := SPACE(1)
nAmountA := nAmountB := 0

@ 1,0 DCSAY 'Work Order Type' GET cWorkOrderType ;
VALID {|| IIF( cWorkOrderType $ 'AB', ( cValidType := cWorkOrderType, DC_GetRefresh(oObject),SetAppFocus(oObject), .t. ), .f. ) }

@ 2,0 DCSAY 'Amount A' GET nAmountA GETOBJECT oObject ;
HIDE {|| cValidType # 'A' }

@ 2,0 DCSAY 'Amount B' GET nAmountB ;
HIDE {|| cValidType # 'B' }

DCREAD GUI FIT ADDBUTTONS OPTIONS GetOptions

RETURN