Beginner programming enthusiast, want to learn BASIC/write programs for RISC OS
Rick Murray (539) 13850 posts |
Dave:
I’m guessing you looked at the code and didn’t bother reading the article itself? It was referring to a friend’s comment about a single self-contained program written in BBC micro style (INPUT, GET, PRINT, etc) and how such a thing could be translated into a RISC OS application. I’ll give you point b though. I’ve never argued that. ;-) Colin:
Basically because while there are fast processors and lots of memory available today, anybody who wrote code back in the days of a mere megabyte on an 8MHz processor would have not wanted to make their programs larger and slower than they had to be. Plus, because BASIC does not have structures so you can’t give offsets meaningful names unless you want to have a bunch of additional variables. Even then, it isn’t quite the same as what C and Pascal programmers would understand a structure to look like. https://www.riscosopen.org/viewer/view/castle/RiscOS/Sources/Apps/Alarm/bas/Main?rev=1.6#l683 Here’s one that does, creating some three dozen variables to make things easier to read: Whether or not DrWimp is hard to read is irrelevant. The point of using a library is so we don’t have to read such stuff. We just call the routines for the things we want done. Steve:
Of course not. 1 You don’t have to call OS_Exit in a C program either. The runtime does that following tidy-up after you |
Chris Hall (132) 3558 posts |
I personally feel that at some point a person should learn to do windows the hard way, so that they can make modifications as needed after loading a template, though before calling ‘Wimp_CreateWindow’. Yes I do exactly that. Load a template that was based on one of the original apps back in 1988 and then tweak it in BASIC (adding various pokes to add icons or whatever so that I know where they are and can give them a variable name) for each window I want. I simply found that easier than trying to use the template editor. |
Steve Fryatt (216) 2105 posts |
I suspect that we probably don’t want to be telling newcomers that this is the way things are done on RISC OS, however. It would be good if some of them stuck around long enough to actually develop some software before we scare them off… |
Rick Murray (539) 13850 posts |
Aren’t they supposed to run screaming when we say “POSIX? Wassat?”? ;-) |
Steve Drain (222) 1620 posts |
That prompts a query. There are several ways a BASIC program can finish: |
Rick Murray (539) 13850 posts |
I was simplifying when I said END does it. It is BASIC quitting that does it, and END does that when run as -quit as it would be for a task. |
GavinWraith (26) 1563 posts |
Agreed. On the topic of code for wimp programs being readable, I would be grateful for comments about the examples given here . Is it clear from the code what these three trivial examples do? |
Steve Fryatt (216) 2105 posts |
I suspect many people have rolled their own versions, however. All of my software uses a simple data file which is loaded into memory with OS_File 16 (or equivalent) and then has the submenus and dialogue boxes within it linked together. Rather like Templates, the file contains sections for the menu definitions, indirected text data and validation strings. The menus are defined in a text file, which is handy for revision control, and get turned into the binary data files by a command-line tool called MenuGen. Had I realised when I wrote it that Template files were extensible, I might have looked into adding the data to those instead (although in the days of Acorn, I doubt there would have been interest). If anyone’s interested, you can find a version of the software amongst the build tools on my website. The file format has evolved over the years, and there’s an unreleased version that has support for embedding menu names into the file to avoid the need to locate menu handles via their position in the definition file. Unfortunately the load routines in my BASIC library don’t handle named menus or dialogue boxes; the ones in my published C library do handle named dialogue boxes but, as with MenuGen, the updates to extract menu handles by name haven’t been published yet either. |
Chris Hall (132) 3558 posts |
If I recall correctly RISCBasic has limitations It does have some limitations but they are few: EVAL cannot be compiled, var%+=2 needs var% defined to (zero) beforehand (as would an undefined variable as a procedure parameter, including with a RETURN prefix), !mem% requires mem% word aligned, DATA statements cannot include variables. Not many really. ABC has a colossal list of exceptions, syntax differences and limitations. |
David Feugey (2125) 2709 posts |
Absolutely :) |
Patrick M (2888) 126 posts |
Hi again, I’ve been reading the “First Steps” guide, testing and trying things out. I’ve encountered a situation where something doesn’t work and I’ve got no idea what’s wrong with it.
This fails with error “unknown or missing variable at line 70”. I’ve checked it over and I can’t seem to understand why it doesn’t work, so I thought I’d ask everyone here, what’s the problem here? |
Steve Pampling (1551) 8172 posts |
You mean like < pre > < /pre> ? Or < code > < / code > When you’re logged in and replying there’s a nice helpful “Textile reference here” link at the bottom… |
Patrick M (2888) 126 posts |
Ok, thanks. I didn’t notice that somehow. |
GavinWraith (26) 1563 posts |
Well one problem is that you have a procedure definition before the END statement - |
Patrick M (2888) 126 posts |
@Gavin |
GavinWraith (26) 1563 posts |
The END statement, it is true, is not always required. is a valid BASIC program. But is not. Unfortunately, when BASIC was invented (by Kemeny and Kurtz in 1964), the usefulness of a formal specification of syntax had not yet been fully appreciated. For some remarks on BASIC’s syntax, scoping rules etc, you might find this of interest.
|
Steve Drain (222) 1620 posts |
That is by far the wisest policy, because it prevents your program running through into the definitions, but it is not strictly true. As DavidS points out, you can GOTO around a definition, although we generally frown on GOTO, don’t we? ;-) Another case is a definition that fits on a single line. BASIC ignores lines starting with DEF in normal execution. |
Steve Drain (222) 1620 posts |
An interesting comparison. There are a few mistakes about BASIC, mostly minor, but a couple more important. This might give Lua a more rosy outlook. ;-) |
GavinWraith (26) 1563 posts |
Let me know. I will be glad to correct them. Most readers will be more familiar with BASIC than Lua, and I wanted to teaze out those bits where the apparent similarities concealed hidden dangers. |
Patrick M (2888) 126 posts |
Thanks again for the help, everyone. I’ve been reading through the ‘first steps in programming risc os computers’ book the past weeks, and I’ve just finished writing a program. (there’s a few bugs to fix, but I think it’s pretty much finished) Zip archive: |
Steffen Huber (91) 1953 posts |
A suggestion: please use the ZIP format to archive anything RISC OS. It is more compact than Arc, it is supported by the nice read-only SparkFS, and you can create it with freely available tools like ZipEE. And it is cross-platform, so can be unarchived/looked-at on other plattforms (although extracting it loses the filetypes, it is still useful to have a peek at the ReadMe or other docs). |
Michael Emerton (483) 136 posts |
Another suggestion, rename the “ReadMe” file to !Help so it appears in the menu under “Help” :) |
Patrick M (2888) 126 posts |
Thanks for the suggestions. I used arcfs because that’s all I had, now I know about ZipEE I’ll use that from now on, and I’ve now replaced the arcfs link with a zip one. |
Phillip (5527) 57 posts |
If you have reached the debugging stage writing C, then you have also learned the hardest part, the C compiler. It is learning the toolchain required to write C that makes interpreted languages, like Basic, better for the budding enthusiast. The four thousand pages of instruction included with RiscOS is the real treasure but, wading through it can be daunting.
Very True. Despite some minor text errors, this could be your best START.
I believe you’ll progress most quickly with Basic. It is after all the Beginners All purpose Symbolic Instructional Code. BBC Basic is so flexible that you may never outgrow it. Once you reach the level of programming professionally, come back to this post and glean the value of the other suggested avenues. By and By, Python is another interpretted language that is new comer friendly. Not the fastest but, well documented and current. |
Andreas Skyman (8677) 170 posts |
As someone who learned C programming on a Risc PC, I have to say that I disagree with this. By all means, do acquire a knowledge of ARM assembly, but – in my opinion – you don’t have to worry about it being a prerequisite to starting C. That said, BASIC is more BASIC than C, and is probably easier to get started with. |