|Command Line Arguments|
|AutoPlay Media Studio|
All developer products from Indigo Rose offer a global table named _CommandLineArgs that will hold all command line arguments passed to the executable. Each application can have specific runtime parameters like SFXSOURCE: (AutoPlay Media Studio) or __IRCT: (Setup Factory), however the basic operation is the same for all of them. In this article I am going to show how to parse the command line arguments, and how to look for certain parameters in order to perform specific tasks in AutoPlay Media Studio, Setup Factory and TrueUpdate. Please note that these are only examples, and by no means that you couldn't perform different actions.
Before you start to try to write your code to react to a certain command line parameter, it is a good idea that you understand what parameters are passed, and what they are. Each application is different, so take the time to include this code in your application, and place it in a location where it gets executed right at the start of your program.
for i, arg in pairs(_CommandLineArgs) do Dialog.Message("info", "Command line argument "..i.." = "..arg); end
This code will show a series of dialogs, one with each command line parameter that the program received. Perform some tests, and call your program on the command line with sample arguments, and see how the _CommandLineArgs table works. This will be a great help when you try to understand the following samples, or attempt to write your own routines for command line arguments parsing.
sample.exe argument1 argument2 "argument with spaces"
Once you understood the basics of the _CommandLineArgs table, we can proceed to the samples for specific applications.