RiscLua with error throwback
GavinWraith (26) 1563 posts |
I had an email from somebody which ended by suggesting that RiscLua would be a better tool for introduction to programming if it had error throwback to an editor. That started me thinking more about error-handling. I intend ultimately to bring out a version 5.80 of RiscLua which will incorporate a more thoughtful approach to this but in the meantime, here is how you can add throwback to version 5.70 – at least for programs that run in taskwindows – if you have a copy of the DDEUtils module. 1. In
2. Before the last line (
3. Add a textfile called
Here is a wee demo. Give it filetype Lua and run it by dragging
So you have to bundle your program up as a function of no arguments and call it in protected mode with throw as the error-handler. Note that format-strings now behave like functions. As for throwback from wimp tasks – that is going to need a clean up of the |
Steve Drain (222) 1620 posts |
In the spirit of friendly rivalry, Basalt has provided It is also very simple to use Reporter’s *ReportError T or to write a simple error routine to use DDEUtils SWIs. |
GavinWraith (26) 1563 posts |
I can remember Joe Taylor programming error throwback for BASIC many years ago. There was some complication about line numbers – whether they should be logical or in steps of 10. This was in the years when working in the desktop was comparatively new. I think I am prepared to concede that BASIC has certain advantages over Lua for introduction to programming – there are fewer choices to be made. It provides ERL and REPORT$ and so on. Lua provides a fairly sophisticated debug library, which I had not previously dipped my toe into. One of the problems is pure Lua’s ability to catch errors – a function Anyway I have begun to get throwback working with wimp programs now. I have gone for a new protocol for what handlers are. They are functions of two variables . There is a poll handler for yielding to the wimp given by
|
Steve Drain (222) 1620 posts |
It is still a problem and depends on the Throwback handling editor. The recommendation I give with The other significant problem is with libraries – BASIC keeps no record of the file from which a library is loaded. I make some attempt to solve this with Reporter does not deal with libraries either, but I have only just realised that it provides throwback for non-wimp programs, because it is itself a wimp application. Despite Basalt’s
Basalt does provide a method to catch errors, but I have never detected a great demand for it. ;-( |
Michael Emerton (483) 136 posts |
Oh I don’t know? I have used to to great effect :@) |
Martin Avison (27) 1494 posts |
Oddly enough, the version I have been using here for some time (and is edging towards release) does – if the first line of the Basic library gives the library name relative to the main program eg… the error Reported is… If the first line is the full path eg… the error Reported is … Throwback works in both cases. |
GavinWraith (26) 1563 posts |
A good tip. Calling DDEUtils from a non-wimp program and outside a taskwindow achieves nothing. No problems with libraries in Lua, or code compiled from external files, so long as one avoids and this program is run in a taskwindow, then throwback will open X to highlight its first line.
|
Steve Drain (222) 1620 posts |
I look forward to the release of the new version. I will say again that Reporter is a much simpler debugging tool than BASIC’s own, even with the enhancements that Basalt includes – The examples are very similar to Basalt and would both work until a couple of years ago. Up until then Prefix was set for the program, but I had to remove this as an automatic feature, because it affected the Font SWIs. So, the first example no longer works, but it is easy to implement another way if I revist it. I otherwise recommend the usefulness of setting Prefix in the !Run file. In Basalt there is also the option for the first line to be written as a library name and a filename, separated by @. This separation is useful elswhere The significant problem, though, is the danger of copying a library from one place to another without changing the first line. My idea would be to use the Basalt An overactive imagination has come up with the alternative idea of copying the library code to a scrap file before invoking Throwback. ;-) |
Martin Avison (27) 1494 posts |
Steve: rather than hijacking this thread further, I will contact you directly. |