Converting VBScript Scripts to Basic Scripts
SyncBackPro V8 introduced a new scripting engine that supports both Basic and Pascal. Although the new Basic scripting language is very similar to VBScript, it is not identical. Although 32-bit SyncBackPro still supports the old VBScript scripting, the 64-bit version of SyncBackPro cannot use VBScript scripting due to limitations in the 64-bit versions of Windows. Therefore if you want your Basic scripts to work in both the 32-bit and 64-bit versions of SyncBackPro then they need to be converted to the new Basic scripting language (or the new Pascal scripting language).
The example scripts that are distributed with SyncBackPro have already been converted to the new Basic scripting language.
Below are some tips on how to convert your VBScript scripts to the new Basic language scripts:
•Change the script filename extension from .VBS to .BAS
•In the header of the script change SBLang=VBScript to SBLang=Basic
•You cannot use ForEach. Instead you must use TEnumVariant.Create, e.g.:
while FoldersEnum.ForEach(SubFol) do begin
If not SBLocation.AddDirEx2(SubFol.Name, SubFol.Attributes, SubFol.DateLastModified, SubFol.DateCreated, '') then
•You must use brackets with calls to sub-routines that have arguments (just as you must already do with functions).
•When declaring functions or sub-routines, and there are no arguments, then don't use brackets, e.g.
Sub RunAfterConfig() - This is wrong
Sub RunAfterConfig - This is correct
•When declaring functions or sub-routines, and there are variable arguments (non-constant), then prefix them with var, e.g.
Sub RunAfterConfig(constvar1, variablevar2) - This is wrong
Sub RunAfterConfig(constvar1, var variablevar2) - This is correct
•When calling functions or sub-routines that have no parameters, don't use empty brackets, e.g.:
RunAfterConfig() - This is wrong
RunAfterConfig - This is correct
•Variables do not need to be declared first but you must declare (or initialize) a variable if it is first set in the parameters on a call to a function or sub-routine.
•You cannot combine lines using an underscore (_) on the end of the line. Simply delete the underscores at the end of lines.
•You can't have:
You must end with LOOP WHILE 1=1, for example.
•Don't put comments after IF statements on the same line:
If SBProfile.GetCheckbox(3) Then ' THIS WILL CAUSE AN ERROR
If SBProfile.GetCheckbox(3) Then
' THIS IS OK
To help with compatibility with VBScript, the following functions are available in Basic scripts (refer to the MSDN documentation for the explanation of each function):
All Content: 2BrightSparks Pte Ltd © 2003-2021