Profile Configuration Scripts

<< Click to Display Table of Contents >>

Navigation:  Using SyncBackPro > Technical Reference > Scripting >

Profile Configuration Scripts

 

These are functions that are defined in your Profile Configuration script and are called by SyncBackPro. The functions are called by SyncBackPro at the appropriate time. Profile Configuration scripts have access to the SBProfile, SBSystem, SBVariables, and SBHistory objects.

 

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

 


function ConfigCanClose;

 

Return value: FALSE if the setup page should not be allowed to close

 

This function is called by SyncBack to ask the script if the setup page can be closed. The script may not want the setup page to close if, for example, some settings are incorrect (however, in this case it is advised that the script simply not save invalid settings).

 

 

function ConfigCanRevert;

 

Return value: TRUE if the script supports reverting to factory defaults

 

This function is called by SyncBack to ask the script if it can revert its settings to the factory defaults. Note that it should not revert to the factory settings in this call (for that see ConfigFactoryDefaults).

 

 

function ConfigLoadSettings;

 

Return value: Return an error message on failure

 

This function is called to tell the script to load its settings and update the display to show those settings. For example:

 

// Create setup window display

procedure ConfigSetupDisplay;

begin

  SBProfile.AddEdit('The name of the process you want to have finished running', 128, FALSE, FALSE, 1);

  SBProfile.AddEdit('The number of seconds to wait before re-checking if it is still running', 10, TRUE, FALSE, 2);

end;

 

// Load settings. Return error message on failure.

function ConfigLoadSettings;

begin

  Result:='';

 

  SBProfile.SetEdit(SBVariables.GetProperty('WFProcessName', 'Notepad.exe', FALSE), 1);

  SBProfile.SetEdit(SBVariables.GetProperty('WFRetrySecs', 5, FALSE), 2);

end;

 

 

function ConfigNodeCaption;

 

Return value: The caption to use in the profile setup window

 

This function is called to get the caption to use in the profile setup window.

 

 

function ConfigSaveSettings(Silent);

 

Silent: Is TRUE if the script should not display any prompts or interact with the user

 

Return value: Return an error message on failure

 

This function is called when the script should save its settings. It should also check to make sure the settings are valid. For example:

 

// Save settings. Return error message on failure.

function ConfigSaveSettings(Silent);

begin

  Result:='';

 

  if (SBProfile.GetEdit(1) = '') then begin

    ConfigSaveSettings:='The process name cannot be empty!';

    Exit;

  end;

 

  if (SBProfile.GetEdit(2) < 1) then begin

    ConfigSaveSettings:='The retry secionds cannot be less than 1!';

    Exit;

  end;

 

  SBVariables.SetProperty('WFProcessName', SBProfile.GetEdit(1));

  SBVariables.SetProperty('WFRetrySecs', SBProfile.GetEdit(2));

end;

 

 

function ConfigWantSetupNode(IsGroup);

 

IsGroup: Pass TRUE if the profile is a group profile

 

Return value: True if a node in the setup window for the profile is required

 

Should a node in the profile setup window be created for this script to use? Note that the result should be consistent, e.g. it should not be based on what the current time is. This is because this function is called several times once the profile setup window is displayed for a profile, and each time it is called the result should be the same.

 

 

procedure ConfigButtonPressed(Tag);

 

This subroutine is called when a button on the profile settings page has been pressed.

 

NOTE: Not available when using old Windows scripting.

 

 

procedure ConfigFactoryDefaults;

 

This subroutine is called when the user has reverted to factory defaults. In this case the script should delete all the profile settings it manages. By doing this the default values will be used when the settings are read.

 

For example:

 

// Reset to factory defaults

procedure ConfigFactoryDefaults;

begin

  SBVariables.DeleteProperty('WFProcessName');

  SBVariables.DeleteProperty('WFRetrySecs');

end;

 

 

procedure ConfigSetupDisplay;

 

This subroutine is called when the script should tell SyncBack what items the setup page should have on it. For example:

 

// Create setup window display

procedure ConfigSetupDisplay;

begin

  SBProfile.AddEdit('The name of the process you want to have finished running', 128, FALSE, FALSE, 1);

  SBProfile.AddEdit('The number of seconds to wait before re-checking if it is still running', 10, TRUE, FALSE, 2);

end;

 

 

procedure ConfigUpdateConditionals;

 

This subroutine is called when an item on the profile settings page has been changed. The script can then verify the new values, enable or disable other items based on the new values, etc.

 

 

procedure InitialiseVars(Checking);

 

Checking: Passed as True if the variables are being checked to see if they exist

 

This subroutine is called when the variables are initialised when a profile is being created or modified. Checking is passed as TRUE.

 

Note that if your script is also a run-time script then this sub-routine is shared. A configuration script does not have access to the SBRunning object.

 

In the example below the variable MyScriptVar is set to a dummy value if it's a call to check if the variable is valid.

 

//

// Called very early when a profile is run (Checking is False)

// Also called in profile config when asking what variables the script sets (Checking is True)

//

procedure InitialiseVars(Checking);

begin

  if Checking then begin

    // Profile is being saved

    SBVariables.SetVar('MyScriptVar', '?');

  end else begin

    // Profile is being run

    // Do nothing

  end;

end;

 

 

 

 

 

All Content: 2BrightSparks Pte Ltd © 2003-2024