When Origin is started, it reads the Command Line or Target text box (depending on your version of Windows) in the Origin program icon's Properties dialog box.
By default, these text boxes start Origin by executing the Origin .EXE file - without any switches. Switches can be added to modify Origin's startup sequence.
All command line arguments are optional. The syntax for passing arguments to Origin is:
<Origin.EXE path and name>[-switch arg] [origin_file_name] [labtalk_scripts]
|
Note: In general, the initialization switch (-i) should precede other switches if more than one switch is used. |
| Switch | Argument | Function |
|---|---|---|
| -A | cnf file | Specifies a configuration file to add to the list specified in the INI file. Configuration files can include any LabTalk command, but typically contain menu commands and macro definitions. The file (a) should be placed at the root level in your User Files Folder, (b) must have a CNF extension (omit at the command line), and (c) cannot contain spaces in the file name. For example:
Note: When passing the .cnf file on the command line using -a switch, Origin C may not finish startup compiling, and the licensing has probably not been processed by the time the .cnf file is processed. So, when you want to include X-Functions in your .cnf file, it's better to use -r or -rs switch instead of -a. |
| -B | <none> | Run script following OPJ path-name after the OPJ is open similar to -R but before the OPJ's attached ProjectEvents.ogs, such that you can use this option to pass in variables to ProjectEvents.ogs. This option also have the advantage of using all the command line string at the end so it does not need to be put into parenthesis as is needed by -R. |
| -C | cnf file | Specifies a new configuration file to override the specification in the INI file. Configuration files can include any LabTalk command, but typically contain menu commands and macro definitions. |
| -d | <none> | Force Origin to choose a new User Files Folder location. |
| -H | <none> | Hide the Origin application. Script Window will still show if it is open by internal control. |
| -HS | <none> | Same as -h, but in addition, it prevents the Script Window from opening. This helps scheduled tasks to run reliably. |
| -I | ini file | Specifies an initialization file to use in place of ORIGIN.INI. In general this switch should precede other switches if more than one switch is used. |
| -L | level | Specifies at which menu level to start Origin at. |
| -M | <none> | Run the Origin application as minimized. |
| -N | opju/opj file | Open Origin project file with % in file name |
| -OCW | ocw file | Load the Origin C workspace file. |
| -P | full path | Directs the network version of Origin to look for client-specific files in the specified path. |
| -R | (script) | Run the LabTalk script after any specified OPJ has been loaded.
Note: This script will execute after Origin C startup compile. |
| -R0 | (script) | Run the LabTalk script before any specified OPJ has been loaded.
Note: This script will execute after Origin C startup compile. |
| -RS | scripts | Similar to -R but without having OPJ specified. All the remaining string from the command line will be used as LabTalk script and run after Origin C startup compile has finished. |
| -SLOG | file name | Send script window output to file. If no path is provided, then the file is written to the user files folder. If no file name is specified and another switch follows, like -slog -hs, then Script_Log.txt will be created in the user files folder. |
| -TL | file name | Specifies the default page template. |
| -TM | otm file | Specifies the default matrix template. |
| -TG | otp file | Specifies the default graph template. Same as -TP. |
| -TP | otp file | Specifies the default graph template. Same as -TG. |
| -TW | otw file | Specifies the template used to create the first window in the project/session. File name cannot exceed 8 characters, excluding the otw extension. |
| -W | <none> | Directs the network version of Origin to look for client-specific files in the Start In folder or Working directory. |
The following is an example of a DOS *.bat file. First it changes the current directory to the Origin exe directory. It then calls Origin and passes the following command line arguments:
Please note that these -r, -r0, -rs, -b switches will wait for Origin C startup compiling to finish and thus you can use X-Functions in such script, as in:
For more complicated scripts, you will be better off putting them into an OGS file, and then running that OGS file from the command line.
The following example will run the script code in the main section of the startup.ogs file located in the User Files Folder. When the file name given to the run.section method does not contain a path, LabTalk assumes the file is in the User Files Folder. The following command line argument illustrates use of the run.section object method:
A simple startup.ogs file to demonstrate the above example can be:
[main] type -b "hello, from startup.ogs";
The ProjectEvents.ogs script attached to an OPJ file can be used to create an OPJ-centered task-processing tool. In the following example, an OPJ can be used to run a program either by opening the OPJ directly, or by calling it from a command line console external to Origin. In addition, we can set a project variable in the command line to indicate whether the OPJ was opened by a user from the Origin GUI or as part of a command-line argument.
We will create an OPJ with the following ProjectEvents.ogs code:
[AfterOpenDoc] Function doTask() { type -a "Doing some task..."; // code to do things type "Done!"; } //%2 = 2 for command line, but also for dble-click OPJ // so we better control it exactly with this variable CheckVar FromCmdLine 0; if(FromCmdLine) { type -b "Coming from command line"; doTask(); sec -p 2;//wait a little before closing exit; } else { type -N "Do you want to do the task now?"; doTask(); }
To run this OPJ (call it test) from a command line, use the -B switch to ensure the FromCmdLine variable is defined before [AfterOpenDoc] is executed:
The following example demonstrates starting Origin from a command line shell (i.e., Windows cmd) by entering a long script string containing the -rs switch.
The script performs several actions:
To begin, issue this command at an external, system-level command prompt (such as Windows cmd), replacing the Origin installation path given with the one on your computer or network:
This example demonstrates using an external Excel file to generate a Summary Report using Batch Processing.
In one single continuous command line, the following is performed:
To begin, issue this command at an external, system-level command prompt (such as Windows cmd), replacing the Origin installation path given with the one on your computer or network:
|
Note: Additional information on batch processing from script (using both Loops and X-Functions) is available in a separate Batch Processing chapter. |