Probably a dunce question...
Rick Murray (539) 13851 posts |
Probably a dunce question, but it isn’t actually something I’ve ever needed to do before! Outside of the Desktop (cannot use Desktop stuff) – a BASIC program. How would I get it to run another program, and then return to the original when it is done. Should I push PAGE up high (so the other program doesn’t overwrite mine) and then SYS “OS_CLI” it? |
Steve Drain (222) 1620 posts |
My suggestion would be to put the second program into a library and start running it using a PROCedure call. The main warning is to make sure there are no conflicts in the namespace of each program, ie global variables and routine names. If you really want to change programs entirely you could CHAIN one from the other and then vice versa. Then you would have to preserve each program’s values somehow, perhaps to a file. You could pass some values using the resident integers. |
Rick Murray (539) 13851 posts |
Sorry, I should clarify – the “chained” programs are utility/absolute that may be assembler or C. |
Rick Murray (539) 13851 posts |
[this was a dupe of the previous; was writing in the car and the signal dropped out going through a small village…] |
Steve Drain (222) 1620 posts |
[Transient] utilities, filetype &FFC, should be no problem. Just call them with OSCLI. |
nemo (145) 2556 posts |
A Utility is loaded into the RMA, given 1024 bytes workspace and executed there. It is even possible for a Utility to call Wimp_Initialise and run as a task (though you have to be clever). However, an Absolute is going to load on top of your program. It would be nice if BASIC could be persuaded to run elsewhere in memory, but &8000 and wimpslot manipulation is built in. When you say “outside the desktop” do you mean while the desktop is running (eg F12) or when the Wimp is not running – before *Desktop? It is of course possible to use the WindowManager as a process controller rather than a GUI at a push. (And it’s a pity these two elements are so intertwined in the one module – I wish TaskManager did the Task stuff and WindowManager did the GUI stuff…) |
Steve Drain (222) 1620 posts |
I sure that you would have done it if it could be done. I have tried, and I can get most bits of a program’s workspace to be elsewhere, but not those bits tied to ARGP, always held in r8. I always imagined that at one time it was intended to be changeable. |
nemo (145) 2556 posts |
:-D It couldn’t be forced on existing builds without patches (BASIC resets ARGP rather too often – eg after every SYS).
I don’t think that was planned, however I don’t see why it couldn’t be done. For example, though the Error and Escape environment handlers are hard-wired to reset R8, the UpCall and Exit handlers are registered with an appropriate R12. Given appropriate extensions (or semantics) to BASIC’s @ CLI parameter (eg addresses outside the application slot have different implications) one could envisage being able to invoke the interpreter on any bit of memory anywhere… but if one wanted to use BASIC as a general purpose scripting language extension, one would need a better API to allow interworking with “the host”. But I digress, &8700 is hard wired all over the place. |
Steve Drain (222) 1620 posts |
So I found. ;-) The best I could do was run a BASIC V task in a 4k (minimum page size) wimpslot with everything else located elsewhere. This was actually in a module so that you could write *commands in BASIC, but each one had to start a task. Rather pointless really. |
Rick Murray (539) 13851 posts |
Damn. Okay. I guess this rules out BASIC without some ugly page hacking in assembler. When I say outside of the desktop environment, count on the Desktop not have been started yet – I am attempting to write a sanitised boot handler to process through BootRun, log activity, and not abort on errors. So… Can I set up a C program to execute high (say, 256K over &8000)? If so, I could see if I could run a program under. It’s a shame RISC OS has no (easy) way to shell out to another program and return to caller when done. |
nemo (145) 2556 posts |
Well that sounds like an extended version of *Repeat to me. |
Rick Murray (539) 13851 posts |
And can this log what it does and success/fail status? Debugging a broken boot is a PITA, about time something was done to make things better – which is my intention… |
Steve Pampling (1551) 8172 posts |
Debugging a broken boot is a PITA, Yes, I’ll go with that about time something was done to make things better – which is my intention… !Reporter can, apparently, do this. |
Rik Griffin (98) 264 posts |
There was a BASIC library called “Shell”, from Acorn I think, that would allow a BASIC program to call another program via OS_CLI. I’ve still got it somewhere if anyone wants a copy. I think it works by copying BASIC’s workspace to the stack and then loading the new absolute at 0×8000. |
Rick Murray (539) 13851 posts |
Yes please. |
Rik Griffin (98) 264 posts | |
Martin Avison (27) 1494 posts |
Sorry for late input …. been away …
Do what?
I am not sure what you are suggesting here. Turning Boot logging on and off in Reporter Config is little more than click on, click off (and then save). |
Steve Pampling (1551) 8172 posts |
Log various actions occurring during the boot sequence.
I was suggesting that Reporter being built in, along with syslog, would be a good idea for people wanting to report faults. |
Ben Avison (25) 445 posts |
Sorry for the late follow-up. The BASIC shell library has been here on the ROOL site all along as well: |