# 24.2 Packaging Multiple Files as OPX

If you want to share your Origin work files with another user then we recommend you to use Origin's Package Manager. Similar to Zip, Package Manager packs all your files into a single file for sending to other users. But Package Manager offers other advantages. The main advantage with Package Manager is allowing other users to install the files within the package by simply dragging and dropping the package on to Origin's workspace. Packages can also be setup to create Apps, button groups and toolbars and execute LabTalk scripts before and after installation. Packages can be easily uninstalled from the Package Manager dialog.

Open Package Manager by choosing Package Manager on the Tools menu.

## Dialog box

The Package Manger dialog has a File menu and a Tools menu.

The File menu contains the following items:

 New Create a new package. This will cause the current package, if one is open, to be closed. If the current package has been changed but not saved then you will be prompted to save or discard the changes or cancel the creation of a new package. Open an existing package file. This will cause the current package, if one is open, to be closed. If the current package has been changed but not saved then you will be prompted to save or discard the changes or cancel the opening of a new package. Save the current package to disk using it's current file name. If the package is new and does not yet have a file name then you will be prompted for a file name. Save the current package using a new file name. Close the dialog. If changes were made to current package and have not been saved you will be prompted to save or discard the changes or cancel the closing action.

The Tools menu contains the following items:

 Browse Installed Packages... This item will show you the Installed Packages dialog box which lists all the packages currently installed. You can browse the packages information such as name, version, and description, and open/uninstall the selected package if you wish. Extracting a package is different than installing a package. Extracting a package is used when you only want to get the files out of the package. The before and after scripts will not be executed. You also will be prompted to choose the target folder which can be any folder you choose. The target folder does not have to be Origin's user nor system folder. You will be prompted with a file dialog to choose a package file. After choosing a package file and clicking Open button the package will be installed. This item will also show you the "Installed Packages" dialog box. Simply select the packages you want to uninstall and click the Uninstall button.

### Tree View

The tree view is where the package settings are edited.

### Buttons

Below the tree view are six buttons.

The right-most button is used to show and hide the File List.

### File List

The file list shows all the files that are currently in the package. The total number of files in the list is shown to the left of the above six button. The number of files in the list and the number of selected files will change the state of the buttons as described above.

## Creating A New Package

Create a new package by adding files:

2. Click the Add Files button to open the Add Files To Package dialog.
3. Choose your files and then click the Open button or press the Enter key.
4. Choose Save or Save As on the File menu to write the package to an OPX file.

Create a new package by adding a folder:

If all of the files you want to put into a package are the same folder, it is more convenient to use the Add Folder button. This will add the folder and everything inside the folder, including subfolders their contents, into the package. The folder structure will be remembered in the package and will be recreated when the package is installed by another user.

2. Click the Add Folder button to open the Select Folder dialog.
3. Choose your folder and then click the Open button.
4. Choose Save or Save As on the File menu to write the package to an OPX file.
 Note: Button Groups require that all supporting files be in the Origin folder or in a subfolder of the Origin folder. It is highly recommended that your module keep all it's files, if possible, in a subfolder to keep modules organized and to avoid cluttering either the Apps folder or the User Files Folder.

## Creating a New App

To create a new package for an App, you can follow the steps in this tutorial.

## Extracting Files From A Package

You can extract the files from an existing package using the Package Manager.

1. Choose Extract a Package... on the Tools menu.
2. In the Open dialog choose your OPX file and click the Open button.
3. In the Select Target Folder dialog choose your target folder and click the OK button.

All the files will be extracted to the target folder. If the package contains subfolder information then all the subfolders will be created and files will be extracted into the subfolders just as they were when they were added to the package.

 Note: Extracting files from a package is not the same as installing a package. When extracting files from a package, Button Groups and Toolbars are not created and LabTalk scripts are not executed. Toolbar information and LabTalk scripts are only used when the package is being installed or uninstalled.

## Installing A Package

Installing A Package Using Package Manager

1. Choose Install a Package... on the Tools menu.
2. In the Open dialog choose your OPX file and click the Open button or press the Enter key.

The package will be installed.

Installing A Package Using Drag & Drop

1. Drag your OPX file and drop it on to the Origin workspace.

The package will be installed.

Installing A Package Using Group Folder

If you are using a concurrent network then you can have your package installed on all clients by putting it into your Group Folder.

Please see Group Folder Manager for how to do this.

Silent Install

A silent installation means performing installing automatically with the least user intervention. It is very useful when the installing procedure contains so many rollout messages that it would cost user many time to respond to every message and make the installation much slower.

