OSCLI problem in Basic
David Gee (1833) 268 posts |
I’m having a problem with the OSCLI command in BASIC. I’m using it to call an external program; specifically Jeffrey Lee’s wave-file-playing application (from dream2-code.zip). The program is called succssfully, and works as it should, but the BASIC program terminates immediately afterwards. How can this be resolved? NB I’ve tried smething similar in (Norcroft) C, using the |
Rick Murray (539) 13840 posts |
In a word, you can’t. In a nutshell, every program believes it is located at address &8000. When you load a program from a program, that program is loaded at &8000 on top of the current program. The reason OSCLI, on the other hand, does nothing of the sort. One program overwrites another. It is possible to do this in BASIC but it requires a wodge of assembler and a knowledge of both BASIC and RISC OS. |
Martin Bazley (331) 379 posts |
That’s two words. :-P
Or you could take the infinitely simpler option and call Wimp_Initialise. This will make the Wimp do all the work for you. You don’t even need to call Wimp_Poll at any point – your program can still single-task, you just have to remember to call Wimp_CloseDown at the end. There are, of course, caveats. You can no longer use command windows or TaskWindows to display output, and you can’t change screen mode, or issue any other VDU commands that RISC OS would normally clean up for you after you ‘press SPACE or click mouse to continue’. Also, you can only call other single-tasking programs this way, otherwise control will pass back to you before the child task has finished. The latter problem can be worked around by using Wimp_StartTask instead of OSCLI, but then you have to write a poll loop to wait for the task to quit. It all depends on how comfortable you feel about RISC OS programming. |
David Gee (1833) 268 posts |
Ah. I had noticed that I could use OSCLI to call a * command (like Judging by the proposed solutions, I think it will be quicker to rewrite the program in question in C :-; |
nemo (145) 2546 posts |
Martin said
If you think about it, in a TaskWindow you are already a Wimp task, so you can use Wimp_StartTask anyway. It is even possible to call Wimp_Poll from inside a TaskWindow, as long as you’re really careful about event masking. Technically you can call Wimp_StartTask from outside the desktop too, but it has unfortunate side effects on the screen (which the Wimp really could have avoided) and won’t take effect until you return to the desktop. |
nemo (145) 2546 posts |
TIL You can call Wimp_Poll from outside the desktop (without calling Wimp_Initialise first). That was sort of unexpected and rather unfortunate. It’s only sort of unexpected, because technically “outside the desktop” is a Wimp task… but a special one. |
nemo (145) 2546 posts |
Martin also said
That in itself isn’t necessarily a problem. Communication protocols are slightly more tricky though. Having said that, you can send wimp messages that don’t need a reply with no trouble at all. |