Re: Font_DecodeMenu



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/
.



Relevant Pages

  • Re: CloseFiles
    ... Martin Wuerthner wrote: ... their window templates with a variety of fonts including system font ... I believe that SWI Wimp_TextOp is only available from RISC OS 3.5 ... REM read x eigen factor for current screen mode ...
    (comp.sys.acorn.apps)
  • Re: Memory usage
    ... > Theseus/ Misc / Font for this windows and default font. ... without nothing happening until I kill theseus :-( ... getlinmp.cmd to get the linear memory usage. ... rem call mode co132,80 ...
    (comp.os.os2.misc)
  • Re: Annoying font problem....
    ... particular string in an anti-aliased font. ... calculating the width of a word is correct. ... SYS "Wimp_ReadSysInfo",8 TO font% ... REM For RISC OS 3.50 and higher ...
    (comp.sys.acorn.programmer)
  • [NEWS] Lotus Notes API Unauthorized Access to File Attachments
    ... obtain a string to display to the user. ... %REM ... Const LOWOBJ& = &H0001& ... Dim Result As Integer ...
    (Securiteam)
  • Re: Wieder mal das Thema DRUCKEN ;-)))
    ... Dim myapp As New Application ... Rem JUMO Dim druckername As String ... Set myapp = New Word.Application ...
    (microsoft.public.de.word.vba)