Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanswer.pls
More file actions
529 lines (478 loc) · 16.9 KB
/
answer.pls
File metadata and controls
529 lines (478 loc) · 16.9 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
*---------------------------------------------------------------
.
. Program Name: answer
. Description: Sample answer/signin program
.
. Revision History:
.
. 29 Aug 24 - Redesigned for version 10.7
.
INCLUDE plbequ.inc
INCLUDE plbmeth.inc
CIFNDEF $CLI_STATE_CORDOVA
$CLI_STATE_CORDOVA EQU 2
$CLI_STATE_BOOTSTRAP5 EQU 16
$BS5_OPTION_NO_WINBORDER EQU 4
CENDIF
*---------------------------------------------------------------
// <runtime wide variables>
isLoggedIn BOOLEAN %
isGui BOOLEAN %
isWebSrv BOOLEAN %
isPlbSrv BOOLEAN %
isWebview BOOLEAN %
isWebCliApp BOOLEAN %
isSmallScreen BOOLEAN %
curTheme FORM %2
loggedInUser DIM %40
charScrWidth FORM %3 // char screen width
charScrHeight FORM %2 // char screen Height
// <program wide variables>
.
. GETINFO System data
.
systemInfoData DIM 644
systemInfoRec RECORD
osType FORM 1
osVersion FORM 1
keyboardType DIM 2
keyboardSubType DIM 2
functionKeyType DIM 2
hasPen BOOLEAN
hasMouse BOOLEAN
mouseButtons FORM 1
buttonsSwapped BOOLEAN
screenWidth FORM 4
screenHeight FORM 4
computerName DIM 15
userName DIM 20
windowsDir DIM 260
systemDir DIM 260
colorBits FORM 2
windowHandle INTEGER 4
windowInstance INTEGER 4
taskbarState FORM 1
taskbarTop FORM 4
taskbarBottom FORM 4
taskbarLeft FORM 4
taskbarRight FORM 4
monitorCount FORM 2
virtualTop FORM 10
virtualBottom FORM 10
virtualLeft FORM 10
virtualRight FORM 10
RECORDEND
.
plbUsers IFILE
userRec RECORD
email DIM 40 // user email or name
password DIM 16 // password
loginTime DIM 14 // login time
RECORDEND
webWin PLFORM answerwv.plf
guiWin PLFORM answer.plf
Client CLIENT
Runtime RUNTIME
*................................................................
.
. Code start
.
.
. Check to see if we have alredy been run and terminate if yes
.
IF ( isLoggedIn )
SHUTDOWN
ENDIF
CALL Main
LOOP
EVENTWAIT
REPEAT
STOP
*................................................................
.
. Shutdown the runtime
.
DoShutdown LFUNCTION
ENTRY
SHUTDOWN
FUNCTIONEND
*................................................................
.
. Open or Create Users file
.
UserFileAccess LFUNCTION
ENTRY
result FORM 5
error INIT "Unable to open or create the user file!"
EXCEPTSET NoUserFile IF IO
FINDFILE "plb_users.isi"
IF EQUAL
OPEN plbUsers,"plb_users.isi"
ELSE
PREP plbUsers,"plb_users.txt","plb_users.isi","1-20","65"
ENDIF
RETURN
.
. Could not Open or Create the Users file
.
NoUserFile IF (isGui )
ALERT STOP,error,result
ELSE
KEYIN *DV,error,result
ENDIF
SHUTDOWN
FUNCTIONEND
*-------------------------------------------------------------------------------
.
. If user is on file, compare the password. Otherwise add the user.
.
CheckPassword LFUNCTION
ENTRY
decodedPasword DIM 12
tempPassword DIM 12
result FORM 5
ENDSET userRec.email
EXTEND userRec.email,40
RESET userRec.email
.
. we only save 12 character password so truncate anything extra
. and remove trailing spaces
.
MOVE userRec.password,tempPassword
CHOP tempPassword // Remove trailing spaces
READ plbUsers,userRec.email;userRec // Use name as key to password file
IF NOT OVER
DECODE64 userRec.password,decodedPasword // Decode the saved password
CHOP decodedPasword // Remove trailing spaces
RETURN IF ( tempPassword != decodedPasword ) // Return NOT Equal for bad password
ELSE
IF ( isGui ) // Notify user of new record
ALERT NOTE,"Added New User",result
ELSE
DISPLAY "Added New User",*W=2
ENDIF
.
. Encode the password stored on disk.
.
MOVE userRec.password,decodedPasword
ENDSET decodedPasword
EXTEND decodedPasword,12
RESET decodedPasword
ENCODE64 decodedPasword,userRec.password // don't store plain text password in file
WRITE plbUsers;userRec // Save User/Password info to disk
ENDIF
SETFLAG EQUAL // Password was good
FUNCTIONEND
*-------------------------------------------------------------------------------
.
. Update the user file and go to the master program
.
Signin LFUNCTION
ENTRY
timeStamp DIM 20
.
. Get the current time and update the password file to log
. last log in time
.
CLOCK TIMESTAMP,timeStamp
MOVE timeStamp,userRec.loginTime
UPDATE plbUsers;userRec
.
. move the user name to the global authenticated user variable
. so other progams can check this
.
MOVE userRec.email,loggedInUser
.
. chain to master
.
SET isLoggedIn
CHAIN "master"
STOP
FUNCTIONEND
*................................................................
.
. Switch betweem light and dark mode
.
DarkSwitch LFUNCTION
ENTRY
switch BOOLEAN
GETPROP awvChkDark,Value=switch
IF (Switch)
MOVE "3" TO curTheme
awvPictLogo.SetWebStyle Using "background-image", "none"
SETPROP awvChkDark,Value=0
ELSE
MOVE "4" TO curTheme
awvPictLogo.SetWebStyle Using "background-image", "linear-gradient(red, yellow)"
SETPROP awvChkDark,Value=1
ENDIF
Runtime.SetWebTheme Using curTheme
FUNCTIONEND
*................................................................
.
. Sign-in for Web
.
SigninWeb LFUNCTION
ENTRY
result FORM 5
GETPROP awvEdtUserName,Text=userRec.email
GETPROP awvEdtPassword,Text=userRec.password
CALL CheckPassword
IF NOT EQUAL
ALERT awvFrmMain;STOP,"Invalid Password",result
SETPROP awvEdtPassword,Text=""
SETFOCUS awvEdtPassword
RETURN
ENDIF
CALL Signin
FUNCTIONEND
*................................................................
.
. Webview or Bootstap 5 enabled GUI
.
WebAnswer LFUNCTION
ENTRY
.
. On smaller screens change to % positioning for left and width
.
IF (isWebCliApp || isSmallScreen)
SETMODE *PERCENTCONVERT=1
ENDIF
.
. Setup the default theme support
.
MOVE "3" TO curTheme
Runtime.SetWebTheme Using curTheme,*Options=($BS5_OPTION_GRADIENT+$BS5_OPTION_PROGRESS+$BS5_OPTION_NO_WINBORDER)
FORMLOAD webWin
awvPictLogo.SetWebStyle Using "border-radius", "25px"
.
. Turn off LOGO on smaller screens
.
IF (isPlbSrv || isWebCliApp || isSmallScreen)
SETPROP awvPictLogo,Visible=$FALSE
ENDIF
.
. Resize window and static header on smaller screens
.
IF (isWebCliApp || isSmallScreen)
SETPROP awvStatHeader,WebLeft="5%",WebWidth="90%"
awvStatHeader.SetWebStyle Using "font-size", "18pt"
SETPROP awvFrmMain,WebWidth="100%"
ELSE IF (isPlbSrv)
SETPROP awvStatHeader,Left=5
ENDIF
.
. Make the form visible
.
SETPROP awvFrmMain,Visible=$TRUE
SETFOCUS awvEdtUserName
FUNCTIONEND
*................................................................
.
. Sign-in for GUI
.
SigninGui LFUNCTION
ENTRY
result FORM 5
GETPROP ansEdtUserName,Text=userRec.email
GETPROP ansEdtPassword,Text=userRec.password
CALL CheckPassword
IF NOT EQUAL
ALERT ansFrmMain;STOP,"Invalid Password",result
SETPROP ansEdtPassword,Text=""
SETFOCUS ansEdtPassword
RETURN
ENDIF
CALL Signin
FUNCTIONEND
*................................................................
.
. Basic GUI for older graphical systems
.
GuiAnswer LFUNCTION
ENTRY
.
. On smaller screens change to % positioning for left and width
.
IF (isWebCliApp || isSmallScreen)
SETMODE *PERCENTCONVERT=1
ENDIF
FORMLOAD guiWin
.
. Turn off LOGO on smaller screens
.
IF (isPlbSrv || isWebCliApp || isSmallScreen)
SETPROP ansPictLogo,Visible=$FALSE
ENDIF
.
. Resize window and static header on smaller screens
.
IF (isWebCliApp || isSmallScreen)
SETPROP ansStatHeader,WebLeft="5%",WebWidth="90%"
ansStatHeader.SetWebStyle Using "font-size", "18pt"
SETPROP ansFrmMain,WebWidth="100%"
ELSE IF (isPlbSrv)
SETPROP ansStatHeader,Left=5
ENDIF
.
. Make the form visible
.
SETPROP ansFrmMain,Visible=$TRUE
SETFOCUS ansEdtUserName
FUNCTIONEND
*................................................................
.
. Show a banner on a console system
.
ShowBanner LFUNCTION
ENTRY
timeStamp DIM 20
formattedTime DIM 20
.
. Get the current time and format it for display
.
CLOCK TIMESTAMP,timeStamp
EDIT timeStamp,formattedTime,MASK="9999-99-99 99:99:99"
.
. setup the screen with colors and borders all based on screen information
. retrieved from clock earlier in the program.
.
DISPLAY *SETSWALL=1:charScrHeight:1:charScrWidth,*BGCOLOR=*BLUE,*WHITE,*ES;
DISPLAY *SETSWALL=1:3:1:charScrWidth,*BORDER:
*p=3:2,"Sunbelt Computer Software":
*P=(charScrWidth-21):2,formattedTime:
*SETSWALL=3:charScrHeight:1:charScrWidth,*BORDER:
*RTKDD,*H=charScrWidth,*LTKDD,*SHRINKSW:
*P=2:(charScrHeight-3),*RED,"ESC to exit",*WHITE;
FUNCTIONEND
*................................................................
.
. Classic Keyin/Display for character based systems
.
ConAnswer LFUNCTION
ENTRY
cx FORM 2 // character screen center x
cy FORM 3 // character screen center y
port DIM 10
.
. get screen dimensions
.
CLOCK PORT,port
RESET port,4
UNPACK port,charScrHeight,charScrWidth
.
. display banner
.
CALL ShowBanner
.
. calculate the center of the screen
.
CALC cx=charScrWidth/2
CALC cy=charScrHeight/2
.
. User prompts
.
DISPLAY *P=(cx-15):(cy-2),"Username : "
DISPLAY *H=(cx-15),"Password : "
.
. Traps to exit runtime cleanly
.
TRAP DoShutdown IF INTERRUPT
TRAP DoShutdown IF ESCAPE
.
LOOP
.
. Note: *IT does not expire. It's used to change the
. legacy behavior ( CAPS OFF = ALL CAPS )
. of the caps lock key to modern behavior. ( CAPS ON = ALL CAPS )
.
. We are using *DVEDIT for the user name because we want to use
. the system logged in user as the default userRec.
.
KEYIN *IT,*P=(cx-3):(cy-2),*LC,*DVEDIT=userRec.email
IF ESCAPE
SHUTDOWN
ENDIF
CHOP userRec.email
CONTINUE if ( userRec.email = "" ) // No empty or null user names
KEYIN *P=(cx-3):(cy-1),*EL,*ESON,*LC,userRec.password,*ESOFF
CONTINUE if ( userRec.password = "" ) // No empty or null passwords
CALL CheckPassword
UNTIL EQUAL
BEEP
DISPLAY *SAVESW,*SETSWALL=(cy-1):(cy+1):(cx-10):(cx+10),*BORDER:
*SHRINKSW,*BGCOLOR=*WHITE,*RED,*ES,"Invalid Password":
*W=4,*RESTSW,*SHRINKSW
REPEAT
DISPLAY *IN; // Turn off Shift Inversion.
CALL Signin
FUNCTIONEND
*................................................................
.
. Main - Main program entry point
.
Main LFUNCTION
ENTRY
runtimeData DIM 50
runtimeVersion DIM 5
unused DIM 1
plbRuntime DIM 9
WidthData DIM 5
checkWidth FORM 5
CLEAR S$ERROR$
.
. Check for character mode runtime
.
GETMODE *GUI=isGui
IF (isGui)
.
. Get System Information that could be useful later...
.
GETINFO SYSTEM,systemInfoData
UNPACK systemInfoData,systemInfoRec
.
. check windows console.
.
CLOCK VERSION,runtimeData
UNPACK runtimeData,runtimeVersion,unused,plbRuntime
CHOP plbRuntime
IF (NOCASE plbRuntime == "PLBCON")
CLEAR isGui
ENDIF
IF (NOCASE plbRuntime == "PLBWEBSV")
SET isWebSrv
ENDIF
IF (NOCASE plbRuntime == "PLBSERVE")
SET isPlbSrv
ENDIF
ENDIF
IF (isGui)
WINHIDE
ENDIF
.
. Open the user file and invoke the proper user interface
.
CALL UserFileAccess
CALL ConAnswer IF (!isGui)
Client.Getstate Giving isWebCliApp Using $CLI_STATE_CORDOVA
Client.Getstate Giving isWebview Using $CLI_STATE_BOOTSTRAP5
.
. Check for a small screen (such as iphone)
.
IF (isWebSrv)
Client.GetWinInfo Giving WidthData Using 0x2
MOVE WidthData To checkWidth
MOVE (checkWidth <= 700) to isSmallScreen
ENDIF
.
. Invoke the answer form based on level of UI support
.
IF (isWebview)
CALL WebAnswer
ELSE
CALL GuiAnswer
ENDIF
FUNCTIONEND
.
. End of code
.
You can’t perform that action at this time.
