Page 1 of 1

running a profile on conditions

Posted: Thu Jan 05, 2023 11:53 pm
by PeterC
Is it possible to have a profile run only if another specific one is not running?

Re: running a profile on conditions

Posted: Fri Jan 06, 2023 12:08 am
by tobias
Hello,
yes, please see the OnCanRunProfile Sample Script on
https://www.syncovery.com/pascalscript/

Re: running a profile on conditions

Posted: Fri Jan 06, 2023 1:10 am
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"

Re: running a profile on conditions

Posted: Fri Jan 06, 2023 9:52 am
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;

Re: running a profile on conditions

Posted: Fri Jan 06, 2023 10:31 am
by PeterC
I've upgraded to the latest version and copy/pasted your code and it's all working ok now.

Thank you.