********************************************************************** 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) llEvaluateAllRules = .T. && Override second parameter. * 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 if Level = "I" && Ignore loop endif select (lnOldAlias) if not evaluate(validation.rule) lcErrorText = lcErrorText + iif(Validation.Level = "W", "Advertencia: ", "Error: ") + Validation.Spanish if not Validation.Level = "W" llError = .T. endif if llEvaluateAllRules lcErrorText = lcErrorText + chr(13) else exit endif endif select validation endscan * show error message if not empty(lcErrorText) if llError * MessageBox("Can't save"... "Error on save") MessageBox("No se pudo guardar:" + chr(13) + chr(13) + lcErrorText,; 16, "Error al guardar") else llError = MessageBox("Warning on save:" + ... "save anyway?") llError = MessageBox("Advertencia al guardar:" + chr(13) + chr(13) + lcErrorText; + chr(13) + "¿Quiere guardar de todos modos?",; 4 + 48 + 256, "Advertencia al guardar") # 6 endif endif * restore environment and return success status use in validation select (lnOldAlias) set exact &lcOldExact return not llError ENDFUNC