OSCLI("bbcwrun6 ..")

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
Post Reply
User avatar
hellomike
Posts: 60
Joined: Sat 09 Jun 2018, 09:47

OSCLI("bbcwrun6 ..")

Post by hellomike » Sun 22 Dec 2019, 14:24

The following BB4W program works fine from the IDE as well as compiled:

Code: Select all

      OSCLI("Notepad D:\text.txt;")
      QUIT
A text file is opened in Notepad and the calling program ends.

The following program works fine from the IDE but not when it is compiled:

Code: Select all

      OSCLI("bbcwrun6 D:\prog.bbc;")
      QUIT
From the IDE, the BB4W program 'prog.bbc' is executed (it only has PRINT "Hello" in it) and the calling program ends.
If I double click the compiled .exe though, then nothing happens or seem to happen.

Probably this has been discussed before or is in the Wiki but I didn't know what to search for.

What am I missing here?

Thanks in advance.

Mike

RichardRussell
Posts: 112
Joined: Tue 15 Oct 2019, 09:10

Re: OSCLI("bbcwrun6 ..")

Post by RichardRussell » Tue 24 Dec 2019, 02:05

hellomike wrote:
Sun 22 Dec 2019, 14:24
What am I missing here?
I don't think you're missing anything. The reported behaviour is exactly what I would expect, and isn't specific to BBC BASIC.

(If you need any further explanation, permission for me to post it will need to be sought from the moderator).
My posts are moderated; if you are seeing this it has already been approved. If you have a comment about the style or tone of the message please report it to the moderators by clicking the exclamation mark icon rather than complaining on the public forum.

KenDown
Posts: 114
Joined: Wed 04 Apr 2018, 06:36

Re: OSCLI("bbcwrun6 ..")

Post by KenDown » Tue 24 Dec 2019, 04:46

Richard will correct me if I am wrong, but I suspect the behaviour you report has something to do with the value of @dir$. When you are running a program from the IDE, @dir$ has the value of wherever your copy of BBC BASIC is located. However when you compile the program, you compile it to somewhere - for example, it might be to D://BBCprogs/Test.exe - in which case @dir$ will have the value of D://BBCprogs/ and the program you are seeking to run (bbcwrun6.exe) is not located in that directory.

It might be worth while inserting this line at the start of your program:

Code: Select all

PRINT@dir$
and see what the values are when run from the IDE and when compiled. *If* I am right, you may get the results you want by specifying the file path explicitly in your OSCLI call both for bbcwrun6 and for the file you want to have loaded.

User avatar
hellomike
Posts: 60
Joined: Sat 09 Jun 2018, 09:47

Re: OSCLI("bbcwrun6 ..")

Post by hellomike » Tue 24 Dec 2019, 08:20

Thanks for the replies.

I indeed had @dir$ and @lib$ issues when I CHAINed a program from a compiled program which was fixed by setting @dir$ and @lib% just prior to the CHAIN.
However, I would assume "bbcwrun6" would set those when it starts.

Will do more tests after my little holiday. Have a nice Xmas!

Mike

RichardRussell
Posts: 112
Joined: Tue 15 Oct 2019, 09:10

Re: OSCLI("bbcwrun6 ..")

Post by RichardRussell » Tue 24 Dec 2019, 10:26

KenDown wrote:
Tue 24 Dec 2019, 04:46
I suspect the behaviour you report has something to do with the value of @dir$.
This is at best misleading, and I wish you didn't feel the need to post a reply (however inaccurate) every time you approve one of my messages. It should be obvious that it cannot be directly a result of the value of @dir$ because OSCLI (in this context) is simply passing the command to Windows for execution, and Windows cannot know anything about the internal workings of BBC BASIC such as the value of a system variable!

I did not reply in detail previously because I promised I would not post to the forum over the Christmas period, to give the moderator(s) a break. But since you have posted a reply that needs correction I feel I have no choice but to set the record straight. As I said, OSCLI (in this case) passes the command to Windows for execution, so this is entirely a Windows issue not a BBC BASIC issue.

The reason that 'notepad' works but 'bbcwrun6' doesn't is that the former is on the PATH (the environment variable which contains a list of directories to be searched) whereas the latter isn't. Typically 'notepad' will be in C:\Windows\System32\ and you will find that this directory is always included in the PATH (unless you have deliberately excluded it for some reason) whereas 'bbcwrun6' is typically in C:\Program Files (x86)\BBC BASIC for Windows\ which won't be in your PATH unless you have speciflcally added it.

So there are two ways to make bbcwrun6 work: you could add it to your PATH by editing your environment variables, or you could supply an absolute (fully qualified) path and filename in your command, for example:

Code: Select all

      OSCLI """C:\Program Files (x86)\BBC BASIC for Windows\bbcwrun6.exe"" D:\prog.bbc;"
Rather than specifying an a literal string you can generally assume that the required location is the parent directory of @lib$:

Code: Select all

      OSCLI """" + @lib$ + "..\bbcwrun6.exe"" D:\prog.bbc;"
Of course if you are 'compiling' the program which contains this statement, with a view to distributing it to somebody who may not themselves have BBC BASIC installed, then this still won't work because they won't have bbcwrun6.exe anywhere on their PC!
My posts are moderated; if you are seeing this it has already been approved. If you have a comment about the style or tone of the message please report it to the moderators by clicking the exclamation mark icon rather than complaining on the public forum.

KenDown
Posts: 114
Joined: Wed 04 Apr 2018, 06:36

Re: OSCLI("bbcwrun6 ..")

Post by KenDown » Tue 24 Dec 2019, 13:00

Thank you very much, Richard. I'm grateful that you have corrected me and I'm sure the original poster is too. Your caution over compiling a program for someone else to use who may not have BB4W is noted.

The only thing is that I did not know how to change PATH and possibly the original poster doesn't either. I looked it up on the Internet and found these instructions:

"Fortunately, you can set or modify the PATH system variable in Windows very easily. Here’s how: Click Start –> Computer –> System Properties. Click Advanced system settings. From the Advanced tab, click Environment Variables…. In the bottom pane, scroll down to the variable named Path. Select it and click Edit."

I have not tried this and the above information is posted without any recommendation or guarantee.

User avatar
hellomike
Posts: 60
Joined: Sat 09 Jun 2018, 09:47

Re: OSCLI("bbcwrun6 ..")

Post by hellomike » Fri 27 Dec 2019, 16:46

Most definitely I agree that this is entirely a Windows issue not a BBC BASIC issue.

Also expanding the OSCLI to

Code: Select all

      OSCLI("""C:\Program Files (x86)\BBC BASIC for Windows\bbcwrun6"" D:\prog.bbc;")
works fantastic!

The compiled program is not meant for distribution so this solution will be fine.
I needed a compiled program because I want to start it from the Windows10 Taskbar, where I intent to pin the EXEcutable, i.e. I can't pin other filetypes (I think). I then only have to click it to start the program.

Actually I am very aware of the purpose of the PATH system variable and how it works. But since there was NO issue when running the program from the IDE, I didn't think of that.

Windows (of course) will search for the command in the same directory as the calling program (the interpreter) before the ones in the PATH variable.

Regards,

Mike

Post Reply