# 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](MainInterfaceScripts.md) script because there is no current profile.

All the example code below is written in using the [Pascal](PascalScriptLanguage.md) 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](SBVariables.md#function_getproperty_propname__propdefault__internal__) and [GetProfileProperty](SBVariables.md#function_getprofileproperty_profilename__propname__propdefault__internal__) 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](SBVariables.md#function_setglobalproperty_propname__newpropvalue__)

Some internal properties are encrypted, so you must decrypt the result using the [SBSystem.DecryptString](SBSystem.md#function_decodestring_str__) 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](SBVariables.md#function_setprofileproperty_profilename__propname__newpropvalue__)

Some internal properties are encrypted, so you must decrypt the result using the [SBSystem.DecryptString](SBSystem.md#function_decodestring_str__) 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](SBVariables.md#function_setproperty_propname__newpropvalue__)

Note that this function will do nothing if called from a Main Interface script. You must use the [GetProfileProperty](SBVariables.md#function_getprofileproperty_profilename__propname__propdefault__internal__) function.

Some internal properties are encrypted, so you must decrypt the result using the [SBSystem.DecryptString](SBSystem.md#function_decodestring_str__) 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](SBVariables.md#function_setproperty_propname__newpropvalue__), [GetVarName](SBVariables.md#function_getvarname_idx__var_value__), and [SetVar](SBVariables.md#function_setvar_varname__newvarvalue__)

**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](SBVariables.md#function_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](SBVariables.md#function_setproperty_propname__newpropvalue__) and [SetProfileProperty](SBVariables.md#function_setprofileproperty_profilename__propname__newpropvalue__) because those are used with profiles (the property is profile specific).

Note that PropName must be a single property name. See [GetGlobalProperty](SBVariables.md#function_getglobalproperty_propname__propdefault__internal__) for retrieving global property values.

If you want to store the value encrypted, see the [SBSystem.EncryptString](SBSystem.md#function_encryptstring_str__) function.

See [DeleteGlobalProperty](SBVariables.md#procedure_deleteglobalproperty_propname__) 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](SBVariables.md#function_setproperty_propname__newpropvalue__) except a profile can be specified. See [GetProfileProperty](SBVariables.md#function_getprofileproperty_profilename__propname__propdefault__internal__) for retrieving property values from a specific profile and [DeleteProfileProperty](SBVariables.md#procedure_deleteprofileproperty_profilename__propname__) to delete properties from a speficic profile.

If you want to store the value encrypted, see the [SBSystem.EncryptString](SBSystem.md#function_encryptstring_str__) 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](SBVariables.md#function_getproperty_propname__propdefault__internal__) for retrieving property values.

See [DeleteProperty](SBVariables.md#procedure_deleteproperty_propname__) to delete properties, and [SetProfileProperty](SBVariables.md#function_setprofileproperty_profilename__propname__newpropvalue__) 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](SBSystem.md#function_encryptstring_str__) function.

Note that this function will do nothing if called from a Main Interface script. You must use the [SetProfileProperty](SBVariables.md#function_setprofileproperty_profilename__propname__newpropvalue__) 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](SBVariables.md#function_getvar_varname__)

**procedure DeleteGlobalProperty(PropName);**

**PropName:** The name of the property to delete

This subroutine deletes a global property (setting) value. This is different from [DeleteProperty](SBVariables.md#procedure_deleteproperty_propname__) and [DeleteProfileProperty](SBVariables.md#procedure_deleteprofileproperty_profilename__propname__) 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](SBVariables.md#procedure_deleteproperty_propname__)

**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](SBVariables.md#procedure_deleteprofileproperty_profilename__propname__) function.

All Content: 2BrightSparks Pte Ltd © 2003-2026
