Global Script Functions

Global Scripting Functions

Apart from standard VBScript/JavaScript/PowerShell functions, Automise exposes the following global functions:

Method Call Example Description
<br>procedure SaveProject;<br> <br>SaveProject;<br> Saves the current Automise project.
<br>function ExtractFilePath(filename : string) : string;<br> <br>var path = ExtractFilePath('C:\\Temp\\TextFile.txt'); // path == 'C:\Temp\'<br> Extracts the path (minus the filename) from a fully qualified filename. The trailing backslash will be included in the returned string.
<br>function ExtractFilename(filename : string) : string;<br> <br>var filename = ExtractFilename('C:\\Temp\\TextFile.txt'); // filename == 'TextFile.txt'<br> Extracts the filename (minus the path) from a fully qualified filename.
<br>function ExtractFileDrive(filename : string) : string;<br> <br>var drive = ExtractFileDrive('C:\\Temp\\TextFile.txt'); // drive == 'C:'<br> Extracts the filename drive letter. No trailing backslash is included in the returned string.
<br>function ExtractFileExt(filename : string) : string;<br> <br>var ext = ExtractFileExt('C:\\Temp\\TextFile.txt'); // ext == '.txt'<br> Extracts the file extension including the period.
<br>function ExpandUNCFilename(filename: string) : string;<br> <br>var unc = ExpandUNCFilename('C:\\Temp\\TextFile.txt'); // unc == '\\Server\Temp\TextFile.txt'<br> Expands any pathname to either the fully qualified UNC pathname.
<br>procedure FBSetCaption(value : string);<br> <br>FBSetCaption('Compiler Running...');<br> Sets the titlebar caption for Automise FBSetCaption does nothing when Automise is run from the scheduler.
<br>function GetClipBoardText : string;<br> <br>var clipText = GetClipBoardText;<br> Gets the text currently on the clipboard. GetClipBoardText does nothing when Automise is run from the scheduler.
<br>procedure CopyToClipBoard(const clipText : string)<br> <br>CopyToClipBoard(clipText);<br> Copies the string to the clipboard. CopyToClipBoard does nothing when Automise is run from the scheduler.
<br>function FBFormatDateTime(format : string; datetime : DateTime) : string;<br> <br>var formattedDate = FBFormatDateTime('dd-mm-yyyy', FBVariables.Today); // formatedDate == '25-02-2015'<br> Formats the specified DateTime as a string. See DateTime Format Strings
<br>function StrToDate(date : string) : DateTime;<br> <br>var fridaysDate = StrToDate('25/02/2015'); // fridaysDate == 42060<br> Converts a string into a Date.
The default format in the UK is day/month/year, where:
The day must be 1..31 (depending on month/year)
The month must be 1..12
The year must be 0..9999 (optional)
<br>function StrToDateTime(datetime: string) : DateTime;<br> <br>var fridaysDateTime = StrToDateTime('25/02/2015 8:31:23');<br> Converts a string into a DateTime.
The default format in the UK is day/month/year hour:minute:second.msec, where:

The day must be 1..31 (depending on month/year)
The month must be 1..12
The year must be 0..9999 (optional)
The hour must be 0..23
The minute must be 0..59 (optional)
The second must be 0..59 (optional)
The milli-sec must be 0..999 (optional)
<br>function ChangeFileExt(filename : string; newext : string) : string;<br> <br>var file = ChangeFileExt('C:\\Temp\\TextFile.txt', ".doc"); // file == 'C:\Temp\TextFile.doc'<br> Changes the file extension of filename to the specified new extension.
<br>function IncludeTrailingPathDelimiter(text : string) : string;<br> <br>var path = IncludeTrailingPathDelimiter('C:\\Temp'); // path == 'C:\Temp\'<br> Appends a trailing path delimiter to the specified directory if required.
<br>function ExcludeTrailingPathDelimiter(text : string) : string;<br> <br>var path = ExcludeTrailingPathDelimiter('C:\\Temp\\'); // path == 'C:\Temp'<br> Removes a trailing path delimiter from the specifed directory if it exists.
<br>function ExpandFilename(shortFilename : string) : string;<br> <br>var path = ExpandFilename('C:\\Progra~1\\TextFile.txt'); // path == 'C:\Program Files\TextFile.txt'<br> Expands the short filename and path to the fulll filename/path
<br>function FileExists(filename : string) : boolean;<br> <br>var exists = FileExists('C:\\Temp\\TextFile.txt'); // exists == true<br> Returns true if the specified file exists
<br>function GetCurrentDir : string;<br> <br>var currDir = GetCurrentDir; // currDir == 'C:\Temp\'<br> Returns the current working directory
<br>function SetCurrentDir(dir : string) : boolean;<br> <br>SetCurrentDir('C:\\Temp\\');<br> Set the current working directory
<br>function ExpandRelativePath(filepath : string; relativeto : string) : string;<br> <br>var path = ExpandRelativePath('..\\TextFile.txt', 'C:\\Temp\\Depth1\\')' // path == 'C:\Temp\TextFile.txt'<br> Returns the full path and filename of the file specified with the relative path.
<br>function NewGUIDString : string;<br> <br>var guid = NewGUIDString; // guid == '{CB938C2E-C805-47CF-8935-5AFCC85640A9}'<br> Creates a new GUID (Globally Unique Identifier). The identifier will be in the format .
<br>function ExtractMajorVer(major : string) : string;<br> <br>var major = ExtractMajorVer('3.0.23.1'); // major == '3'<br> Extracts the Major Version value from a version string.
<br>function ExtractMinorVer(minor : string) : string;<br> <br>var minor = ExtractMinorVer('3.0.23.1'); // minor == '0'<br> Extracts the Minor Version value from a version string.
<br>function ExtractReleaseVer(release : string) : string;<br> <br>var release = ExtractReleaseVer('3.0.23.1'); // release == '23'<br> Extracts the Release Version value from a version string.
<br>function ExtractBuildVer(build : string) : string;<br> <br>var build = ExtractMajorVer('3.0.23.1'); // build == '1'<br> Extracts the Build Version value from a version string.
<br>function MessageBox(text : string; title : string; style : integer) : integer;<br> <br>var msgResult = MessageBox('Do you want to cancel the build', 'Cancel Build', mbOKCancel); // msgResult == mrOK<br> Displays a message box to the user. See MessageBox Constants.
<br>procedure Alert(message : string);<br> <br>Alert('Click OK when ready to proceed.');<br> Displays an alert dialog to the user.
<br>function EncryptString(text : String) : String;<br> <br>var encryptedText = ExcryptString('password');<br> See DecryptString
<br>function DecryptString(encodedText : String) : String;<br> <br>var decryptedText = DecryptedString(encryptedText);<br> Two functions to scramble and descramble passwords, etc. (ie for storage in project files.). Uses blowfish with a hardcoded key. Not to be considered secure.
<br>procedure SetEstimatedProgressTotal(progress : Integer);<br> <br>var SetEstimatedProgressTotal(251);<br> Use to set the estimated total number of actions (for the Build Summary estimated progress bar.). See Estimated Progress for an example script.