Current directory and Dialog.RunExternal

All except GUI problems

Current directory and Dialog.RunExternal

Postby adimetrius » Wed Mar 03, 2021 3:06 pm

Colleagues,
by convention, relative paths in BB are evaluated with respect to the BB working directory, thus 'Hr/Demo' stands for 'C:\Program Files\BlackBox\Hr\Demo'.
It seems, however, that Dialog.RunExternal does not fully respect this convention.

When BB is started with the '/USE C:\Herschel' option, the working directory (in terms of BB and Files module) is altered to be C:\Herschel. But Dialog.RunExternal('Hr/Demo/Elf/M.exe') brings up a host dialog box that says Hr/Demo/Elf/M.exe cannot be found. The file is actually found in C:\Herschel\Hr\Demo\Elf\M.exe, but obviously the relative path is evaluated with respect to C:\Program Files\BlackBox, as directed by the .lnk file.
I've looked around, and C:\Herschel (the /USE option) is kept in HostFiles.dir.startup.path: HostFiles.Locator. However it is not available to the programmer: both HostFiles.dir and it's type HostFiles.Directory are not exported.

I can't find a way to figure out the actual working directory of running BlackBox (as directed by the /USE commandline option). Is there one? If I could, I would've used it in calling Dialog.RunExternal.

However, i think that'd be a workaround; a better thing to do, rather, is to make Dialog.RunExternal follow the BB convention and start the passed command in the actual BB working directory.

What do you think? How would such amendment of Dialog.RunExternal affect existing software?
User avatar
adimetrius
 
Posts: 58
Joined: Sun Aug 04, 2019 1:02 pm

Re: Current directory and Dialog.RunExternal

Postby Zinn » Wed Mar 03, 2021 6:34 pm

Hello Adimetrius,
here there are a procedure which gets the working directory of BlackBox:

Code: Select all
   PROCEDURE GetWorkingPath* (VAR workingDir: ARRAY OF CHAR);
      VAR loc: Files.Locator;
   BEGIN
      (* BlackBox Working Directory *)
      loc := Files.dir.This("");
      workingDir := loc(HostFiles.Locator).path + '/';
   END GetWorkingPath;


I hope that helps
- Helmut
Zinn
 
Posts: 99
Joined: Mon Nov 24, 2014 10:47 am
Location: Frankfurt am Main

Re: Current directory and Dialog.RunExternal

Postby adimetrius » Sun Apr 11, 2021 6:34 pm

Helmut,

thank you for your suggestion, I have incorporated it into Herschel. It does look like a hack to me, though; but it seems there's no one to second my suggestion of a more elegant and platform-independent solution?
User avatar
adimetrius
 
Posts: 58
Joined: Sun Aug 04, 2019 1:02 pm


Return to BlackBox Framework

Who is online

Users browsing this forum: No registered users and 1 guest

cron