Real Software Forums

How does App get launchd ProgramArguments?
Page 1 of 1

Author:  Tom Baumgartner [ Tue May 21, 2013 5:57 am ]
Post subject:  How does App get launchd ProgramArguments?

There is a gap in my understanding of how launchd and Xojo (might as well get used to the new name) communicate.

If my launchd plist is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN >
<plist version="1.0">
<string>myApp Launcher</string>

How do I get my app to receive the "-f" program argument when it is started by launchd?

Author:  JeremK [ Wed May 22, 2013 6:48 am ]
Post subject:  Re: How does App get launchd ProgramArguments?


The app gets the ProgramArguments using the "System.CommandLine" property.

This is the code I use in one of my programs.
The command() property then has all commands sent to the App.

Dim commands() As String
Dim FoundQuote As Boolean
Dim SplitCommand() As String
SplitCommand = Split((Trim(System.CommandLine).Replace(chr(34) + " " + chr(34), chr(34) + chr(34))), "")
Dim index As Integer
Dim tempStr As String

//List of commands
// -w #### : output width
// -h #### : output height
// -r simple | browser | smart | border : resize type
// -nostop : do not display error messages
// -bfontsize ## : output text size in browser

For each letter as String in SplitCommand
Select case letter
Case " "
If not FoundQuote then
index = index + 1
commands.Append tempStr
tempStr = ""
tempStr = tempStr + letter
End If
Case chr(34)
If not FoundQuote then
commands.Append tempStr
tempStr = ""
End If
FoundQuote = not FoundQuote
tempStr = tempStr + letter
End Select
commands.Append tempStr


Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group