Converting Visual Basic Scripts to Basic Scripts

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Converting Visual Basic Scripts to Basic Scripts

 

SyncBackPro V9 introduced a new scripting engine that supports both Basic and Pascal. Although the new Basic scripting language is very similar to Visual Basic Scripting, it is not identical. Although 32-bit SyncBackPro V8 (and newer) still supports the old Visual Basic scripting, the 64-bit version of SyncBackPro cannot use Visual Basic 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 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 Visual Basic 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.:
 
FoldersEnum:=TEnumVariant.Create(Folder.SubFolders);
try
 while FoldersEnum.ForEach(SubFol) do begin
   If not SBLocation.AddDirEx2(SubFol.Name, SubFol.Attributes, SubFol.DateLastModified, SubFol.DateCreated, '') then
     Exit;
 end;
finally
 FoldersEnum.Free;
end;
 

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 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 that parameters on a call to 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:
 
DO
 ' Code
LOOP
 
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
 

 

All Content: 2BrightSparks Pte Ltd © 2003-2024