Table C(30) Order I Rule M Message M Comments M Level N(1)And here is the function:
********************************************************************** FUNCTION RecordValid(tcTableName, llEvaluateAllRules) * Record validation. * Meant to be invoked from form.valid(<tablename>). * Can also be invoked from other places, for instance, triggers. tcTableName = lower(tcTableName) * save and change settings local lnOldAlias, lcOldExact lnOldAlias = select() lcOldExact = set("exact") set exact off * open validation table if used("validation") select validation else select 0 use validation again endif set order to "mainorder" * evaluate all errors defined in rules table local lcErrorText, llError lcErrorText = "" tcTableName = padr(tcTableName, len(Table)) seek tcTableName scan while table = tcTableName select (lnOldAlias) if not evaluate(validation.rule) * Adv. means warning. lcErrorText = lcErrorText + iif(validation.warning, "Adv.: ", "Err.: ") + validation.spanish if not validation.warning llError = .T. endif if llEvaluateAllRules lcErrorText = lcErrorText + chr(13) else exit endif endif select validation endscan * show error message if not empty(lcErrorText) * "Can't save", "Warning when saving", * "Changes saved", "Error saving", "Warning saving" MessageBox(iif(llError, "No se pudo grabar:", "Advertencia al grabar:") + chr(13) + chr(13); + lcErrorText + iif(llError, "", chr(13) + "Se grabaron los cambios."),; 16, iif(llError, "Error al grabar", "Advertencia al grabar")) endif * restore environment and return success status use in validation select (lnOldAlias) set exact &lcOldExact return not llError ENDFUNC