A Pocket Forth question...
Hello All,
I faced a problem on the menus with the Pocket Forth.
I think there's nothing wrong with my code for I just checked it up again
and again with the included files 'Windows&Menus' and 'Reader'. It's really
strange indeed. I used the format provided by Mr Heilman, 'Windows&Menus'
and 'Reader' worked very well but my code kept crashing after I chose
anything from my new-added menu.
Here follows my code,
--------------------------------------------
page 0 28 +md !
forget task : task ;
hex 4E55 4D45 2constant 'MENU' decimal
: Handle ( -- )
create 4 allot ;
Handle PMList
create thePoint 4 allot
: ResourceError? ( -- )
0 >r ,$ A9AF r> \ _ResError
?dup
if
." Resource Error: " . abort
then ;
variable c,even
-1 c,even !
: C, ( c -- )
if
0 c,even !
else
here 1 - c! -1 c,even !
then ;
2 base !
create Grey
01010101 c,
10101010 c,
01010101 c,
10101010 c,
01010101 c,
10101010 c,
01010101 c,
10101010 c,
decimal
: _DrawMenuBar ( -- )
,$ A937 ;
: _GetRMenu ( ResID -- MenuHandle )
0 0 2>r >r ,$ A9BF 2r> ;
: _InsertMenu ( beforeID theMenu -- )
: _ShowPen ( -- )
,$ A897 ;
: _PenSize ( h w -- )
>r >r ,$ A89B ;
: _PenPat ( pat -- )
a>r ,$ A89D ;
: _GetPen ( Point -- )
thePoint a>r ,$ A89A ;
: _LineTo ( v h -- )
>r >r ,$ A891 ;
: _Button ( -- boolean )
0 >r ,$ A974 r> ;
create StuffMenu \ my menu's menu list
' beep , ' beep , ' beep ,
create MBAR \ a new menu list
StuffMenu ,
: Main ( -- )
4 _GetRMenu PMList 2! \ get my menu from the resource
0 PMList _InsertMenu \ insert my menu in the last position
_DrawMenuBar
begin
6 6 _PenSize
Grey _PenPat
_Button
if
then
?terminal until ;
main forget main
MBAR 18 +md ! \ assign my own menu list as the current one
page -1 28 +md !
Thank you very much in advance.
God bless you all! ?:^)
--
Forthy
//////////
/// /// ///
////// //////// /// /// /////// ///////
/// /// /// ////// /// //// ///
/// //////// /// ///// /// ///