How to Create a Command-Line Tool with LiveCode?
Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Wed May 29, 2013 1:54 am
- Location: Sydney, Australia
Re: How to Create a Command-Line Tool with LiveCode?
Hi there! Just checking whether with the upcoming version 9.5 there is now a (non-hacky) way to create compiled command-line tools with LiveCode? - i.e., a way that doesn't require us calling the tool with `-ui` arguments? Or is the only way still to just write uncompiled scripts that can be run by LiveCode Server?
Re: How to Create a Command-Line Tool with LiveCode?
Just curious, what makes adding '-ui' to the command to launch the program any more or less hacky than not using it?
I really am curious, not trying to be a jerk. Switches are common to almost any command line tool I can think of, no matter how you write them or launch them.
I really am curious, not trying to be a jerk. Switches are common to almost any command line tool I can think of, no matter how you write them or launch them.

-
- VIP Livecode Opensource Backer
- Posts: 7032
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
The -ui flag is only needed when using a standalone facelessly from the command line. It is not needed with LiveCode Server.
This blog article describes how to use LC Server outside of web serving, as a more general command-line program:
https://livecode.com/livecode-server/
This blog article describes how to use LC Server outside of web serving, as a more general command-line program:
https://livecode.com/livecode-server/
Richard Gaskin
Community volunteer LiveCode Community Liaison
LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Community volunteer LiveCode Community Liaison
LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Wed May 29, 2013 1:54 am
- Location: Sydney, Australia
Re: How to Create a Command-Line Tool with LiveCode?
@bogs What makes it 'hacky' is the fact that in order to control the output of the tool you MUST use the `-ui` flags every time you run it. It's perfectly fine to have your tool use flags, but no flags should be *required* for the tool to do its 'normal' function.
@FourthWorld Thanks for the link, but as you can see from my previous posts, I knew that already!
Ideally, it would be better to be able to ship a compiled tool, rather than just a script that requires the user to have LiveCode Server installed.
@FourthWorld Thanks for the link, but as you can see from my previous posts, I knew that already!

-
- VIP Livecode Opensource Backer
- Posts: 7032
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
It doesn't seem particularly onerous to have either a script + engine or a standalone with UI when shipping to an audience comfortable with command line execution.
What am I not understanding?
What am I not understanding?
Richard Gaskin
Community volunteer LiveCode Community Liaison
LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Community volunteer LiveCode Community Liaison
LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: How to Create a Command-Line Tool with LiveCode?
Like I said, I'm not sure what about that makes it 'hacky'.
I don't know which Os you are on, but, for instance, on Linux just off the top of my head, if you want to run dpkg, you are going to be using a switch. In fact, no part of dpkg (or many other) command line tools does *anything* unless you use a switch of some kind. If you open a terminal, and type in 'dpkg', you get a manual page. Same with (almost) any other command I can think of. I don't remember as much of the Windows cli commands as I probably should, but from what I remember writing batch files, it was the same thing.
I guess our standards are just different, but having to use a switch on a cli command program doesn't strike me as anything other than normal. If you really want to ditch the switch for your end user, just write a bash/batch/launcher file for the Os end user to launch your program with the -ui, and tell them *that* is the program. Problem solved
I don't know which Os you are on, but, for instance, on Linux just off the top of my head, if you want to run dpkg, you are going to be using a switch. In fact, no part of dpkg (or many other) command line tools does *anything* unless you use a switch of some kind. If you open a terminal, and type in 'dpkg', you get a manual page. Same with (almost) any other command I can think of. I don't remember as much of the Windows cli commands as I probably should, but from what I remember writing batch files, it was the same thing.
I guess our standards are just different, but having to use a switch on a cli command program doesn't strike me as anything other than normal. If you really want to ditch the switch for your end user, just write a bash/batch/launcher file for the Os end user to launch your program with the -ui, and tell them *that* is the program. Problem solved


-
- VIP Livecode Opensource Backer
- Posts: 2847
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: How to Create a Command-Line Tool with LiveCode?
If you use the server product to run scripts then you don't need the "-ui" modifier. Here's a test script (I have the server in my path to avoid having to specify the complete path in the hashbang line:
Here's the included test1.lc file:
Code: Select all
#!livecode-community-server
include "test1.lc"
local x, y
put 3 into x
breakpoint
put x into y
put "-- environment --" & cr
put "libraries=" && the libraries & cr
put "frontscripts=" && the frontscripts & cr
put "backscripts=" && the backscripts & cr
put "stacks=" && the stacks & cr
put "stacksinuse=" && the stacksinuse & cr
put "the version=" && the version & cr
put "the environment=" && the environment & cr
put "the editionType=" && the editionType & cr
put "the defaultFolder=" && the defaultFolder & cr
put "the defaultStack=" && the defaultStack & cr
put "-- dateItem test --" & cr
put 1489755600 into tVar
convert tVar to dateitems
put "fixed time (dateItems)=" & tVar & cr
get the time
convert it to dateitems
put "current time (dateItems)=" & it & cr
put the screenrect & cr
Code: Select all
#!livecode-community-server
put "hello, world" & cr
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- Posts: 270
- Joined: Wed Apr 27, 2011 2:12 pm
Re: How to Create a Command-Line Tool with LiveCode?
This is a GREAT question and forum thread. I have a similar question.
I have the need to create a system tray application and/or windows service. Can this be done in Livecode?
Mike
I have the need to create a system tray application and/or windows service. Can this be done in Livecode?
Mike
Re: How to Create a Command-Line Tool with LiveCode?
400,- (FOUR HUNDRED) US dollars, Mr.Felker!