When this code is invoked "file1" is indeed loaded in Notepad. But in order to see 'file2" I have to close the file1 Notepad, then Notepad containing file2 is displayed.
I want to open Notepad twice, one containing file1 and one containing file2.
On the Mac two instances of the Textedit app are executed.
Any workaround?
Thank you!
Last edit: Simon Sobisch 2022-07-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not sure if you'll get CMD consoles flashing in the background or not, or all the other edge case issues that may arise.
If you wanted to go cross platform, you might be able to make a POSIX start script somewhere in your PATH that looks for a notepad argument and replace the whole thing with vim and ending with &. wink wink smiley.
(If you have WINE installed on a GNU/Linux system, which ships with notepad it usually invokes the entire emulated WINE system, which is expensive if not already running).
Cheers,
Blue
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The solution is to never hard-wire external programs in your code.
Instead just call a script - for example CALL "SYSTEM" USING "TEXTEDIT OPEN file1" and then have TEXTEDIT as exutable script in PATH (for Win32 name it ".bat", for other systems add the #!/bin/bash in the first line.
You can then check in there for the first argument and if it is WAIT execute a "waiting" texteditor, otherwise a background one.
For Win32 you could do this with cmd /k "start /nowait notepad.exe %2" for other systems normally end with a &.
If you use multiple programs you could also come up with a EXTCALL script that executes multiple different programs (and for example also get a "print" command, ...)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Off topic side comment: I gotta start hitting refresh more often, and stop posting advice that is not as complete as Simon's better answers that go in before I finish typing. :-)
😄
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not quite. I was assuming that the file is not an executable, but a data file. So rather than force the program by using call system using "adobereader file.pdf", calling system using "explore.exe file.pdf" will start whatever program that has been assigned to open pdf files.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello, I suspect this is more a Windows question than a GnuCOBOL question so apologies in advance if that's an issue.
I want to open a file created by my COBOL program in an editor on Windows. I use this code:
When this code is invoked "file1" is indeed loaded in Notepad. But in order to see 'file2" I have to close the file1 Notepad, then Notepad containing file2 is displayed.
I want to open Notepad twice, one containing file1 and one containing file2.
On the Mac two instances of the Textedit app are executed.
Any workaround?
Thank you!
Last edit: Simon Sobisch 2022-07-05
Can't test, @flaneur7508, but seeing as you know you are on WIN32 in that code block, try:
Not sure if you'll get CMD consoles flashing in the background or not, or all the other edge case issues that may arise.
If you wanted to go cross platform, you might be able to make a POSIX
start
script somewhere in your PATH that looks for anotepad
argument and replace the whole thing withvim
and ending with&
. wink wink smiley.(If you have WINE installed on a GNU/Linux system, which ships with
notepad
it usually invokes the entire emulated WINE system, which is expensive if not already running).Cheers,
Blue
Thanks Brian, that does the trick! Cheers!
The solution is to never hard-wire external programs in your code.
Instead just call a script - for example
CALL "SYSTEM" USING "TEXTEDIT OPEN file1"
and then have TEXTEDIT as exutable script in PATH (for Win32 name it ".bat", for other systems add the#!/bin/bash
in the first line.You can then check in there for the first argument and if it is WAIT execute a "waiting" texteditor, otherwise a background one.
For Win32 you could do this with
cmd /k "start /nowait notepad.exe %2"
for other systems normally end with a&
.If you use multiple programs you could also come up with a
EXTCALL
script that executes multiple different programs (and for example also get a "print" command, ...)Off topic side comment: I gotta start hitting refresh more often, and stop posting advice that is not as complete as Simon's better answers that go in before I finish typing. :-)
Yes, sometimes i'm just too lazy :) I do of course see your point.
I use:
CALL SYSTEM USING "explore.exe file.ext"
This way, the program that is opened is the one associated with the file extension.
Wouldn't be
CALL SYSTEM USING "file.ext"
work, too and be more portable at the same time?Not quite. I was assuming that the file is not an executable, but a data file. So rather than force the program by using call system using "adobereader file.pdf", calling system using "explore.exe file.pdf" will start whatever program that has been assigned to open pdf files.
I've thought that executing the "file" would automatically open it without using explorer.exe, but if that's your test result - sure stay with it.