-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLS_POWER.BAS
383 lines (334 loc) · 11 KB
/
LS_POWER.BAS
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
DECLARE SUB Banner (Row%, Fcolor%, Bcolor%, Text$)
DECLARE SUB Box (Row1%, Col1%, Row2%, Col2%, Fcolor%, Bcolor%, Style%)
DECLARE SUB GetInput (Row%, Col%, MaxCharacters%, Fcolor%, DefaultText$, Password%, Bleep%)
DECLARE SUB Menu (Top%, Bottom%, Col%, Fcolor%, Bcolor%, InverseFColor%, InverseBColor%)
DECLARE SUB MultiSelect (Row%, Col%, NumberAnswers%, Question$, QColor%, AColor%)
DECLARE SUB press ()
DECLARE SUB ScreenSwap (Action AS INTEGER)
DECLARE SUB UserInterface ()
DECLARE SUB WallPaper (Fcolor%, Bcolor%, ASCIIChr%)
DECLARE SUB Center (Row%, Text$)
DECLARE FUNCTION Bold$ (Text$)
DECLARE FUNCTION Underline$ (Text$)
DECLARE FUNCTION StrikeThrough$ (Text$)
DECLARE FUNCTION Encrypt$ (Text$, EncryptKey%)
DEFINT A-Z
CONST True = -1
CONST False = 0
DIM SHARED InputString$
DIM SHARED MenuItems$(1 TO 10)
DIM SHARED ScrollText$(1 TO 10)
DIM SHARED ItemSelected
SUB Banner (Row, Fcolor, Bcolor, Text$)
COLOR Fcolor, Bcolor
LOCATE Row, 1
PRINT STRING$(80, " ");
Center Row, Text$
END SUB
FUNCTION Bold$ (Text$)
BackSpace$ = STRING$(LEN(Text$), CHR$(8))
Text$ = Text$ + BackSpace$ + Text$
Bold$ = Text$
END FUNCTION
SUB Box (Row1, Col1, Row2, Col2, Fcolor, Bcolor, Style)
SELECT CASE Style
CASE 1
Horizontal$ = "Ä"
Verticle$ = "³"
UpperLeft$ = "Ú"
LowerLeft$ = "À"
UpperRight$ = "¿"
LowerRight$ = "Ù"
CASE 2
Horizontal$ = "Í"
Verticle$ = "º"
UpperLeft$ = "É"
LowerLeft$ = "È"
UpperRight$ = "»"
LowerRight$ = "¼"
CASE 3
Horizontal$ = "Û"
Verticle$ = "Û"
UpperLeft$ = "Û"
LowerLeft$ = "Û"
UpperRight$ = "Û"
LowerRight$ = "Û"
CASE ELSE
EXIT SUB
END SELECT
COLOR Fcolor, Bcolor
BW = Col2 - Col1 + 1
LOCATE Row1, Col1
PRINT UpperLeft$; STRING$(BW - 2, Horizontal$); UpperRight$;
FOR A = Row1 + 1 TO Row2 - 1
LOCATE A, Col1
PRINT Verticle$; SPACE$(BW - 2); Verticle$;
NEXT A
LOCATE Row2, Col1
PRINT LowerLeft$; STRING$(BW - 2, Horizontal$); LowerRight$;
END SUB
SUB Center (Row, Text$)
LOCATE Row, 41 - LEN(Text$) / 2
PRINT Text$;
END SUB
SUB Delay (Seconds AS LONG)
'=============================================================================
'Delay (Seconds)
'=============================================================================
'Seconds Number of seconds Delay should pause
'=============================================================================
DIM TimeNow(0) AS LONG
DIM DestinationTime(0) AS LONG
TimeNow(0) = TIMER
DestinationTime(0) = TimeNow(0) + Seconds
DO
LOOP UNTIL DestinationTime(0) < TIMER
END SUB
FUNCTION Encrypt$ (Text$, EncryptKey)
Temp$ = ""
FOR RR = 1 TO LEN(Text$)
Temp$ = Temp$ + CHR$(ASC(MID$(Text$, RR, 1)) XOR EncryptKey)
NEXT RR
Encrypt$ = Temp$
END FUNCTION
SUB GetInput (Row, Col, MaxCharacters, Fcolor, DefaultText$, Password, Bleep)
'=============================================================================
'GetInput (Row, Col, MaxCharacters, FColor, DefaultText$, Password, Bleep)
'=============================================================================
'Row Screen row where input cursor should be placed
'Col Screen column where input cursor should be placed
'MaxCharacters Max number of characters allowed in string
'FColor Foreground color of text
'DefaultText$ A text string that is to be edited
'Password If True, displays all text as a series of *'s
'Bleep If True, a beep is sounded on an input error
'=============================================================================
WHILE INKEY$ <> "": WEND
InputString$ = DefaultText$
LOCATE Row, Col
COLOR 23: PRINT "_"
LOCATE Row, Col
COLOR Fcolor
GOTO ShowString
StartInput:
DO 'This DO loop continues until the user presses the <ENTER> key
DO 'This one uses INKEY to check for a key presses
Character$ = INKEY$
LOOP WHILE Character$ = "" 'If no key has been pressed, continue checking
ShowString:
LOCATE Row, Col
PRINT STRING$(LEN(InputString$), " ");
LOCATE Row, Col
PRINT InputString$;
IF Character$ = CHR$(8) THEN
Chrs = LEN(InputString$)
IF Chrs = 0 THEN
IF Bleep = True THEN BEEP
GOTO StartInput
END IF
DelChrs = Chrs - 1
InputString$ = LEFT$(InputString$, DelChrs)
LOCATE Row, Col + LEN(InputString$) + 1: PRINT " ";
LOCATE Row, Col: PRINT STRING$(LEN(InputString$) + 1, " ")
LOCATE Row, Col: PRINT InputString$
LOCATE Row, Col + LEN(InputString$)
GOSUB ShowStars
COLOR 23: PRINT "_": COLOR Fcolor
GOTO StartInput
END IF
FOR RR = 0 TO 31
IF RR = 13 THEN RR = 14
IF Character$ = CHR$(RR) THEN GOTO StartInput
NEXT RR
IF Character$ = CHR$(13) THEN GOTO RelayChrs
IF LEN(InputString$) = MaxCharacters THEN
IF Bleep = True THEN BEEP
GOSUB ShowStars
GOTO StartInput
END IF
IF LEN(Character$) = 2 THEN GOTO StartInput
InputString$ = InputString$ + Character$
RelayChrs:
IF Character$ <> CHR$(13) THEN
PRINT Character$;
COLOR 23
PRINT "_"
COLOR Fcolor
END IF
GOSUB ShowStars
LOOP UNTIL Character$ = CHR$(13) '<ENTER> Key - abort loop
LOCATE Row, Col + LEN(InputString$): PRINT " ";
EXIT SUB
ShowStars:
IF Password = True THEN
LOCATE Row, Col: PRINT STRING$(LEN(InputString$), "*");
END IF
RETURN
END SUB
SUB Menu (Top, Bottom, Col, Fcolor, Bcolor, InverseFColor, InverseBColor)
'=============================================================================
'Menu (Top, Bottom, Col, Fcolor, BColor, InverseFColor, InverseBColor)
'=============================================================================
'Top Top screen row where the first menu item is placed
'Bottom Bottom screen row where the first menu item is placed
'Col Screen column where the menu should be put
'FColor Foreground color of text
'BColor Background color of text
'InverseFColor Foreground color selected text
'InverseBColor Background color selected text
'=============================================================================
WHILE INKEY$ <> "": WEND
CONST HomeKey = 71, EndKey = 79, UpKey = 72, DownKey = 80, EnterKey = 13
Null$ = CHR$(0)
CurrentItem = Top
TextTrack = 1
GOSUB DisplayItems
GOSUB GoTop
StartMenu:
DO
MenuKey$ = INKEY$
LOOP WHILE MenuKey$ = ""
IF MenuKey$ = CHR$(13) THEN GOTO ReturnHit
IF MenuKey$ = Null$ + CHR$(UpKey) THEN GOSUB GoUp
IF MenuKey$ = Null$ + CHR$(DownKey) THEN GOSUB GoDown
IF MenuKey$ = Null$ + CHR$(HomeKey) THEN GOSUB GoTop
IF MenuKey$ = Null$ + CHR$(EndKey) THEN GOSUB GoBottom
GOTO StartMenu
GoUp:
CurrentItem = CurrentItem - 1
IF CurrentItem < Top THEN GOTO GoBottom
TextTrack = TextTrack - 1
GOSUB DisplayPointer
RETURN
GoDown:
CurrentItem = CurrentItem + 1
IF CurrentItem > Bottom THEN GOTO GoTop
TextTrack = TextTrack + 1
GOSUB DisplayPointer
RETURN
GoTop:
TextTrack = 1
CurrentItem = Top
GOSUB DisplayPointer
RETURN
GoBottom:
TextTrack = (Bottom - Top) + 1
CurrentItem = Bottom
GOSUB DisplayPointer
RETURN
ReturnHit:
COLOR InverseFColor, InverseBColor
LOCATE CurrentItem, Col
PRINT " "; MenuItems$(TextTrack); " "
ItemSelected = TextTrack
COLOR Fcolor, Bcolor
EXIT SUB
DisplayPointer:
GOSUB DisplayItems
COLOR InverseFColor, InverseBColor
LOCATE CurrentItem, Col
PRINT " "; MenuItems$(TextTrack); " "
RETURN
DisplayItems:
CurrentRow = Top
COLOR Fcolor, Bcolor
FOR RR = 1 TO ((Bottom - Top) + 1)
LOCATE CurrentRow, Col - 1
PRINT " "; MenuItems$(RR); " "
CurrentRow = CurrentRow + 1
NEXT RR
RETURN
END SUB
SUB MultiSelect (Row, Col, NumberAnswers, Question$, QColor, AColor)
'=============================================================================
'MultiSelect (Row, Col, NumberAnswers, Question$, QColor, AColor)
'=============================================================================
'Row Screen row where input cursor should be placed
'Col Screen column where input cursor should be placed
'NumberAnswers The max number of questions to be displayed
'Question$ The question to be displayed
'QColor Color of the Question
'AColor Color of the Answers
'=============================================================================
WHILE INKEY$ <> "": WEND
AnswerLength = LEN(MenuItems$(1))
QuestionLength = LEN(Question$) + Col + 2
LOCATE Row, Col
COLOR QColor
PRINT Question$; " ";
CurrentAnswer = 0
GOSUB SwitchAnswer
StartSelect:
DO
MenuKey$ = INKEY$
LOOP WHILE MenuKey$ = ""
IF MenuKey$ = CHR$(13) THEN GOTO SelectedItem
IF MenuKey$ = CHR$(32) THEN GOSUB SwitchAnswer
GOTO StartSelect
SwitchAnswer:
COLOR AColor
CurrentAnswer = CurrentAnswer + 1
IF CurrentAnswer > NumberAnswers THEN CurrentAnswer = 1
LOCATE Row, QuestionLength
PRINT STRING$(AnswerLength, " ")
LOCATE Row, QuestionLength
PRINT MenuItems$(CurrentAnswer)
AnswerLength = LEN(MenuItems$(CurrentAnswer))
RETURN
SelectedItem:
ItemSelected = CurrentAnswer
END SUB
SUB press
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = "": WEND
END SUB
SUB ScreenSwap (Action AS INTEGER)
'=============================================================================
'ScreenSwap (Action)
'=============================================================================
'Action 1 to capture, 2 to restore
'=============================================================================
SELECT CASE Action
CASE 1
PCOPY 0, 1
SCREEN 0, , 1, 1
CASE 2
SCREEN 0, , 0, 0
END SELECT
END SUB
FUNCTION StrikeThrough$ (Text$)
BackSpace$ = STRING$(LEN(Text$), CHR$(8))
Strike$ = STRING$(LEN(Text$), "-")
Text$ = Text$ + BackSpace$ + Strike$
StrikeThrough$ = Text$
END FUNCTION
FUNCTION Underline$ (Text$)
BackSpace$ = STRING$(LEN(Text$), CHR$(8))
ULine$ = STRING$(LEN(Text$), "_")
Text$ = Text$ + BackSpace$ + ULine$
Underline$ = Text$
END FUNCTION
SUB UserInterface
'=============================================================================
'UserInterface
'=============================================================================
'Put all of your code here to display your common user interface
'=============================================================================
WallPaper 7, 1, 177
Banner 1, 15, 4, "Legend Software Power Pack Demo"
Banner 25, 7, 1, "Copyright 1994-1995 Legend Software. All rights reserved."
END SUB
SUB WallPaper (Fcolor, Bcolor, ASCIIChr)
'=============================================================================
'WallPaper (Fcolor, BColor, ASCIIChr)
'=============================================================================
'FColor Foreground color of text
'BColor Background color of text
'ASCIIChr ASCII Code for Wallpaper design, can try 176, 177, or 178
'=============================================================================
COLOR Fcolor, Bcolor
FOR RR = 1 TO 25
LOCATE RR, 1
PRINT STRING$(80, ASCIIChr);
NEXT RR
END SUB