-
Notifications
You must be signed in to change notification settings - Fork 3
/
validator.e
49 lines (39 loc) · 1.35 KB
/
validator.e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
OPT MODULE, OSVERSION=37
MODULE 'intuition/gadgetclass'
MODULE '*reactionObject','*reactionForm','*stringlist','*dialogs'
//access to main rebuild object list
EXPORT DEF objectList:PTR TO stdlist
PROC checkDupe(str:PTR TO CHAR,comp:PTR TO reactionObject, form:PTR TO reactionForm, editComp:PTR TO reactionObject,id)
DEF i
IF comp
IF StrCmp(comp.ident,str) AND (editComp<>comp) THEN RETURN TRUE
FOR i:=0 TO comp.children.count()-1
IF checkDupe(str,comp.children.item(i),form,editComp,id) THEN RETURN TRUE
ENDFOR
ENDIF
ENDPROC
EXPORT PROC checkIdent(form:PTR TO reactionForm, editComp:PTR TO reactionObject, id)
DEF str:PTR TO CHAR
DEF comp:PTR TO reactionObject
DEF i,j
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 checkDupe(str,comp,form,editComp,id)
errorRequest(form.windowObj,'Error','The identifer is already used')
RETURN FALSE
ENDIF
ENDFOR
ENDIF
ENDPROC TRUE