True Support for Command Line Applications
Posted: Mon Mar 06, 2023 3:41 pm
Hi Everyone,
I'm working on a command line application at the moment and I've noticed a couple of quirks with it, particular with how it interacts with Windows but apparently there's also some weirdness when used on macOS and Linux but I haven't been able to confirm that. For example, if you double click a LiveCode app that runs primarily via command line, you do not get the console host appear like you would if you double clicked say DISKPART in Windows.
In addition, unless you instruct Windows to start the LiveCode application using a parameter to wait for the app to close (For example Start-Process -Wait in PowerShell) then Windows immediately returns the prompt but then the output of the app is written on to each line like it should and then when the app terminates and you press a key on the command prompt in Windows, then it outputs at the original location of the prompt. But if you start the application using a parameter to direct Windows to wait for the app to exit, then it acts like a proper command line application. If you use a Batch or PowerShell script file and call your LiveCode application that way, then Windows always waits for the app to close before continuing.
Thus with LC10 being the big shebang redesign, it would be nice to get full support for creating command line applications with LiveCode. I believe regular WinMain() based applications such as LiveCode need to explicitly call OpenConsole() and CloseConsole() in order to open a console host window where as regular main() based applications do it as part of the C++ startup routines that are hidden away from the developer.
I did find the article below which seems to articulate it a little better than I do, but I've heard that .NET apps for example have a while loop that waits for execution of the main app logic to finish before returning from Main().
Article: https://justcheckingonall.wordpress.com ... win32-app/
I'm working on a command line application at the moment and I've noticed a couple of quirks with it, particular with how it interacts with Windows but apparently there's also some weirdness when used on macOS and Linux but I haven't been able to confirm that. For example, if you double click a LiveCode app that runs primarily via command line, you do not get the console host appear like you would if you double clicked say DISKPART in Windows.
In addition, unless you instruct Windows to start the LiveCode application using a parameter to wait for the app to close (For example Start-Process -Wait in PowerShell) then Windows immediately returns the prompt but then the output of the app is written on to each line like it should and then when the app terminates and you press a key on the command prompt in Windows, then it outputs at the original location of the prompt. But if you start the application using a parameter to direct Windows to wait for the app to exit, then it acts like a proper command line application. If you use a Batch or PowerShell script file and call your LiveCode application that way, then Windows always waits for the app to close before continuing.
Thus with LC10 being the big shebang redesign, it would be nice to get full support for creating command line applications with LiveCode. I believe regular WinMain() based applications such as LiveCode need to explicitly call OpenConsole() and CloseConsole() in order to open a console host window where as regular main() based applications do it as part of the C++ startup routines that are hidden away from the developer.
I did find the article below which seems to articulate it a little better than I do, but I've heard that .NET apps for example have a while loop that waits for execution of the main app logic to finish before returning from Main().
Article: https://justcheckingonall.wordpress.com ... win32-app/