SBVariables

<< Click to Display Table of Contents >>

Navigation:  Using SyncBackPro > Technical Reference > Scripting >

SBVariables

 

These are functions that can be accessed from scripts via the SBVariables object. For example:

 

SBSystem.SetProperty('MyVar', 'Value');

 

The SBVariables object is accessible from any type of script, but some functions will do nothing when used in some script types. For example, GetProperty won't work in a Main Interface script because there is no current profile.

 

All the example code below is written in using the Pascal scripting language.

 


function Count;

 

Return value: The number of variables defined

 

This function returns the number of variables defined.

 

 

function GetGlobalProperty(PropName, PropDefault, Internal);

 

PropName: The name of the property

PropDefault: The value to return if the property does not exist

Internal: Pass True to retrieve properties that SyncBack uses, otherwise it's a property created by a script

 

Return value: The value of the property (as a string) or an empty string on error

 

This function retrieves a global property (setting) value. This is different from GetProperty and GetProfileProperty because those are used with profiles (the property is profile specific).

 

Note that PropName must be a single property name.

 

To check if a property exists or not pass a default value that cannot be valid, e.g.

 

if (SBVariables.GetGlobalProperty('PropName', '!NOTEXIST!', FALSE) = '!NOTEXIST!') then begin

  // Does not exist

end else begin

  // Exists

end;

 

See also SetGlobalProperty

 

Some internal properties are encrypted, so you must decrypt the result using the SBSystem.DecryptString function.

 

 

function GetProfileProperty(ProfileName, PropName, PropDefault, Internal);

 

ProfileName: The name of the profile to read the property from

PropName: The name of the property

PropDefault: The value to return if the property does not exist

Internal: Pass True to retrieve properties that SyncBack uses, otherwise it's a property created by a script

 

Return value: The value of the property (as a string) or an empty string on error

 

This function retrieves a profile property (setting) value from a specific profile. It works the same way as GetProfileProperty except you can specify the profile.

 

See also SetProfileProperty

 

Some internal properties are encrypted, so you must decrypt the result using the SBSystem.DecryptString function.

 

 

function GetProperty(PropName, PropDefault, Internal);

 

PropName: The name of the property

PropDefault: The value to return if the property does not exist

Internal: Pass True to retrieve properties that SyncBack uses, otherwise it's a property created by a script

 

Return value: The value of the property (as a string) or an empty string on error

 

This function retrieves a profile property (setting) value. The difference between properties and variables is that properties are stored as part of the profiles settings, but variables are not. That means their value is kept between profile runs. Note that PropName must be a single property name.

 

To check if a property exists or not pass a default value that cannot be valid, e.g.

 

if (SBVariables.GetProperty('PropName', '!NOTEXIST!', False) = '!NOTEXIST!') then begin

  // Does not exist

end else begin

  // Exists

end;

 

See also SetProperty

 

Note that this function will do nothing if called from a Main Interface script. You must use the GetProfileProperty function.

 

Some internal properties are encrypted, so you must decrypt the result using the SBSystem.DecryptString function.

 

 

function GetVar(VarName);

 

VarName: A string containing variables

 

Return value: VarName with the variables expanded

 

This function retrieves a variable value. The difference between properties and variables is that properties are stored as part of the profiles settings, but variables are not. Also, variables like environment variables are set by the operating system or other programs.

 

VarValue1:=SBVariables.GetVar('%USERPROFILE%');

VarValue1:=SBVariables.GetVar('Username is %USERNAME% and profile is %USERPROFILE%');

 

See also SetProperty, GetVarName, and SetVar

 

 

function GetVarName(Idx, var Value);

 

Idx: The number of the variable to get the name of (0=first variable)

Value: Value is set to the value of the variable

 

Return value: The name of the variable, or empty string on failure

 

This function retrieves the name of a variable. The first variable is variable zero (0). SBVariables.Count returns the number of variables defined.

 

For example:

 

VarName:=SBVariables.GetVarName(0, VarValue);

 

 

function SetGlobalProperty(PropName, NewPropValue);

 

PropName: The name of the property

NewPropValue: The new value of the property

 

Return value: The new value of the property (as a string) or an empty string on error

 

This function sets a global property (setting) value. This is different from SetProperty and SetProfileProperty because those are used with profiles (the property is profile specific).

 

Note that PropName must be a single property name. See GetGlobalProperty for retrieving global property values.

 

If you want to store the value encrypted, see the SBSystem.EncryptString function.

 

See DeleteGlobalProperty to delete global properties.

 

Note that you cannot change internal SyncBack properties.

 

 

function SetProfileProperty(ProfileName, PropName, NewPropValue);

 

PropName: The name of the profile to delete the property from

PropName: The name of the property

NewPropValue: The new value of the property

 

Return value: The new value of the property (as a string) or an empty string on error

 

This function sets a profile property (setting) value for a specific profile. It works the same way as SetProperty except a profile can be specified. See GetProfileProperty for retrieving property values from a specific profile and DeleteProfileProperty to delete properties from a speficic profile.

 

If you want to store the value encrypted, see the SBSystem.EncryptString function.

 

Note that you cannot change internal SyncBack properties.

 

 

function SetProperty(PropName, NewPropValue);

 

PropName: The name of the property

NewPropValue: The new value of the property

 

Return value: The new value of the property (as a string) or an empty string on error

 

This function sets a profile property (setting) value. Note that PropName must be a single property name. See GetProperty for retrieving property values.

 

See DeleteProperty to delete properties, and SetProfileProperty to set the property for a specific profile.

 

Note that you cannot change internal SyncBack properties.

 

If you want to store the value encrypted, see the SBSystem.EncryptString function.

 

Note that this function will do nothing if called from a Main Interface script. You must use the SetProfileProperty function.

 

 

function SetVar(VarName, NewVarValue);

 

VarName: The name of the variable to set

NewVarValue: The new value of the variable

 

Return value: The new value of the variable (string) or an empty string on failure

 

This function sets the value of a profile variable. Note that variables cannot be deleted.

 

SBVariables.SetVar('MyVariable', 'The value');

 

See also GetVar

 

 

procedure DeleteGlobalProperty(PropName);

 

PropName: The name of the property to delete

 

This subroutine deletes a global property (setting) value. This is different from DeleteProperty and DeleteProfileProperty because those are used with profiles (the property is profile specific).

 

Note that PropName must be a single property name, and you cannot delete internal SyncBack properties.

 

 

procedure DeleteProfileProperty(ProfileName, PropName);

 

ProfileName: The name of the profile to delete the property from

PropName: The name of the property to delete

 

This subroutine deletes a profile property (setting) value from a specific profile. Note that PropName must be a single property name.

 

Note that you cannot delete internal SyncBack properties.

 

See also DeleteProperty

 

 

procedure DeleteProperty(PropName);

 

PropName: The name of the property to delete

 

This subroutine deletes a profile property (setting) value. Note that PropName must be a single property name.

 

Note that you cannot delete internal SyncBack properties.

 

Note that this function will do nothing if called from a Main Interface script. You must use the DeleteProfileProperty function.

 

 

 

 

 

All Content: 2BrightSparks Pte Ltd © 2003-2024