Re: Font_DecodeMenu
- From: Steve Fryatt <news@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 14 Jun 2011 22:43:40 +0100
On 14 Jun, Paul Sprangers wrote in message
<51e32acc58Paul@xxxxxxxx>:
This time it is the attempt to create a font menu and choose a font from
there. I've managed to get a font menu on screen (with submenus for
weights), but as soon as I click on a font, the program quits with an
Abort on data etc.
The culprit appears to be the following call:
SYS "Font_DecodeMenu",0,fontmenu%,block%,buf%,&100
(fontmenu% holds the font menu, while buf% is dimensioned elsewhere.)
The short answer is "no idea": in isolation, your code is faultless.
Of course, we don't have any idea what fontmenu%, block% and buf% contain in
the context of your program.
Strangely, I used exactly the same call in another program without
problems. Even more strangely, when I change block% to block%!36 (a
desperate man is willing to plunge into the unobvious),
It's unclear what that's supposed to be trying to achieve. block% should be
a pointer to the block returned by Wimp_Poll on a Menu Selection event
(reason code 9), so block!36 would be the selection at the 10th level of
(sub)menu: I'm not even sure that the Wimp will go that far. In fact,
you're probably just pointing Font_DecodeMenu to some random memory address,
which isn't a smart move...
Allowing for the important caveats that: a) I've only used these calls in
anger from C, b) the following code uses extremely poor memory allocation
techniques, and c) I don't do BASIC much nowadays and this hasn't been
tested at all (what could possibly go wrong? ;-), I think the following
semi-pseudocode should be what you're doing. Is it?
DIM block% 255
DIM font_menu% size1%
DIM font_names% size2%
DIM returned_name% size3%
REM ... time passes ...
SYS "Font_ListFonts",,font_menu%,&800,size1%,font_names%,size2%,0
SYS "Wimp_CreateMenu",,font_menu%,x%,y%
REM ... more time passes ...
SYS "Wimp_Poll",0,block% TO reason%
CASE reason% OF
REM ... etc ...
WHEN 9
SYS "Font_DecodeMenu",0,font_menu,block%,returned_name%,size3%
SYS "XOS_GenerateError",returned_name TO returned_name$
REM returned_name$ now contains the font name plus stuff: you'll
REM now need to do some string manipulation to sort out what.
REM
REM I can't remember if the name is zero terminated; if not,
REM you might get away without XOS_GenerateError.
REM ... etc ...
ENDCASE
--
Steve Fryatt - Leeds, England
http://www.stevefryatt.org.uk/
.
- Follow-Ups:
- Re: Font_DecodeMenu
- From: Rick Murray
- Re: Font_DecodeMenu
- References:
- Font_DecodeMenu
- From: Paul Sprangers
- Font_DecodeMenu
- Prev by Date: Re: Font_DecodeMenu
- Next by Date: Re: Font_DecodeMenu
- Previous by thread: Re: Font_DecodeMenu
- Next by thread: Re: Font_DecodeMenu
- Index(es):
Relevant Pages
|