<< Click to Display Table of Contents >>

Navigation:  Using SyncBackPro > Technical Reference >


Previous pageReturn to chapter overviewNext page


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.



We do not provide technical support, or consultancy, for writing or debugging scripts.



Scripting Overview


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.



Installing Scripts


To start using a script you must first install it via Scripts in the burger menu burger in the main window. 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 import scripts by dragging the file onto the main window of SyncBackPro.


You can also install scripts via the command line interface by simply passing the filename of the script (the same way as importing profiles).



Exporting Scripts


To export a script, go to the Scripts window (via burger menu burger -> Scripts in the main window), select the script (or scripts) you wish to export, then click the Export button.



Editing and Checking Scripts


Starting with SyncBackPro 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 burger menu burger -> Scripts in the main window), select the script you wish to edit, then click the Edit button.




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).



Script Order


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.



Script Types


There are four different types of scripts:


1.Main Interface scripts: these are scripts that can be used with the main user interface in SyncBackPro. For example, you could write a script that adds columns to the main window.

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.

4.Runtime scripts: these are scripts that are used by profiles when they are run. For example, you could write a profile to decide on which files to copy, or add columns to the Differences window.


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:


   // SBLang=Pascal

   Function Description(var ScriptType);
     Result:='All Drives Location';


Scripts Objects


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:


SBLocation: This object is only accessible from Location scripts. It provides information and control over the source/left and destination/right locations.

SBProfile: This object is only accessible from Profile Configuration scripts. It allows you to create a page in the profile setup window.

SBRunning: This object is only accessible from Runtime scripts. Using this object you can access the runtime information of a profile.

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.

SBHistory: This object is accessible from Main Interface, Runtime and Profile Configuration scripts. Using it you can get access to the runtime history of a profile.



Scripts Online


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-2022