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/
True Support for Command Line Applications
Moderator: Klaus
-
- VIP Livecode Opensource Backer
- Posts: 246
- Joined: Tue Jun 30, 2009 11:15 pm
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: True Support for Command Line Applications
If you want LC to run a command line app without Console, set the hideConsoleWindows to true.
To run an LC app from the command line be sure to call it with a -ui flag to bypass GUI init for true CLUI operation.
If you're already doing that let's dig deeper. I rarely use Windows, but have written many LC command line apps for Linux.
To run an LC app from the command line be sure to call it with a -ui flag to bypass GUI init for true CLUI operation.
If you're already doing that let's dig deeper. I rarely use Windows, but have written many LC command line apps for Linux.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: True Support for Command Line Applications
See also this blog post on using the already-CLUI LC Server engine for general command line use:
https://livecode.com/a-livecode-shell/
https://livecode.com/a-livecode-shell/
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: True Support for Command Line Applications
Bonus: see also the getopt function for operating CLI args:
https://livecode.fandom.com/wiki/Getopt
https://livecode.fandom.com/wiki/Getopt
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 683
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: True Support for Command Line Applications
There's a few alternative xTalk (languages that are very similar to LCScript) interpreters out there and at least one of them runs on the command line, is free open-source but uses JavaVM as it's 'engine' (unless you compile native binary with GraalVM), but it's not LC product so I won't link to it on their forum.SirWobbyTheFirst wrote: ↑Mon Mar 06, 2023 3:41 pmHi 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/
Other than that I'd take Richard's advice and maybe look into using the 'Server' version. I believe the IDE engine can also run in no-gui mode.