3.7.5.44 OPack

LabTalk Object Type:

External Object

The OPack object is used to pack and unpack user-specified files.

Properties:

Property Access Description
opack.autoReplace Read/write
numeric

Controls whether the user is prompted to replace existing files. 0: (Default) Ask the user before replacing existing files. 1: Automatically replace existing files.

opack.file$ Read/write
string

List of files need to be packed. Used by all methods. If the file name begins without '\', go to the Origin directory to find the corresponding file.

opack.fileName$ Read/write
string

Archive file name. Use OPK as the extension name. Used by the opack.getFileNames( ), opack.pack( ), and opack.unpack() methods. If file name begins without '\', the archive file will be put in the corresponding path under the Origin directory.

opack.pack.saveFolderInfo Read/write, numeric

Only used in the opack.pack( ) method. 1: (Default) Save the full path name when pack into archive file. 0: Save the file name only.

opack.unpack.useFolderInfo Read/write, numeric

Only used in the opack.unpack( ) method. 1: (Default) Use the directory structure saved in OPK file when unpacking. 0: Use the file name only.

opack.unpack.targetFolder$ Read/write, string

This is the unpack directory. This property is only used in the opack.unpack( ) method. If it is not empty, use this as the target directory.

opack.unpack.uninstall$ Read/write, string

LabTalk script to be executed when the package is uninstalled. This property is used by the Unpack method. During the installation of a package the LabTalk script in this property is saved by Origin. When Origin is asked to uninstall the package it will execute this script before any files are uninstalled/removed. This is where you can perform any custom tasks necessary to fully uninstall your package from Origin. OPack will only uninstall/remove files and will not undo any changes you made during installation. Remember that during installation OPack will execute script code in the setup.ogs file's OnBeforeSetup and OnAfterSetup sections. To use this property you should set it in your OnBeforeSetup script and clear it in the OnAfterSetup script.

Methods:

Method Description
opack.getFileNames(TextFileName)

TextFileName is the name of text file containing the destination archive file name and the names of the files need to be packed. This method reads the first line to FileName$, then reads the following lines into the File$ property.

opack.findFile(FileName [, StrVar])

FileName is the file name to be found. StrVar is the string variable (optional). This method searches from the beginning of the File$ property. If the required file name is found, it assigns it to the LabTalk string variable. Otherwise, it leaves the variable unchanged. When the search is performed, only the last part of the file name will be compared. For example: opack.findFile(.dat, S) will find the first file name with "dat" as the extension from the current position of the File$ property and then assign it to a LabTalk string variable S. This method's return value is the element index if found, or 0 if not found.

opack.findNext([StrVar])

StrVar is the LabTalk string variable (optional). This method searches from the current index of the File$ property for the file name passed by the opack.findFile( ) method. If found, it is assigned to the LabTalk string variable. Otherwise, the variable is left unchanged. This method returns the element index if found, or 0 if not found.

opack.pack([UserAccessCode])

UserAccessCode can be: 0 = All, 1 = Non-registered, and 2 = Registered. If UserAccessCode is not included, then 0 (All) is used. This method packs all the files listed in the File$ property to the file FileName$. If opack.pack.SaveFolderInfo = 1, save the full path name for every source file. If opack.pack.SaveFolderInfo = 0, save the file name only. This method returns 0 for success, 2 for a File I/O error, or 6 for a File creation error.

opack.uninstall(ModuleName)

Uninstall OPK file moduleName. If found, removes the button group from the ini file. Returns 0 = success, 1 = failure.

opack.unpack( )

Unpacks the archive file FileName$. If opack.unpack.UseFolderInfo = 1, use the directory structure saved in the OPK file. If no folder information was saved, use the Origin directory instead. If opack.unpack.UseFolderInfo = 0, use the file name only. Return values are: 0 Success, 1 User access error, 2 File I/O error, 3 File header error, and 4 Expanding file error.

opack.reset( )

Sets opack.pack.SaveFolderInfo = 1, and opack.unpack.UseFolderInfo = 1. Sets all the other arguments to empty.