USED("&thetable") * is the same as USED(thetable) IF &thefield = .T. * is the same as IF EVAL(thefield) REPLACE &thefield WITH .T. * is the same as REPLACE (thefield) WITH .T.Also multiple related IF's could be replaced witd DO CASE ENDCASE
DO CASE CASE ISNULL(EVAL(thefield)) THIS.Value = "" CASE EVAL(thefield) THIS.Value = "Yes" CASE NOT EVAL(thefield) THIS.Value = "No" ENDCASE>>This shouldn't be so hard....
>DEFINE CLASS Yncombo AS Combobox > RowSourceType = 1 > RowSource = "Yes,No" > Style = 2 > FieldName = "" > TableName = "" > YesNoSource = "" > > PROCEDURE Init > LOCAL dotspot, thetable, thefield > > dotspot = AT(".",THIS.YesNoSource) > > STORE LEFT(THIS.YesNoSource,(dotspot - 1)) TO THIS.TableName > STORE SUBSTR(THIS.YesNoSource,(dotspot + 1)) TO THIS.FieldName > > STORE THIS.TableName TO thetable > STORE THIS.FieldName TO thefield > > IF USED("&thetable") > IF &thefield = .T. > THIS.Value = "Yes" > ENDIF > > IF &thefield = .F. > THIS.Value = "No" > ENDIF > > IF ISNULL(&thefield) > THIS.Value = "" > ENDIF > ELSE > THIS.Value = "" > ENDIF > ENDPROC > > PROCEDURE Valid > LOCAL thetable, thefield > > STORE THIS.TableName TO thetable > STORE THIS.FieldName TO thefield > > IF NOT EMPTY(THIS.DisplayValue) > IF NOT USED("&thetable") > MESSAGEBOX("The Yes/No Combobox data source is not open.") > THIS.DisplayValue = "" > RETURN > ENDIF > ENDIF > > IF THIS.DisplayValue = "Yes" > REPLACE &thefield WITH .T. > ENDIF > > IF THIS.DisplayValue = "No" > REPLACE &thefield WITH .F. > ENDIF > > IF EMPTY(THIS.DisplayValue) > REPLACE &thefield WITH .F. > ENDIF > ENDPROC >ENDDEFINE >