How to possibly automatically run a file in .BAS format from the command line?

Discussions related specifically to the Windows, Linux (86), Mac OS-X and Raspberry Pi editions of BB4W and BBCSDL
knudvaneeden
Posts: 2
Joined: Sun 21 Apr 2019, 19:54

How to possibly automatically run a file in .BAS format from the command line?

Post by knudvaneeden »

Hi,

How to possibly automatically run a file in .BAS format from the command line?

Use case:
I want to run a BBCBASIC program as a block of readable text in my favorite text editor, then save it in .BAS format (all this I already can
do automatically in the text editor),
after which running BBCBASIC .exe which then AUTOMATICALLY runs it.

E.g. something like:
bbcwin.exe /RUN "mybbcbasicprogram.bas"
or similar
bbcwin.exe -RUN "mybbcbasicprogram.bas"

* Note:
If that automatic running of a .BAS file is possible then you could e.g.
perform automatically this typical cycle of typing
your human readable BBCBASIC program text in your favorite text editor, then from inside
that text editor you could do a quick run (e.g. calculation using
matrices) in BBCBASIC, then using e.g. *SPOOL to output it to a result
file, then load that result automatically back into your text editor where
you can do something with it.
I apply the same principle of saving the current block of text then
running automatically other executables like Mathematica, Matlab,
Maple, Python, ...

* Note:
bbcwin.exe "mybbcbasicprogram.bas"
will automatically LOAD that program, but will not RUN it automatically.
I have to click manually on the green '>' button in the GUI to run that program.

* Note: thus not a file in binary .BBC format (which can successfully be run automatically via bbcwrun.exe),
but in human readable .BAS format

* Note:
conversion on the command line automatically from .BAS to .BBC format
would be a possible solution, then you can run bbcwrun.exe with that
.BBC file instead. Not sure if that is possible at this moment.

* Note: Tested in latest BBCBASIC for Windows version 6.12a.

Thanks
with friendly greetings
Knud van Eeden
knudvaneeden
Posts: 2
Joined: Sun 21 Apr 2019, 19:54

Re: How to possibly automatically run a file in .BAS format from the command line?

Post by knudvaneeden »

Hi,

Hereby a (convert automatically a .bas program to a .bbc program, then run that .bbc program instead) solution (many thanks to Richard Russell for this):

https://www.bbcbasic.co.uk/wiki/doku.ph ... and_prompt

Troubleshooting note: It is very important to (always) use quotes "" around the first filename parameter (otherwise no output).

E.g. bbcwrun6.exe "c:\temp\basrun.bbc" c:\temp\foobar.bas
should be used but
E.g. bbcwrun6.exe c:\temp\basrun.bbc c:\temp\foobar.bas
should not be used.
DDRM

Re: How to possibly automatically run a file in .BAS format from the command line?

Post by DDRM »

Wow! That's remarkably compact! Richard is a clever man...

I could see that what was needed was to tokenise file, but I'm sure you did too, so I didn't bother to say. I'd never have been able to write code like that, though - it's going to take some work to understand....

:-)

D
User avatar
hellomike
Posts: 184
Joined: Sat 09 Jun 2018, 09:47
Location: Amsterdam

Re: How to possibly automatically run a file in .BAS format from the command line?

Post by hellomike »

In Richard terms, this is "a relatively simple solution".... :lol:
Repton
Posts: 42
Joined: Tue 22 May 2018, 13:51

Re: How to possibly automatically run a file in .BAS format from the command line?

Post by Repton »

So who upset him on this forum?