From b18aa20d0ac43f3ecb76ee83f13047046830b265 Mon Sep 17 00:00:00 2001 From: dmcoles Date: Wed, 3 Jul 2024 17:54:01 +0100 Subject: [PATCH] add missing file --- validator.e | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 validator.e diff --git a/validator.e b/validator.e new file mode 100644 index 0000000..b692ac5 --- /dev/null +++ b/validator.e @@ -0,0 +1,41 @@ +OPT MODULE, OSVERSION=37 + + MODULE 'intuition/gadgetclass' + + MODULE '*reactionObject','*reactionForm','*stringlist','*dialogs' + +//access to main rebuild object list +EXPORT DEF objectList:PTR TO stdlist + + +EXPORT PROC checkIdent(form:PTR TO reactionForm, editComp:PTR TO reactionObject, id) + DEF str:PTR TO CHAR + DEF comp:PTR TO reactionObject + DEF i + str:=Gets(form.gadgetList[ id ],STRINGA_TEXTVAL) + + IF StrLen(str)=0 + errorRequest(form.windowObj,'Error','The identifer cannot be blank') + RETURN FALSE + ENDIF + + FOR i:=0 TO StrLen(str)-1 + IF (str[i]==["_","a" TO "z","A" TO "Z","0" TO "9"])=FALSE + errorRequest(form.windowObj,'Error','The identifer is not valid (A-Z, 0-9 and _)') + RETURN FALSE + ENDIF + ENDFOR + + IF objectList + FOR i:=0 TO objectList.count()-1 + comp:=objectList.item(i) + IF comp + IF StrCmp(comp.ident,str) AND (editComp<>comp) + errorRequest(form.windowObj,'Error','The identifer is already used') + RETURN FALSE + ENDIF + ENDIF + ENDFOR + ENDIF + +ENDPROC TRUE