-
Notifications
You must be signed in to change notification settings - Fork 0
/
multipleRegEx.R
88 lines (84 loc) · 2.47 KB
/
multipleRegEx.R
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
testRegex = function(rgx) {
err=capture.output(tryCatch.W.E(grepl(rgx,'testregexponly')))
if(any(grepl('invalid regular expression',err))){
return(FALSE)
}
return(TRUE)
}
getAndExp = function(a1x='',a2x='',a3x='',disposer=FALSE){
if(disposer){
if(isExtant(wwx1)){
dispose(.GlobalEnv$wwx1)
}
}else{
.GlobalEnv$notFlg=FALSE
.GlobalEnv$a11='.'
.GlobalEnv$a22='.'
.GlobalEnv$a33='.'
.GlobalEnv$wwx1=gwindow('REGEX 1',height=30,parent = c(200,200))
ww1=ggroup(cont=wwx1)
gbb=gbutton('NOT',cont=ww1,handler = function(h,...){
focus(a1)=TRUE
.GlobalEnv$notFlg=!.GlobalEnv$notFlg
svalue(wwx1)=ifelse(notFlg,'NOT REGEX 1','REGEX 1')
})
a1=gedit(text=a1x,cont=ww1,handler=function(h,...){
if(nchar(svalue(a1))==0){
dispose(a1)
gtkMainQuit()
}else{
.GlobalEnv$a11=svalue(a1)
if(!testRegex(.GlobalEnv$a11)){
galert('BAD REGEX 1')
return()
}
ww2=gwindow('REGEX 2',height=30,parent = c(200,275))
a2=gedit(text=a2x,cont=ww2,handler=function(h,...){
if(nchar(svalue(a2))==0){
dispose(a2)
dispose(a1)
gtkMainQuit()
}else{
.GlobalEnv$a22=svalue(a2)
if(!testRegex(.GlobalEnv$a22)){
galert('BAD REGEX 2')
return()
}
ww3=gwindow('REGEX 3',height=30,parent = c(200,350))
a3=gedit(text=a3x,cont=ww3,handler=function(h,...){
.GlobalEnv$a33=svalue(a3)
if(!testRegex(.GlobalEnv$a33)){
galert('BAD REGEX 3')
return()
}
dispose(a2)
dispose(a1)
dispose(a3)
gtkMainQuit()
})
addHandlerDestroy(ww3,handler=function(h,...){
if(isExtant(ww2))
dispose(ww2)
gtkMainQuit()
})
focus(a3)=TRUE
}
})
addHandlerDestroy(ww2,handler=function(h,...){
dispose(ww1)
gtkMainQuit()
})
focus(a2)=TRUE
}
})
focus(a1)=TRUE
focus(a1)=FALSE
focus(a1)=TRUE
addHandlerDestroy(wwx1,handler=function(h,...){
gtkMainQuit()
})
gtkMain()
}
gtkMainQuit()
return(list(.GlobalEnv$a11,.GlobalEnv$a22,.GlobalEnv$a33,!as.logical(.GlobalEnv$notFlg)))
}