>FORM > property aViews(1) > > INIT() > for each cursor in dataenvironment > if cursor is a view > ** store object reference for each view > add row(n) to this.aViews > this.aViews(n) = CreateObject('View_Validation',alias()) > endif > endfor > > DESTROY() > ** release all object references > this.aViews = .null > >ENDFORM >>
>DEFINE CLASS View_Validation as line > aVars(1) = '' && holds list of public variables to release in DESTROY() > > INIT() > lparameters tcAlias > > ** create public variable to store Primary Keys edited in view > cViewVar = 'gcView' + tcAlias > public &cViewVar(1) > > ** store public variable name so DESTROY() can release > this.aVars(1) = cViewVar > > for each cTable in cursorgetprop('Tables') > cTableVar = 'gcTable' + cTable > > ** store variable name of view associated with Table > ** so validation() can find it > public &cTableVar > &cTableVar = cViewVar > > ** store public variable name so DESTROY() can release > add row(n) to this.aVars > this.aVars(n) = cTableVar > endfor > > DESTROY() > for each cVar in this.aVars > release &cVar > endfor >ENDDEFINE >>
>FIELD VALIDATION RULE > cTableVar = 'gcTable' + alias() && public variable associated with Table > cViewVar = 'gcView' + alias() && public variable associated with View > > Do Case > case type(cViewVar) = 'C' > ** Editing View > ** store list of Primary Keys edited > if ascan(cViewVar,<Primary Key Value>) = 0 > add row(n) to &cViewVar > &cViewVar(n) = <Primary Key Value> > endif > case type(cTableVar) = 'C' > ** Editing Underlying Table > ** get name of variable containing list of Primary Keys edited > cViewVar = &cTableVar > > if ascan(cViewVar,<Primary Key Value>) <> 0 > ** already edited in view > return .t. > endif > EndCase > > <rest of field validation> > ..... >