-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path138.bas
More file actions
73 lines (71 loc) · 1.66 KB
/
Copy path138.bas
File metadata and controls
73 lines (71 loc) · 1.66 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
'by Jan Vibe, ppad.bas
'from code library 2015-11-19 copy
'update to SmallBASIC 0.12.0 MGA/B+
'fix code messed up by text format
'and attempt to fit any screen
rtns=ppad("test ppad function, click some keys then OK...")
?"ppad returned: ";rtns
Input "OK press enter ";OK
end
func ppad(prompt)
local n,ch,w,h,x,y,f,r,x1,y1,x2,y2,tlimit
tlimit=xmax\txtw(" ")
'best to see if all this will fit on screen
h=txth("By")+3
'test screen size
x=0:y=2*h+2:w=txtw("ii")+6
for n=0 to 70
if x+w>xmax-13:x=0:y=y+h+2:endif
x=x+w+2
next
if y>ymax-h-3 then 'use small character set
for n=42 to 57:append ch,chr(n)
next
for n=65 to 90:append ch,chr(n)
next
else 'use large character set
for n=33 to 95:append ch,chr(n)
next
endif
append ch, "space bar":append ch,"delete":append ch,"OK"
cls:? prompt
x=0:y=2*h+2
'draw keypad for mouse, this is pretty cool
for n=0 to ubound(ch)
w=txtw(ch(n))+6
if x+w>xmax-13:x=0:y=y+h+2:endif
rect x,y step w,h
append x1,x:append y1,y
append x2,x+w:append y2,y+h
at x+4,y+2:? ch(n);
x=x+w+2
next
'handle clicks
r=""
pen on
repeat
while pen(0)=0
wend
x=pen(4):y=pen(5)
while pen(3)
wend
f=0 'f for find ch
for n=0 to ubound(ch)
if x> x1(n) and y> y1(n) and x< x2(n) and y< y2(n) then
f=n:n=ubound(ch)
endif
next
if ch(f)="delete" then
if len(r)>= 1 then r=left(r,len(r)-1)
elseif ch(f)="space bar"
r=r+" "
elseif ch(f)<> "OK"
r=r+ch(f)
endif
if len(r)> tlimit then beep
at 0,h+1:?string(tlimit," ");
at 0,h+1:?r;
until ch(f)="OK"
pen off:cls
ppad=r
end