To make an OPX that can be silently installed you need to have the following settings:

• Set the LabTalk Script > Before Installation setting to blank or any script that does not provoke a user prompt.
• Set the LabTalk Script > After Installation setting to any script that does not provoke a user prompt followed by the following two additional commands:
doc -s;
exit;

After making the necessary changes to the OPX it is now possible to launch Origin, install the OPX, and exit Origin without any human interaction. The following command line demonstrates how to perform the silent install of the OPX.

Origin8.exe -h -R "instOPX OPXFileName.opx"

The above command line will need to be edited to use the file name of your OPX.

 Note: Installing a package is not the same as extracting files from a package. When you install a package, Button Groups and Toolbars will be created and LabTalk scripts will be executed if the Toolbar and LabTalk Script fields are specified. Toolbar information and LabTalk scripts are ignored when extracting files from a package. When installing a package Origin will first check to see if the package has already been installed. If it has already been installed then Origin will inform the user that the package is already installed and ask if the installing should continue. If the user chooses to continue the installation then Origin will first uninstall the previous installation and then continue to install the current package. When installing an App all templates (*.otw,*otm,*otp,etc) and fitting function files (*. FDF) contained in this package are installed. They are copied to this App's folder. When uninstalling this App, all will be uninstalled as well. For each package that gets installed Origin will copy the package, without the packed files, to a package list file. The package list file is OPXList.xml and is stored in the Apps folder.

## Uninstall a package

You can uninstall a package already installed using Package Manager.

1. Select Uninstall a package… or browse installed packages… on the Tools menu.
2. In the Installed Packages dialog, choose a package listed and click the Uninstall button.

The package will be uninstalled from your computer.

## OriginC

The Package Manager is handled by OriginC code in OriginC\OriginLab\XMLPackage.c

The XMLPackage.c file calls a collection of Origin exported functions for working with packages. The following functions are declared in oUtils.h and exported from Origin's okUtil80.dll:

• okutil_create_package_tree
• okutil_create_package_file
• okutil_install_package_file
• okutil_uninstall_package_file
• okutil_get_installed_package_names
• okutil_remove_files_from_package
• okutil_get_packed_file_names
• okutil_repack_files

See OriginC's oUtils.h for the function's return type and the argument accepted by each function.

## Updating Origin C Files

Every Origin C file, when compiled, will generate a corresponding .OCB file in your User Files Folder. The .OCB file prevents having to recompile your Origin C source code every time it is executed. If you distribute Origin C files using an Origin package then you want to be sure your changed Origin C file gets recompiled when a user installs your updated package. In other words you want to delete the .OCB file that was created on the user's computer when they installed an older version of your package. You can delete the .OCB files using LabTalk's Delete command with the OCB option in your package's After Installation script.

For a detailed description of doing this please see Updating an Existing Origin C File

## Command to create OPX file

Make an OPX file from ini settings without opening package manager dialog. This will be useful if user execute origin from command line or a windows BAT files.

### Origin C

#include <Origin.h>
#include <../OriginLab/OPXFile.h>
int test_ini_to_opx()
{
OPXFile opx;
int err = opx.InitFromIni("opx_IEVer.ini");
if( err == 0 )
{
if( !opx.Save() )
printf("Failed saving.\n");
}
else
printf("InitFromIni error %d\n", err);
return 0;
}

### LabTalk

mkOPX ini:="C:\Users\jacqueline\Documents\OriginLab\User Files\opx_IEVer.ini" app:=Custom_IEVer opx:=H:\CustomIEVer.opx;
 Note: This method require a source ini file which including all settings in package manager dialog. See below, opx_IEVer.ini, for example:
[Package]
Name=IEVer
Description=Show IE version detected by Origin
Version=1.0
Author=OriginLab

[Origin]
Version=9.4
Pro=0

[App]
Icon=AppIcon.png
ToolbarIcon=
LaunchScript=run.section("%@AIEVer\IEVer.ogs",main);

[AppEnable]
Always=1
Graph=1
Workbook=1
Matrixbook=1
Image=1
Excel=1
Layout=1
LabTalkExp=

[Toolbar]
ButtonGroupFile=
Create=0

[LabTalk]
BeforeInstall=
AfterInstall=
BeforeUninstall=

[Files]
EncryptC=0
SourcePath=C:\Users\eparent\AppData\Local\OriginLab\Apps\IEVer\
OPXFile=IEVer1.opx