Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
|
|
@ -0,0 +1,91 @@
|
|||
\ The following is Forth code using iMops v2.23
|
||||
\ Tested on all MacOS from High Sierra to Sonoma
|
||||
\ using Intel based systems.
|
||||
\ This code can be used to create a stand-alone application
|
||||
|
||||
: isdigit? ( char -- flag ) \ true if 0 thru 9, false otherwise
|
||||
48 58 within? ;
|
||||
|
||||
: >uinteger { addr len \ dec accum -- n t | f }
|
||||
len NIF exit THEN
|
||||
1 -> dec 0 -> accum
|
||||
len 1+ 1 ?DO
|
||||
addr len + i - c@ dup isdigit?
|
||||
IF ( it's a digit 0 thru 9 )
|
||||
48 - dec * accum + -> accum
|
||||
dec 10 * -> dec
|
||||
ELSE 2drop false unloop exit
|
||||
THEN drop
|
||||
LOOP accum true ;
|
||||
|
||||
SYSCALL rand { -- int }
|
||||
|
||||
:class TextView' super{ TextView }
|
||||
:m put: ( addr len -- )
|
||||
0 #ofChars: self SetSelect: self
|
||||
insert: self ;m
|
||||
;class
|
||||
|
||||
Window+ w
|
||||
View wview
|
||||
Button incButton
|
||||
100 30 90 20 ( x0 y0 wid hi ) setFrame: incButton
|
||||
Button randButton
|
||||
190 30 70 20 ( x0 y0 wid hi ) setFrame: randButton
|
||||
TextView' val
|
||||
180 100 100 15 setFrame: val
|
||||
FixedText valLabel
|
||||
110 98 80 18 setframe: valLabel
|
||||
|
||||
Window+ okW
|
||||
view okView
|
||||
Button yesButton
|
||||
100 20 80 18 setframe: yesButton
|
||||
Button cancelButton
|
||||
10 20 80 18 setframe: cancelButton
|
||||
FixedText okText
|
||||
5 40 200 18 setframe: okText
|
||||
|
||||
:noname
|
||||
getText: val >uinteger
|
||||
IF 1+ deciNumstr
|
||||
ELSE " 0"
|
||||
THEN put: val ; setAction: incButton
|
||||
|
||||
:noname
|
||||
show: okW ; setAction: randButton
|
||||
|
||||
:noname
|
||||
rand deciNumstr put: val
|
||||
show: w ; setAction: yesButton
|
||||
|
||||
:noname
|
||||
getText: val >uinteger
|
||||
NIF " 0" put: val
|
||||
THEN show: w ; setAction: cancelButton
|
||||
|
||||
: main
|
||||
incButton addview: wview
|
||||
randButton addview: wview
|
||||
val addview: wview
|
||||
valLabel addview: wview
|
||||
" value:" SetText: valLabel
|
||||
300 30 430 230 put: frameRect
|
||||
frameRect " GUI component interaction" docWindow
|
||||
wview new: w show: w
|
||||
" 0" put: val \ must be done after window is new:
|
||||
" increment" setTitle: incButton
|
||||
" random" setTitle: randButton
|
||||
|
||||
yesButton addview: okView
|
||||
cancelButton addview: okView
|
||||
okText addview: okView
|
||||
" Set value to random number?" SetText: okText
|
||||
310 40 200 60 put: frameRect
|
||||
frameRect " " noCloseStyle
|
||||
okView new: okW
|
||||
" yes" setTitle: yesButton
|
||||
" cancel" setTitle: cancelButton
|
||||
;
|
||||
|
||||
main \ if creating installed app, startup word must be commented out
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
\0123456789012345678901234567 template for display layout
|
||||
\ Component interaction. X . main window
|
||||
\ Value: 123456789_ .
|
||||
\ [Increment] [Random] .
|
||||
\ Confirm............... X . dialog pop-up
|
||||
\ Set to a random value?
|
||||
\ [ Yes ] [ No ]
|
||||
|
||||
include xpllib; \for Ctrl key names, AtoI, ItoA and StrLen
|
||||
def X0=22, Y0=10; \upper-left corner of main window's position
|
||||
def X1=X0+21, Y1=Y0+5; \position of dialog pop-up (character cells)
|
||||
int Mouse, Button, X, Y, Ch, I; \all variables are global for simplicity
|
||||
def StrMax = 10; \max chars in String including underline
|
||||
char String(StrMax); \Value string array
|
||||
int StrInx; \index for character to be added to String
|
||||
|
||||
proc ShowString; \Show Value String
|
||||
[Attrib($F0); \set black on bright white
|
||||
Cursor(13+X0, 2+Y0); \move to Value field position
|
||||
for I:= 0 to StrInx-1 do ChOut(6, String(I));
|
||||
ChOut(6, ^_); \show cursor underline at end of String
|
||||
for I:= StrInx+1 to StrMax-1 do ChOut(6, ^ ); \blank rest of line
|
||||
];
|
||||
|
||||
func GetButton; \Return soft button number at mouse pointer
|
||||
[Mouse:= GetMouse;
|
||||
X:= Mouse(0)/8 - X0; \convert pixels to 8x16-pixel character cells
|
||||
Y:= Mouse(1)/16 - Y0;
|
||||
if X>=24 & X<=26 & Y=0 then return 0; \exit [X]
|
||||
if X>= 3 & X<=13 & Y=4 then return 1; \Increment
|
||||
if X>=17 & X<=24 & Y=4 then return 2; \Random
|
||||
X:= Mouse(0)/8 - X1; \convert pixels to character cells for dialog
|
||||
Y:= Mouse(1)/16 - Y1;
|
||||
if X>=24 & X<=26 & Y=0 then return 3; \exit [X]
|
||||
if X>= 3 & X<=11 & Y=4 then return 4; \Yes
|
||||
if X>=16 & X<=24 & Y=4 then return 5; \No
|
||||
return -1; \mouse is not on any soft button
|
||||
];
|
||||
|
||||
proc DoDialog; \Do pop-up dialog for further information
|
||||
[Attrib($70); \set black-on-gray color attribute
|
||||
SetWind(0+X1, 0+Y1, 27+X1, 5+Y1, 0, \fill\true); \draw gray rectangle
|
||||
Cursor(25+X1, 0+Y1); ChOut(6, ^X); \draw exit button
|
||||
Cursor( 3+X1, 2+Y1); Text(6, "Set to a random value?");
|
||||
Attrib($80); \set black on dark gray for buttons
|
||||
Cursor( 3+X1, 4+Y1); Text(6, " Yes ");
|
||||
Cursor(16+X1, 4+Y1); Text(6, " No ");
|
||||
Attrib($9F); \set bright white on light blue, for title bar
|
||||
Cursor(0+X1, 0+Y1); Text(6, " Confirm ");
|
||||
ShowMouse(true); \turn on mouse pointer
|
||||
loop [MoveMouse; \make pointer track mouse movements
|
||||
Mouse:= GetMouse;
|
||||
if Mouse(2) then \a left or right mouse button is down
|
||||
[Button:= GetButton; \get soft button at mouse pointer
|
||||
while Mouse(2) do \wait for mouse button to be released
|
||||
[MoveMouse;
|
||||
Mouse:= GetMouse;
|
||||
];
|
||||
if Button = GetButton then \if down Button = release button
|
||||
[if Button = 3 then InsertKey(Esc); \insert into keyboard buffer
|
||||
if Button = 4 then InsertKey(^y);
|
||||
if Button = 5 then InsertKey(^n);
|
||||
];
|
||||
];
|
||||
if KeyHit then \key is hit or was inserted in KB buffer
|
||||
[Ch:= ChIn(1); \get character from non-echoed keyboard
|
||||
if Ch=^y or Ch=^Y then \set Value to random number
|
||||
[I:= Ran(1_000_000_000);
|
||||
ItoA(I, String);
|
||||
StrInx:= StrLen(String);
|
||||
quit;
|
||||
]
|
||||
else if Ch=^n or Ch=^N or Ch=Esc then quit;
|
||||
];
|
||||
]; \loop
|
||||
];
|
||||
|
||||
proc DoMain; \Do main window interaction
|
||||
[ShowMouse(true); \turn on mouse pointer
|
||||
loop [MoveMouse; \make pointer track mouse movements
|
||||
Mouse:= GetMouse;
|
||||
if Mouse(2) then \a left or right mouse button is down
|
||||
[Button:= GetButton; \get soft button at mouse pointer
|
||||
while Mouse(2) do \wait for mouse button to be released
|
||||
[MoveMouse;
|
||||
Mouse:= GetMouse;
|
||||
];
|
||||
if Button = GetButton then \if down Button = release button
|
||||
[if Button = 0 then InsertKey(Esc); \insert into keyboard buffer
|
||||
if Button = 1 then InsertKey(^i);
|
||||
if Button = 2 then InsertKey(^r);
|
||||
];
|
||||
];
|
||||
if KeyHit then \key is hit or was inserted in KB buffer
|
||||
[ShowMouse(false); \don't draw on top of mouse pointer
|
||||
Ch:= ChIn(1); \get character from non-echoed keyboard
|
||||
if Ch>=$30 & Ch<=$39 then \only allow numeric digits for Value
|
||||
[if StrInx < StrMax-1 then \limit number of digits added
|
||||
[String(StrInx):= Ch;
|
||||
StrInx:= StrInx+1;
|
||||
\handle leading zeros - convert number to its canonical form
|
||||
String(StrInx):= 0; \append string terminator for AtoI
|
||||
I:= AtoI(String); \convert numeric String to an integer
|
||||
ItoA(I, String); \convert binary integer back to String
|
||||
StrInx:= StrLen(String); \String could have gotten shorter
|
||||
];
|
||||
]
|
||||
else if Ch = BS then \(backspace) delete back a character
|
||||
[if StrInx > 0 then StrInx:= StrInx-1]
|
||||
else if Ch=^i or Ch=^I then \increment Value
|
||||
[String(StrInx):= 0; \append terminator for AtoI
|
||||
I:= AtoI(String);
|
||||
ItoA(I+1, String);
|
||||
StrInx:= StrLen(String); \String could have gotten longer
|
||||
if StrInx > StrMax-1 then \roll all 9's to zero
|
||||
[String(0):= ^0; StrInx:= 1];
|
||||
]
|
||||
else if Ch=^r or Ch=^R then \random Value - go do dialog pop-up
|
||||
quit
|
||||
else if Ch = Esc then
|
||||
[SetVid(3); exit]; \restore normal text mode before exiting
|
||||
ShowString;
|
||||
ShowMouse(true);
|
||||
];
|
||||
]; \loop
|
||||
];
|
||||
|
||||
[SetVid($12); \set 640x480 graphics mode display
|
||||
TrapC(true); \prevent Ctrl+C from aborting the program
|
||||
String(0):= ^0; \initialize Value String to zero
|
||||
StrInx:= 1;
|
||||
loop [Attrib($70); \set black-on-gray color attribute
|
||||
SetWind(0+X0, 0+Y0, 27+X0, 5+Y0, 0, \fill\true); \draw gray rectangle
|
||||
Cursor(25+X0, 0+Y0); ChOut(6, ^X); \draw exit button
|
||||
Cursor( 4+X0, 2+Y0); Text(6, "Value:");
|
||||
Attrib($80); \set black on dark gray for buttons
|
||||
Cursor( 3+X0, 4+Y0); Text(6, " Increment ");
|
||||
Cursor(17+X0, 4+Y0); Text(6, " Random ");
|
||||
Attrib($9F); \set bright white on light blue for title bar
|
||||
Cursor(0+X0, 0+Y0); Text(6, " Component interaction ");
|
||||
ShowString;
|
||||
DoMain;
|
||||
DoDialog;
|
||||
ShowMouse(false); \don't overwrite mouse pointer (with Clear)
|
||||
Clear; \remove pop-up dialog
|
||||
]; \loop back to redraw main window
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue