When Clause behavior of GET
Posted: Wed Aug 22, 2007 11:34 am
Dear All,
I am facing a typical problem regarding When clause of GET. Whenever I am getting focus for a GET, When clause of all the GET of that Dialog gets executed. Is that normal behavior ? If so, how to avoid that ?
My problem is I am recalculating subsequent GETs based on the value of a GET. But I wish to program it such a way that user can override the default calculation done by When clause.
Following is a self containing sample.
TIA
Milan.
-------------------------------------------Cut----------------------------
#include "FiveWin.ch"
#define ETVAR1 101
#define ETVAR2 102
#define ETVAR3 103
#define ETVAR4 104
#define PBOK 105
function Main()
Local oDlg, oVar1, oVar2, oVar3, oVar4
LOCAL nVar1, nVar2, nVar3, nVar4
nVar1 := nVar2 := nVar3 := nVar4 := 0
DEFINE DIALOG oDlg TITLE "Test Update Dialog" RESOURCE "Test"
REDEFINE GET oVar1 VAR nVar1 ID ETVAR1 PICTURE "999999.99" OF oDlg;
VALID {|| nVar2 := nVar1 * 0.125/100, nVar3 := nVar1 * 0.010/100, nVar4 := nVar1 * 0.07/100, .T.}
REDEFINE GET oVar2 VAR nVar2 ID ETVAR2 PICTURE "999999.99" OF oDlg
// WHEN {|| nVar2 := nVar1 * 0.125/100, .T.}
REDEFINE GET oVar3 VAR nVar3 ID ETVAR3 PICTURE "999999.99" OF oDlg WHEN {|| MsgInfo ('When of Var3'), .T.} VALID {|| MsgInfo ('Valid of Var3'), .T.}
REDEFINE GET oVar4 VAR nVar4 ID ETVAR4 PICTURE "999999.99" OF oDlg WHEN {|| MsgInfo ('When of Var4'), .T.}
REDEFINE BUTTON ID PBOK ACTION oDlg:End()
ACTIVATE DIALOG oDlg
return nil
-------------------------------------------Paste--------------------------
RC file.
--------------------------------------------Cut---------------------------
#define ETVAR1 101
#define ETVAR2 102
#define ETVAR3 103
#define ETVAR4 104
#define PBOK 105
TEST DIALOG 6, 15, 260, 167
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
CAPTION "Dialog Update"
FONT 8, "MS Sans Serif"
{
EDITTEXT ETVAR1, 64, 20, 49, 18
EDITTEXT ETVAR2, 64, 43, 48, 18
EDITTEXT ETVAR3, 64, 68, 49, 18
EDITTEXT ETVAR4, 64, 97, 51, 18
PUSHBUTTON "Ok", PBOK, 78, 135, 50, 14
}
-------------------------------------------Paste--------------------------
I am facing a typical problem regarding When clause of GET. Whenever I am getting focus for a GET, When clause of all the GET of that Dialog gets executed. Is that normal behavior ? If so, how to avoid that ?
My problem is I am recalculating subsequent GETs based on the value of a GET. But I wish to program it such a way that user can override the default calculation done by When clause.
Following is a self containing sample.
TIA
Milan.
-------------------------------------------Cut----------------------------
#include "FiveWin.ch"
#define ETVAR1 101
#define ETVAR2 102
#define ETVAR3 103
#define ETVAR4 104
#define PBOK 105
function Main()
Local oDlg, oVar1, oVar2, oVar3, oVar4
LOCAL nVar1, nVar2, nVar3, nVar4
nVar1 := nVar2 := nVar3 := nVar4 := 0
DEFINE DIALOG oDlg TITLE "Test Update Dialog" RESOURCE "Test"
REDEFINE GET oVar1 VAR nVar1 ID ETVAR1 PICTURE "999999.99" OF oDlg;
VALID {|| nVar2 := nVar1 * 0.125/100, nVar3 := nVar1 * 0.010/100, nVar4 := nVar1 * 0.07/100, .T.}
REDEFINE GET oVar2 VAR nVar2 ID ETVAR2 PICTURE "999999.99" OF oDlg
// WHEN {|| nVar2 := nVar1 * 0.125/100, .T.}
REDEFINE GET oVar3 VAR nVar3 ID ETVAR3 PICTURE "999999.99" OF oDlg WHEN {|| MsgInfo ('When of Var3'), .T.} VALID {|| MsgInfo ('Valid of Var3'), .T.}
REDEFINE GET oVar4 VAR nVar4 ID ETVAR4 PICTURE "999999.99" OF oDlg WHEN {|| MsgInfo ('When of Var4'), .T.}
REDEFINE BUTTON ID PBOK ACTION oDlg:End()
ACTIVATE DIALOG oDlg
return nil
-------------------------------------------Paste--------------------------
RC file.
--------------------------------------------Cut---------------------------
#define ETVAR1 101
#define ETVAR2 102
#define ETVAR3 103
#define ETVAR4 104
#define PBOK 105
TEST DIALOG 6, 15, 260, 167
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
CAPTION "Dialog Update"
FONT 8, "MS Sans Serif"
{
EDITTEXT ETVAR1, 64, 20, 49, 18
EDITTEXT ETVAR2, 64, 43, 48, 18
EDITTEXT ETVAR3, 64, 68, 49, 18
EDITTEXT ETVAR4, 64, 97, 51, 18
PUSHBUTTON "Ok", PBOK, 78, 135, 50, 14
}
-------------------------------------------Paste--------------------------