Global Scripting Functions
Apart from standard VBScript/JavaScript/PowerShell functions, Automise exposes the following global functions:
Method Call | Example | Description |
---|---|---|
procedure SaveProject; | SaveProject; | Saves the current Automise project. |
function ExtractFilePath(filename : string) : string; | var path = ExtractFilePath('C:\\Temp\\TextFile.txt'); // path == 'C:\Temp\' | Extracts the path (minus the filename) from a fully qualified filename. The trailing backslash will be included in the returned string. |
function ExtractFilename(filename : string) : string; | var filename = ExtractFilename('C:\\Temp\\TextFile.txt'); // filename == 'TextFile.txt' | Extracts the filename (minus the path) from a fully qualified filename. |
function ExtractFileDrive(filename : string) : string; | var drive = ExtractFileDrive('C:\\Temp\\TextFile.txt'); // drive == 'C:' | Extracts the filename drive letter. No trailing backslash is included in the returned string. |
function ExtractFileExt(filename : string) : string; | var ext = ExtractFileExt('C:\\Temp\\TextFile.txt'); // ext == '.txt' | Extracts the file extension including the period. |
function ExpandUNCFilename(filename: string) : string; | var unc = ExpandUNCFilename('C:\\Temp\\TextFile.txt'); // unc == '\\Server\Temp\TextFile.txt' | Expands any pathname to either the fully qualified UNC pathname. |
procedure FBSetCaption(value : string); | FBSetCaption('Compiler Running...'); | Sets the titlebar caption for Automise FBSetCaption does nothing when Automise is run from the scheduler. |
function GetClipBoardText : string; | var clipText = GetClipBoardText; | Gets the text currently on the clipboard. GetClipBoardText does nothing when Automise is run from the scheduler. |
procedure CopyToClipBoard(const clipText : string) | CopyToClipBoard(clipText); | Copies the string to the clipboard. CopyToClipBoard does nothing when Automise is run from the scheduler. |
function FBFormatDateTime(format : string; datetime : DateTime) : string; | var formattedDate = FBFormatDateTime('dd-mm-yyyy', FBVariables.Today); // formatedDate == '25-02-2015' | Formats the specified DateTime as a string. See DateTime Format Strings |
function StrToDate(date : string) : DateTime; | var fridaysDate = StrToDate('25/02/2015'); // fridaysDate == 42060 | Converts a string into a Date. The default format in the UK is day/month/year, where: |
function StrToDateTime(datetime: string) : DateTime; | var fridaysDateTime = StrToDateTime('25/02/2015 8:31:23'); | 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) |
function ChangeFileExt(filename : string; newext : string) : string; | var file = ChangeFileExt('C:\\Temp\\TextFile.txt', ".doc"); // file == 'C:\Temp\TextFile.doc' | Changes the file extension of filename to the specified new extension. |
function IncludeTrailingPathDelimiter(text : string) : string; | var path = IncludeTrailingPathDelimiter('C:\\Temp'); // path == 'C:\Temp\' | Appends a trailing path delimiter to the specified directory if required. |
function ExcludeTrailingPathDelimiter(text : string) : string; | var path = ExcludeTrailingPathDelimiter('C:\\Temp\\'); // path == 'C:\Temp' | Removes a trailing path delimiter from the specifed directory if it exists. |
function ExpandFilename(shortFilename : string) : string; | var path = ExpandFilename('C:\\Progra~1\\TextFile.txt'); // path == 'C:\Program Files\TextFile.txt' | Expands the short filename and path to the fulll filename/path |
function FileExists(filename : string) : boolean; | var exists = FileExists('C:\\Temp\\TextFile.txt'); // exists == true | Returns true if the specified file exists |
function GetCurrentDir : string; | var currDir = GetCurrentDir; // currDir == 'C:\Temp\' | Returns the current working directory |
function SetCurrentDir(dir : string) : boolean; | SetCurrentDir('C:\\Temp\\'); | Set the current working directory |
function ExpandRelativePath(filepath : string; relativeto : string) : string; | var path = ExpandRelativePath('..\\TextFile.txt', 'C:\\Temp\\Depth1\\')' // path == 'C:\Temp\TextFile.txt' | Returns the full path and filename of the file specified with the relative path. |
function NewGUIDString : string; | var guid = NewGUIDString; // guid == '{CB938C2E-C805-47CF-8935-5AFCC85640A9}' | Creates a new GUID (Globally Unique Identifier). The identifier will be in the format {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}. |
function ExtractMajorVer(major : string) : string; | var major = ExtractMajorVer('3.0.23.1'); // major == '3' | Extracts the Major Version value from a version string. |
function ExtractMinorVer(minor : string) : string; | var minor = ExtractMinorVer('3.0.23.1'); // minor == '0' | Extracts the Minor Version value from a version string. |
function ExtractReleaseVer(release : string) : string; | var release = ExtractReleaseVer('3.0.23.1'); // release == '23' | Extracts the Release Version value from a version string. |
function ExtractBuildVer(build : string) : string; | var build = ExtractMajorVer('3.0.23.1'); // build == '1' | Extracts the Build Version value from a version string. |
function MessageBox(text : string; title : string; style : integer) : integer; | var msgResult = MessageBox('Do you want to cancel the build', 'Cancel Build', mbOKCancel); // msgResult == mrOK | Displays a message box to the user. See MessageBox Constants. |
procedure Alert(message : string); | Alert('Click OK when ready to proceed.'); | Displays an alert dialog to the user. |
function EncryptString(text : String) : String; | var encryptedText = ExcryptString('password'); | See DecryptString |
function DecryptString(encodedText : String) : String; | var decryptedText = DecryptedString(encryptedText); | 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. |
procedure SetEstimatedProgressTotal(progress : Integer); | var SetEstimatedProgressTotal(251); | Use to set the estimated total number of actions (for the Build Summary estimated progress bar.). See Estimated Progress for an example script. |