System.FileExt
System-FileExt-obj
Read and alter the file extension, file location, and file tracking settings
LabTalk Object Type:
- Utility
The fileExt object is a subobject of the system object. The fileExt object property allows you to read and alter the file extension, file location, and file tracking settings, which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.
Definitions for this object:
- Extension: The portion of text in the file name that follows the last period. For example, BMP is the extension of the file named "MyImage.BMP".
- Extension Description: The text that appears in the Files of Type combination box in the Open and Save As dialog box. This text is used to describe or identify the files that are named with a specific Extension. Example: Windows Bitmap (*.BMP)
- Extension Group: A list of Extension Descriptions. Example: Images
Properties:
Property |
Access |
Description |
System.fileExt.activeGroup |
Read/write
numeric |
This property returns the index of the group that is currently active. If there are no groups, then this property will return zero. You can change the active group by setting this property to the index of the group you want to make active. Values used for setting this property must be in the range [1, numGroups]. Setting this property will be ignored when there are no groups.
|
System.fileExt.activeGroup$ |
Read/write
string |
This property returns the name of the group that is currently active. If there are no groups, then this property will return an empty string (""). You can change the active group by setting this property to the name of the group you want to make active. Setting this property will be ignored when there are no groups. This property and the Name$ property will always return the same value.
|
System.fileExt.defASCII$ |
Read/write
string |
This property is used for getting and setting the default extension to be appended to ASCII files when an extension is not specified by the user.
|
System.fileExt.defPath$ |
Read/write
string |
This property is used for getting and setting the default path for the file types of the active group.
|
System.fileExt.defType |
Read/write
numeric |
The extension type used by default in the Files of Type combination box in the file dialog box. This value must be in the range [1, numTypes].
|
System.fileExt.name$ |
Read/write
string |
The name of the active group. Setting this property allows you to rename the active group. The Name$ and ActiveGroup$ properties always return the same value.
|
System.fileExt.numGroups |
Read/write
numeric |
The number of extension groups currently defined. You can set this value to decrease or increase the number of groups to be handled by the System.FileExt object. While increasing NumGroups is a way to add more groups, it is highly recommended that you use the AddGroup() method instead.
|
System.fileExt.numTypes |
Read/write
numeric |
The number of extension types in the active group. You can set this value to decrease or increase the number of types in the active group. This value must be in the range [0,25]. While increasing NumTypes is a way to add more types, it is highly recommended that you use the AddType() method instead.
|
System.fileext.openPathMode |
Read/write
numeric |
Path used by FDlog object 1 = User Path, 2 = Project Path, 3 = Origin Path.
|
System.fileext.savePathMode |
Read/write
numeric |
Path used by FDlog object. 0 = Use Open Path, 1 = User Path, 2 = Project Path, 3 = Origin Path.
|
System.fileExt.tracking |
Read/write
numeric |
Tracking default file paths: 0 = no tracking, 1 = Track file dialog changes.
|
System.fileExt.typen$ |
Read/write
string |
This array property is used for getting and setting the nth extension type for the active group. The index must be in the range (1, NumTypes). The extension type must be in the format "[description] *.extension" where description is the text that appears in the Files of Type combination box and extension is used to determine what files are displayed.
|
Methods:
Method |
Description |
System.fileExt.addGroup(groupName) |
Add (create) a new File Extension group. groupName is the name that will be used to identify the group and the types of files it will contain. Each group name must be unique. On success, the added group becomes the active group and the NumGroups property is incremented. Return value is zero for success and non-zero for error.
|
System.fileExt.addType(extensionType) |
Add (create) a new Extension type. extensionType is the Extension type string. The string must be in the format: "[description] *.extension" where description is the text displayed in the Files of Type combination box and extension is the extension of the files to display in the file list box. On success, the NumTypes property is incremented. Return value is zero for success and non-zero for error.
|
groupIndex) |
Delete a File Extension group by name or index. On success the NumGroups property is decremented. Return value is zero for success and non-zero for error.
|
System.fileExt.getType(extension) |
Returns the index of the system.fileExt.typen$ property that represents the file type specified in extension. If no file type represents the extension then zero is returned. Example extension is BMP, EPS, JPG, etc. This is not case sensitive.
|
System.fileExt.reset() |
Delete all File Extension groups. Numeric properties are set to zero and string properties are set to blank (""). Return value is always zero. system.fileExt.setTypeExts(groupName, extension) Set the extensions for the extension type system.fileExt.typen$. If groupName does not exist, it is added.
For example: If the active file extension group is set as follows: system.fileExt.type1$ = "[Image (*.BMP)] *.BMP"; And then you execute the following: system.fileExt.setTypeExts("Image", tif jpg); Then the type will look as follows: system.fileExt.type1$="[Image (*.TIF,*.JPG)] *.TIF;*.JPG";
|
Examples:
Example1: The following script prints out all extension groups and their extension types:
for(ii=1;ii<=system.fileext.numgroups;ii++) {
system.fileExt.ActiveGroup=ii;
%A=system.fileExt.ActiveGroup$;
type Group:$(ii) %A;
for(jj=1;jj<=system.fileExt.numTypes;jj++) {
%B=system.FileExt.type$(jj)$;
type ...Type:$(jj) %B;
}
}
Example2:
The following script add an extension group which include a single type:
system.fileExt.addGroup(myExtGrp);
system.fileExt.ActiveGroup=system.fileext.numgroups;
system.fileExt.numTypes++;
system.fileExt.type1$="[My Init File (*.mif)] *.MIF";
See Also:
System.Project, System.Path, Dir, Cdset
|