Help > Indexes > Indexing Rules > Scripting Rules > Utility Functions

Utility Functions

These functions are available to your Perceptive Enterprise Search script.

Sub Alert(Message)

Show a message box containing the message text.  Not recommended for Perceptive Enterprise Search.

Parameters

Message
String expression displayed as the message in the dialog box.

Response - populate the response object with the metadata for the document.  Response properties/methods are:

Function Base64Decode(EncodedString)

The Base64Decode method decodes a string from base64.

Parameters

EncodedString
The base64 encoded string to decode.

Returns

Returns the value base64 decoded.

Remarks

Base64 is a method of encoding binary data. Base64 encoding divides three bytes of data into four bytes of ASCII text, making the resulting file size approximately 33% larger.

Function Base64Encode(String)

The Base64Encode method encodes a value into a base64 encoded string.

Parameters

String
The value to base64 encode

Returns

Returns the base64 encoded value.

Remarks

Base64 is a method of encoding binary data. Base64 encoding divides three bytes of data into four bytes of ASCII text, making the resulting file size approximately 33% larger.

Function CheckSum(Value)

Checksums (CRC) the given value, returning a numeric representation of the data. This can be used to determine when two values have changed.

Parameters

Value
Contains data to be checksummed. Can be a string, array or numeric value.

Returns

Returns the CRC of the value

Remarks

A checksum is a calculated numeric value based on the content of the data, this value can be stored then used at a later time for comparison to see if content has changed.

Function Decrypt(Value)

Decrypts a value previously encrypted with Encrypt function.

Parameters

Value
Contains the string that is to be decrypted.

Returns

Returns the decrypted string.

Function Encrypt(Value)

Provides basic encryption for storing sensitive data within your scripts.

Parameters

Value
Contains the string that is to be encrypted.

Returns

Returns the encrypted string.

Function ExtractFileExtension(Filename)

Returns the extension portions of a file name, including the ".".

Parameters

Filename
Contains the filename whose extension is to be returned.

Returns

Returns the extension of the filename including the period (.).  Returns empty string for files with no extension.

Function ExtractFileName(Filename)

Extracts the name and extension parts of a file name.

Parameters

Filename
Filename or path from which the filename should be extracted.

Returns

Returns the filename and extension of the file.

Remarks

The resulting string is the rightmost characters of Filename, starting with the first character after the colon or backslash that separates the path information from the name and extension. The resulting string is equal to Filename if Filename contains no drive and directory parts.

Function ExtractFilePath(Filename)

Returns the drive and directory portions of a file name.

Parameters

Filename
Filename or path from which the file path should be extracted.

Returns

Returns the path of the file.

Remarks

The resulting string is the leftmost characters of Filename, up to and including the colon or backslash that separates the path information from the name and extension. The resulting string is empty if Filename contains no drive and directory parts.

Function FileExists(Filename)

Returns a boolean value indicating if the specified file exists on disk.

Parameters

Filename
The name of the file whose existence is to be determined.

Returns

Boolean indicating the existence of the file.

Remarks

FileExists returns true if the file specified by Filename exists. If the file does not exist, FileExists returns false.

Function FileProperties(Filename)

Returns a list of all NTFS file properties stored for the given document.

Parameters

Filename
Filename of the document whose file properties are to be returned.

Returns

Returns a dictionary of properties for the given file.

Example
Set Props = FileProperties( "c:\documents\resume.doc" )

For I = 0 to Props.Count-1
    Name = Props.Keys(I)
    Value = Props(I)
Next

Function HTMLDecode(Value)

Removes HTML encoding from the given string.

Parameters

Value
Specifies the text to be HTML decoded.

Returns

Returns the text html decoded.

Remarks

The HTML decoding process decodes HTML entities back into the corresponding characters, for example &lt; becomes <, &gt; becomes >.

Function HTMLEncode(Value)

Applies HTML encoding to the given string. This method ensures that text is safe to display inside HTML templates.

Parameters

Value
Specifies the text to be HTML encoded.

Returns

Returns the text html encoded.

Remarks

HTMLEncode converts characters as follows:

Function ISYSPath

Returns the path to the Perceptive Enterprise Search installation.

Returns

Returns the path where Perceptive Enterprise Search is installed.

Sub TypeLib(TypeLibrary, Major, Minor)

Loads the type library information, this is useful to access named constants contained within a third party COM object library.

Parameters

TypeLibrary
The registered GUID of the type library.

Major
[optional] The major version number of the type library.

Minor
[optional] The minor version number of the type library.