Repository navigation
Expand file tree
/
Copy pathfglprogress_demo.4gl
More file actions
147 lines (128 loc) · 4.07 KB
/
Copy pathfglprogress_demo.4gl
File metadata and controls
147 lines (128 loc) · 4.07 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
IMPORT FGL fglprogress
DEFINE rec RECORD
icon STRING,
title STRING,
comment STRING,
vmin DECIMAL(20,5),
vmax DECIMAL(20,5),
vstp DECIMAL(20,5),
waitsecs SMALLINT,
confirm BOOLEAN,
canintr BOOLEAN,
showtimefmt STRING,
showtimerem BOOLEAN,
showvalfmt STRING,
refreshtm STRING
END RECORD
MAIN
DEFER INTERRUPT
OPEN FORM f1 FROM "fglprogress_demo"
DISPLAY FORM f1
LET rec.icon = "fourjs_logo.png"
LET rec.title = "My application"
LET rec.comment = "Processing data..."
LET rec.vmin = -0.20
LET rec.vmax = 0.50
LET rec.vstp = 0.05
LET rec.waitsecs = 1
LET rec.confirm = TRUE
LET rec.canintr = TRUE
LET rec.showtimefmt = NULL
LET rec.showtimerem = FALSE
LET rec.showvalfmt = NULL
LET rec.refreshtm = "0.500"
INPUT BY NAME rec.* WITHOUT DEFAULTS ATTRIBUTES(UNBUFFERED)
ON ACTION clear
LET rec.vmin = NULL
LET rec.vmax = NULL
LET rec.vstp = NULL
LET rec.waitsecs = 0
ON ACTION test
IF length(rec.vmin)==0 OR length(rec.vmax)==0 THEN
CALL test_infinite( )
ELSE
CALL test_finite( )
END IF
END INPUT
END MAIN
FUNCTION test_infinite()
DEFINE p fglprogress.progress_dialog
CALL p.initializeInfinite(rec.title,rec.comment)
CALL p.setIcon(rec.icon)
CALL p.withConfirmation(rec.confirm)
IF NOT rec.canintr THEN
IF NOT mbox_yn("Progress","Do you really want to start an infinite loop without interruption button?") THEN
RETURN
END IF
CALL p.withInterruption(rec.canintr)
END IF
CALL p.setExecTimeDisplayFormat(rec.showtimefmt)
CALL p.withRemainingExecTimeDisplay(rec.showtimerem)
CALL p.setValueDisplayFormat(rec.showvalfmt)
CALL p.setRefreshInterval(rec.refreshtm) -- Converted from string
CALL p.open()
WHILE TRUE
IF p.interrupted() THEN
IF NOT mbox_yn("Progress","Process interrupted by user, continue?") THEN
EXIT WHILE
END IF
END IF
CALL p.stepInfinite()
IF p.getValue() > 97 THEN EXIT WHILE END IF
IF rec.waitsecs>0 THEN SLEEP rec.waitsecs END IF
END WHILE
IF p.wasCanceled() THEN
ERROR "Process canceled..."
ELSE
CALL p.setComment("Done.")
CALL p.show()
END IF
CALL p.close()
CALL p.free()
END FUNCTION
FUNCTION test_finite()
DEFINE p fglprogress.progress_dialog
CALL p.initialize(rec.title,rec.comment,rec.vmin,rec.vmax,rec.vstp)
CALL p.setIcon(rec.icon)
LET rec.vstp = p.getStep() -- Get default from fglprogress if NULL specified
CALL p.withConfirmation(rec.confirm)
CALL p.withInterruption(rec.canintr)
CALL p.setExecTimeDisplayFormat(rec.showtimefmt)
CALL p.withRemainingExecTimeDisplay(rec.showtimerem)
CALL p.setValueDisplayFormat(rec.showvalfmt)
CALL p.setRefreshInterval(rec.refreshtm) -- Converted from string
CALL p.open()
WHILE TRUE
IF p.interrupted() THEN
IF NOT mbox_yn("Progress","Process interrupted by user, continue?") THEN
EXIT WHILE
END IF
END IF
IF rec.comment THEN
IF p.getValue() >= rec.vmin+((rec.vmax-rec.vmin)/2) THEN
CALL p.setComment("We are now half way...")
END IF
IF p.getValue() > rec.vmax * 0.95 THEN
CALL p.setComment("Finishing...")
END IF
END IF
IF NOT p.step() THEN EXIT WHILE END IF
IF rec.waitsecs>0 THEN SLEEP rec.waitsecs END IF
END WHILE
IF p.wasCanceled() THEN
ERROR "Process canceled..."
ELSE
CALL p.setComment("Done.")
CALL p.show()
END IF
CALL p.close()
CALL p.free()
END FUNCTION
FUNCTION mbox_yn(ttl STRING, cmt STRING)
DEFINE r BOOLEAN
MENU ttl ATTRIBUTES(STYLE="dialog",COMMENT=cmt)
COMMAND "Yes" LET r = TRUE EXIT MENU
COMMAND "No" LET r = FALSE EXIT MENU
END MENU
RETURN r
END FUNCTION