Numerical Recipes in BASIC and WIMP
François Vanzeveren (2221) 241 posts |
Hi all, I recently start to “seriously” learn how to program in BASIC for the WIMP. I chose the book “Numerical Recipes in C” as a common thread (http://numerical.recipes). This is a nice and concrete subject. You can find the application (called !NuRecipes) in its current state at See you very soon. François |
François Vanzeveren (2221) 241 posts |
Hi again. Let start with a first issue. Thank you for your help. François |
Chris Mahoney (1684) 2165 posts |
If you’re using the Toolbox then you should enable the “local” flag in ResEd. If you’re not using the Toolbox then I defer to an expert :) |
François Vanzeveren (2221) 241 posts |
Nope… I do not use the ToolBox. But just had a quick look at the manual… and I think I should use it :) Regards |
Andrew Conroy (370) 740 posts |
I think you want to be using Wimp_CreateSubMenu to open that menu rather than Wimp_CreateMenu, but it’s not something I’ve tried before, so I could be wrong. I suspect there’s a few other nicities which need to be adjusted to take this into account too. |
Fred Graute (114) 645 posts |
Yes, normally you’d use Wimp_CreateSubMenu to prevent the current menu from being closed, whether it works in this case I’m not sure. The dialogue is opened as part of the menu and windows are officially only allowed as leaf items. If Wimp_CreateSubMenu doesn’t work then the dialogue box would need to be opened as a regular, ie non-transient, window. The pop-up menu can then be created using Wimp_CreateMenu. |
Rick Murray (539) 13840 posts |
If a dialogue is more complicated than a simple click, shouldn’t it be opened on its own and not as part of a menu structure? That way the user can set up what needs set up and then click OK or something to “make it so”. |
François Vanzeveren (2221) 241 posts |
Hi, I think that indeed, when a dialog box gets more complicated, it makes sense to open it on its own. I tried usin Wimp_CreateSubMenu but then this generates an internal data transfer error when using Wimp_DecodeMenu to response to a Wimp-Poll reason code 9. Thank you for your help. François |
Chris Mahoney (1684) 2165 posts |
Sorry, I’d misunderstood and my previous post is wrong. Setting “local” won’t help in this case (at least I presume it won’t; I haven’t actually tried this particular case). |
François Vanzeveren (2221) 241 posts |
Hi, I am rewriting !NuRecipes in order to use the Toolbox. I have to admit this reduce considerably the amount of code required and make structuring the application easier. Without the toolbox, I was using “Wimp_GetIconState” to read R1!36. I can’t find the equivalent in the toolbox. Thank you for your help. François |
Chris Mahoney (1684) 2165 posts |
I’m sure I must have done that sort of thing before, but I can’t figure out how I did it. However, I’m currently at work so I don’t have access to my copy of the Toolbox manual, which I’ve written all over :) I suppose in the meantime you could use Gadget_GetIconList to get the Wimp icon number, which you could then feed into Wimp_GetIconState, but there is almost certainly a way of doing this without needing to call Wimp SWIs directly. |
Richard Coleman (3190) 54 posts |
The method “WritableField_GetValue” with R4 = 0 returns the size of the buffer in R5. |
François Vanzeveren (2221) 241 posts |
Hi Unfortunately, “WritableField_GetValue” and alike with R4=0 returns the lenght of the text currently stored (+1 for the termination character) , not the max buffer length allowed as specified in !ResEd.
Regards François |
François Vanzeveren (2221) 241 posts |
Hello I wonder what error code range can be used for application specific errors. In the Reference Manual, it is mentioned Errors produced by BASIC are in the range 0 to 127. Does this mean I can use any number from 128? Or does Wimp have its own reserved error codes? Thank you François |
Rick Murray (539) 13840 posts | |
Steve Drain (222) 1620 posts |
It is a bit late – I have been away on holiday – but there is a way to get the buffer length from the object data without going to the Wimp. DEFFN_GINFO(object%,gadget%) REM get gadget info SYS"Toolbox_GetTemplateName",,object%,END,255 SYS"Toolbox_TemplateLookUp",,END TO !END SYS"Window_ExtractGadgetInfo",,!END,gadget% TO !END =!END This returns a pointer to the gadget info block. The first 36 bytes are a standard header for all gadgets, followed by the gadget-specific info. You can find the template for each type in the manual. For a writable field this is: text 4 MsgReference max_text_len 4 word allowable 4 MsgReference max_allowable_len 4 word before 4 word after 4 word So the max length allowed for the text buffer is: !(FN_GINFO(object%,gadget%)+40) Some points: The use of I feel that the buffer length ought to be an attribute of itself, or at least discoverable more easily. I do no know of an easier way to get the object template than through the name, but I would be delighted to be shown one. The equivalent for buffers in non-window objects is: DEFFN_OINFO(object%) REM REM get object ino SYS"Toolbox_GetTemplateName",,object%,END,255 SYS"Toolbox_TemplateLookUp",,END TO !END =!END The common header is also 36 bytes. Why/how is ProgInfo.Version writable, but not buffered? |