running a profile on conditions

General Discussion in English
Post Reply
PeterC
Posts: 20
Joined: Thu Jan 05, 2023 11:18 pm

running a profile on conditions

Post by PeterC »

Is it possible to have a profile run only if another specific one is not running?

tobias
Posts: 1603
Joined: Tue Mar 31, 2020 7:37 pm

Re: running a profile on conditions

Post by tobias »

Hello,
yes, please see the OnCanRunProfile Sample Script on
https://www.syncovery.com/pascalscript/

PeterC
Posts: 20
Joined: Thu Jan 05, 2023 11:18 pm

Re: running a profile on conditions

Post by PeterC »

Thank you for the quick response.

This is the code I've added to the Global PascalScript via the Program Settings dialog, tab sheet Advanced

const p1='Daily Backup Tornado-X\UserData--Wombat';
      p2='30-min Backup C-UserData--X';

function OnCanRunProfile(const ProfileName:UnicodeString; var PostponeBySeconds:Integer):Boolean;
begin
  if ProfileName=p1 then
     Result:=not ProfileRunning(p2)
  else
     if ProfileName=p2 then
       Result:=not ProfileRunning(p1)
     else
       Result:=true;
  if not Result then
     PostponeBySeconds:=60;
  end;

Unfortunately I get an error reported by my profiles "Could not compile the Pascal script in this profile. [Error} (2:1): Syntax error"

tobias
Posts: 1603
Joined: Tue Mar 31, 2020 7:37 pm

Re: running a profile on conditions

Post by tobias »

Maybe you need to update Syncovery, or you have pasted some invalid character.

Please try replacing it with this script:

Code: Select all

const p1='Daily Backup Tornado-X\UserData--Wombat';
      p2='30-min Backup C-UserData--X';

function OnCanRunProfile(const ProfileName:UnicodeString; var PostponeBySeconds:Integer):Boolean;
begin
  if ProfileName=p1 then
     Result:=not ProfileRunning(p2)
  else
     if ProfileName=p2 then
       Result:=not ProfileRunning(p1)
     else
       Result:=true;
  if not Result then
     PostponeBySeconds:=60;
  end;

PeterC
Posts: 20
Joined: Thu Jan 05, 2023 11:18 pm

Re: running a profile on conditions

Post by PeterC »

I've upgraded to the latest version and copy/pasted your code and it's all working ok now.

Thank you.

Post Reply