Hated Moron wrote: ↑Sun 19 Mar 2023, 23:37
JeremyNicoll wrote: ↑Sun 19 Mar 2023, 19:13
apparently bbcbasic.exe doesn't default to looking in the folder it itself is running from.
I would expect it to look in the
Current Directory (which isn't necessarily where bbcbasic was loaded from) by default. That's the standard behaviour of applications in Windows, and is the basis of the 'relative path' terminology (where .. represents the parent of the Current Directory, for example). Is that not what you are finding?
In order to reference, in a BBC BASIC program, the directory from which bbcbasic.exe itself was loaded, you could use
@lib$ + "..", i.e. the parent of the
lib directory.
I think I didn't get as far as having a BBC BASIC program execute.
Some applications I use have a long list of folders that they will search in for resource files etc, starting - it's true - with the 'current directory'', sometimes looking on PATH, sometimes looking in application-specific folders/paths defined by environment variables, and sometimes looking in the application .exe's own directory or ones with relative paths. It's rarely just one place.
But it was carelessness on my part, as I put together long command lines to issue. When I write scripts to issue commands I always give files full paths so there's no dependence on where commands are issued from (and usually verify that every such input path refers to a path/folder that actually exists with a leafname file that also actually exists in it (and for output files that the folder/file does or doesn't exist according to what the script's going to do with each one).
[I also rarely call eg just "curl.exe" (especially as later versions of Windows apparently have curl installed), but when I install my copies I usually rename them to specify their versions AND invoke them with full paths... I used to just place them all in a folder where I keep lots of CLI utilities - so eg I would have had curl-7-57-0.exe and several other curl-n-nn-n.exe variants - but unfortunately curl.exe stopped having certain DLLs (or their code) fully linked into the exe's and started using several accompanying DLLs loaded from the same folder ... and that doesn't allow different versions of those, so I changed to have a separate folder for each version, eg
C:\Dropbox\Programs--ALL-\~open-source curl V7-57-0
which contains one specific instance of curl.exe and its matching DLLs.
Likewise when I used to use the get_iplayer perl program, I had a set of modifications to that code so for every released version I had the 'original' and my modified 'stable' version and sometimes test ones as well ... and they all had different names so I could easily compare what they did.
As a Dropbox user, when I "install" stuff (portable no-install versions as much as possible) things go into "Programs--ALL-" folders if any of my machines could run them, or \Programs-<machinid>\ folders if not.]
Anyway... Here I was c&p stuff from one place to another ...
In this case the first programs I tried to run were a couple of your samples in the same folder as the just-downloaded most recent copy of the console application. My commands were like:
C:\>"C:\Users\--myuserid--\Downloads\bbcbasic_console_win64\bbcbasic.exe" "sortdemo.bbc"
and it was ages before I realised they should have been
C:\>"C:\Users\--myuserid--\Downloads\bbcbasic_console_win64\bbcbasic.exe" "C:\Users\--myuserid--\Downloads\bbcbasic_console_win64\sortdemo.bbc"
It wasn't apparent that bbcbasic.exe hadn't found the sortdemo.bbc program as I couldn't tell anything meaningful from the gibberish that was produced. And when I did try a fully-pathed program name later on, that also produced gibberish presumably because the program was found and loaded, but the terminal couldn't cope.
It was only when I saw in this experiment
C:\>echo Fred > %temp%\name.txt
C:\>type %temp%\name.txt
Fred
C:\>"C:\Users\--myuser--\Downloads\bbcbasic_console_win64\bbcbasic.exe" -quit jn_simple.bbc < %temp%\name.txt > %temp%\out1.txt 2> %temp%\out2.txt
C:\>
C:\>type %temp%\out1.txt
?BBC BASIC for Win64 Console v0.42
(C) Copyright R. T. Russell, 2023
>Fred
Mistake
>
>
C:\>
that the redirected input text "Fred" looked as if it was seen by the interpreter's command prompt rather than my .bbc program that I realised a possible/probable reason was that the interpreter hadn't loaded any program at all.
With hindsight it's easy to recognise what happened. Presumably bbcbasic.exe looked for "jn_simple.bbc" in the root of C:\, but I think I expected to see an error saying "program not found", or something. If that "Mistake" in my redirected output file is that error ... then it's a little terse, I feel... and I say that with my background in IBM OSes which took uppercase terseness to extremes.