This section of the help file provides information about scripting support. Scripting is a way in which the functionality of SyncBackPro can be changed or extended by writing small scripts. A script is a set of instructions and is similar to the macro support in Microsoft Office and Java Script in web pages. It is also similar to plug-ins in other software. SyncBackPro can use scripts written in Pascal and Basic. For compatibility with older versions of SyncBackPro, VBScript is also supported. However, VBScript can only be used with the 32-bit version of SyncBackPro. The newer Pascal and Basic scripting languages (introduced in SyncBackPro V8) can be used both in 32-bit and 64-bit.
SyncBackPro comes with many example scripts.
When SyncBackPro performs certain actions it will check to see if there are any scripts installed that can be called when the action is performed. For example, whenever the profiles are listed in the main window it checks to see if there are any main interface scripts installed. If so, it checks if those scripts can be called, and if so, calls the appropriate function in the script. In technical terms, these are events. You write functions in the scripts that perform actions when certain events occur. To make it easier for the scripts to communicate with SyncBackPro it also provides helper objects, e.g. SBSystem. Depending on the script type, one or more of those helper objects will be available to the script.
To start using a script you must first install it via Preferences -> Scripts in the main menu. Note that installing a script does not automatically make the script active. If it's a Main Interface or Profile Configuration script then you must install it then go to the relevant tab and tick the checkbox for that script. To use a Runtime script in a profile, after installing it you must select it in the Scripts page of the profiles configuration. If it's a Location script then you must create (or modify) a profile so it does a backup or sync with that script.
You can also install scripts via the command line interface by simply passing the filename of the script (the same way as importing profiles).
To export a script, go to the Scripts window (via Preferences -> Scripts in the main menu), select the script (or scripts) you wish to export, then right-click on the selection and choose Export from the pop-up menu.
Editing and Checking Scripts
With V8, a new built-in script editor was included. This can only be used with Pascal and Basic scripts (VBScript is not supported). To edit a script (after it has been imported), go to the Scripts window (via Preferences -> Scripts in the main menu), select the script you wish to edit, then click the Edit button (or right-click on the script and choose Edit from the pop-up menu).
The script editor has language sensitive syntax highlighting, auto-completion (ctrl-space), parameter hints (ctrl-shift-space) and can compile scripts (ctrl-F7) to check them for errors. You can also perform test search (ctrl-f) and replace (ctrl-r).
The order in which the scripts are set to run is important. This is because, in some cases, only one script can perform an action. For example, if you have a runtime script that renames a file then obviously a file can only be renamed once. This means the first script to rename a file is the one that will rename it. Any following scripts cannot rename the file.
There are four different types of scripts:
2.Profile Configuration scripts: these are scripts that be used when configuring a profile.
3.Location scripts: these are scripts that are used with profiles to store and retrieve files. For example, you could write a location script that copies files to and from a database.
A single script file can be more than one type of script. For example, you could write a script that is both a main interface and runtime script.
SyncBackPro knows what type a script is because the script tells SyncBackPro via the Description function. It also knows what scripting language is being used based on comments in the header (first 10 lines) of a script, and failing that, the filename extension of the script file. The following languages can be used with the SBLang comment: Pascal, Basic and VBScript.For filename extensions, use .pas for Pascal, .bas for Basic and .vbs for VBScript.
VBScript support is provided for backwards compatibility only and its use is not recommended. VBScript is only supported by 32-bit SyncBackPro and it may be removed in future versions of SyncBackPro.
For example, the following Pascal script is a profile configuration, runtime, and location script:
// Use SBLang to define what language this script is in:
Function Description(var ScriptType);
Result:='All Drives Location';
ScriptType:=SCRIPTTYPE_CONFIG + SCRIPTTYPE_RUN + SCRIPTTYPE_LOCATION;
SyncBackPro makes a number of objects available to scripts to help them interface with SyncBackPro. Which objects are available depends upon the type of script:
•SBSystem: This object is accessible from any type of script. It provides general functions, e.g. hashing.
•SBVariables: This object is accessible from any type of script. It allows you access to the profile and program variables.
If you have scripts you wish to share, or want to download more scripts, visit the following web page:
All Content: 2BrightSparks Pte Ltd © 2003-2017