Capricorn 76
This Lua tutorial shows how to use command line parameters with scripts.


--------------------------------
--------------------------------
-- Command Line parameters: Test 1
-- Print the command-line parameter supplied to the your main program's script.
-- This script starts up a new ScriptENGINE instance, and asks it to run this same script with some command-line parameters.
--
-- Copyright (c) 2006-2008 Capricorn 76 Pty. Ltd.
--------------------------------
--------------------------------

---------------------------
---------------------------
-- PROGRAM STARTS HERE
-- All global code (outside of any functions) is first run.
-- Then the ScriptENGINE automatically run the State Machine by looking for the OnStateRun function
---------------------------
---------------------------
-- Open the console, so we can display a message to the user
IApp:showConsoleWindow();

-- Register developer license (if available)
if (IApp:fileExists('../options.e76cfg')) then
    IApp:loadOptions('../options.e76cfg');
    IApp:registerDeveloper(IApp:getOption('Demo', 'LicenseEmail'), IApp:getOption('Demo', 'LicenseKey'));
end

function OnStateRun_test1(param1, param2, param3)
    ---------------------------
    -- If this script is called with command-line parameters, then print them out
    ---------------------------
    if (param1 and (string.len(param1) > 0)) then
        -- Print the state's input parameter.
        -- This is the program's command-line paramter for the start-up state
        print('================');
        print('OnStateRun_test1:', param1, param2, param3);
        print('================');
        print('Note: The ScriptENGINE handles the first 3 parameters. The rest are ignored...');

        -- Wait for user to press a key
        print('Press any key...');
        IKey:getch();

    ---------------------------
    -- Otherwise we create a new scriptENGINE instance and start this script with some command line parameters
    ---------------------------
    else
        print('About to run this script with some command line parameters. Press any key to continue...');
        IKey:getch();   -- Wait for user to press a key

        IApp:shellExecute('open', 'test1.e76script', '-commandline1 value1 -commandline2 value2');
    end
end

Copyright © 2006-23 Sep 2009 Capricorn 76 Pty. Ltd. (created on Wed Sep 23 16:49:11 2009)