04-28-2024, 02:52 AM
I LOVE qb64pe, and would hate to live without it. I use it to streamline my computer activities, much as I did with batch files in the olden days. I've even used it to run industrial equipment (once did that with DOS too). But there are always little things, that take me forever to get around to fixing, and this was one of those.
The start.command files on my Mac never worked properly. After years of ignoring it I finally decided to dig in and fix it. Turns out to be simple. If the program filename has spaces in it, the start.command malfunctions. It's the second line in the file:
cd "$(dirname "$0")"
./Open Web Image &
osascript -e 'tell application "Terminal" to close (every window whose name contains "Open Web Image_start.command")' &
osascript -e 'if (count the windows of application "Terminal") is 0 then tell application "Terminal" to quit' &
exit
Because the filename has spaces in it, it needs to be in quotes or have the spaces escaped out with backslashes:
./"Open Web Image" & OR
./Open\ Web\ Image &
So I went into the support folder, opened the qb64pe.bas program, searched for "start.command", and found the issue on line 13043.
Here is the block of code involved:
IF INSTR(_OS$, "[MACOSX]") THEN
ff = FREEFILE
IF path.exe$ = "./" OR path.exe$ = "../../" OR path.exe$ = "..\..\" THEN path.exe$ = ""
OPEN path.exe$ + file$ + extension$ + "_start.command" FOR OUTPUT AS #ff
PRINT #ff, "cd " + CHR$(34) + "$(dirname " + CHR$(34) + "$0" + CHR$(34) + ")" + CHR$(34);
PRINT #ff, CHR$(10);
PRINT #ff, "./" + file$ + extension$ + " &";
PRINT #ff, CHR$(10);
PRINT #ff, "osascript -e 'tell application " + CHR$(34) + "Terminal" + CHR$(34) + " to close (every window whose name contains " + CHR$(34) + file$ + extension$ + "_start.command" + CHR$(34) + ")' &";
PRINT #ff, CHR$(10);
PRINT #ff, "osascript -e 'if (count the windows of application " + CHR$(34) + "Terminal" + CHR$(34) + ") is 0 then tell application " + CHR$(34) + "Terminal" + CHR$(34) + " to quit' &";
PRINT #ff, CHR$(10);
PRINT #ff, "exit";
PRINT #ff, CHR$(10);
CLOSE #ff
SHELL _HIDE "chmod +x " + AddQuotes$(path.exe$ + file$ + extension$ + "_start.command")
END IF
I changed the highlighted line to:
PRINT #ff, "./" + CHR$(34) + file$ + extension$ + CHR$(34) + " &";
After compiling and running the new qb64pe program, no more issues. I should have done this years ago. I hope this is useful to others as well. Maybe this could be incorporated in the next release, if it doesn't mess up Windows machines?
True, I could use underscores in filenames instead of spaces, but where's the fun in that?
Now if I can only find the time to change those copy and paste keystrokes...
The start.command files on my Mac never worked properly. After years of ignoring it I finally decided to dig in and fix it. Turns out to be simple. If the program filename has spaces in it, the start.command malfunctions. It's the second line in the file:
cd "$(dirname "$0")"
./Open Web Image &
osascript -e 'tell application "Terminal" to close (every window whose name contains "Open Web Image_start.command")' &
osascript -e 'if (count the windows of application "Terminal") is 0 then tell application "Terminal" to quit' &
exit
Because the filename has spaces in it, it needs to be in quotes or have the spaces escaped out with backslashes:
./"Open Web Image" & OR
./Open\ Web\ Image &
So I went into the support folder, opened the qb64pe.bas program, searched for "start.command", and found the issue on line 13043.
Here is the block of code involved:
IF INSTR(_OS$, "[MACOSX]") THEN
ff = FREEFILE
IF path.exe$ = "./" OR path.exe$ = "../../" OR path.exe$ = "..\..\" THEN path.exe$ = ""
OPEN path.exe$ + file$ + extension$ + "_start.command" FOR OUTPUT AS #ff
PRINT #ff, "cd " + CHR$(34) + "$(dirname " + CHR$(34) + "$0" + CHR$(34) + ")" + CHR$(34);
PRINT #ff, CHR$(10);
PRINT #ff, "./" + file$ + extension$ + " &";
PRINT #ff, CHR$(10);
PRINT #ff, "osascript -e 'tell application " + CHR$(34) + "Terminal" + CHR$(34) + " to close (every window whose name contains " + CHR$(34) + file$ + extension$ + "_start.command" + CHR$(34) + ")' &";
PRINT #ff, CHR$(10);
PRINT #ff, "osascript -e 'if (count the windows of application " + CHR$(34) + "Terminal" + CHR$(34) + ") is 0 then tell application " + CHR$(34) + "Terminal" + CHR$(34) + " to quit' &";
PRINT #ff, CHR$(10);
PRINT #ff, "exit";
PRINT #ff, CHR$(10);
CLOSE #ff
SHELL _HIDE "chmod +x " + AddQuotes$(path.exe$ + file$ + extension$ + "_start.command")
END IF
I changed the highlighted line to:
PRINT #ff, "./" + CHR$(34) + file$ + extension$ + CHR$(34) + " &";
After compiling and running the new qb64pe program, no more issues. I should have done this years ago. I hope this is useful to others as well. Maybe this could be incorporated in the next release, if it doesn't mess up Windows machines?
True, I could use underscores in filenames instead of spaces, but where's the fun in that?
Now if I can only find the time to change those copy and paste keystrokes...