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 aTables(1) = '' && holds list of public variables to release in DESTROY() cAlias = '' && holds public variable to release in DESTROY() INIT() lparameters tcAlias ** create public variable to store Primary Keys edited in view cAliasVar = 'gcView' + tcAlias public &cAliasVar(1) ** store public variable name so DESTROY() can release this.cAlias = cAliasVar for each cTable in cursorgetprop('Tables') cTemp = 'gcTable' + cTable ** store name of view associated with Table ** so validation() can find it public &cTemp &cTemp = tcAlias ** store public variable name so DESTROY() can release add row(n) to this.aAlias this.aAlias(n) = cTemp endfor DESTROY() release &this.cAlias for each cTable in this.aTables release &cTable endfor ENDDEFINE
FIELD VALIDATION RULE cTableVar = 'gcTable' + alias() && public variable associated with Table cViewVar = 'gcView' + alias() && public variable associated iwth View Do Case case type(cViewVar) = 'C' ** Editing View ** store list of Primary Keys edited if ascan(cView,<Primary Key Value>) = 0 add row(n) to &cView &cView(n) = <Primary Key Value> endif case type(cTableVar) = 'C' ** Editing Table ** get name of public variable containing list of Primary Keys edited cView = cTableVar if ascan(cView,<Primary Key Value>) <> 0 ** already edited in view return .t. endif cView = 'gcView' + cViewAlias && View associated with Table Do Case Case type(cView) = 'C' Case type(cTable) = 'C' EndCase <rest of field validation> .....