File equivalent of {rightpath}/{leftpath}

I am on a quest to create a unified DIFF button. so my thoughts

What I want to do is essentially combine steps 1,2,3 from Beyond Compare buttons

  1. for comparing two files selected in different file displays:
    1.1 for comparing two files with identical names in different file displays:
  2. for comparing two files within same lister:
  3. for comparing two folders in two different file displays:

I use leo optimization for combine one and three, but it only works with files of identical names File equivalent of {rightpath}/{leftpath}
(i.e. 1.1) and not for the general case 1

The logic is simple. Here's some pseudocode

if more than 1 file selected in source
 @set args={allfilepath} (handle case 2)
else if no {destfilepath} exists, 
  @set args= {leftpath}{file} {rightpath}{file} (handles case 1.1 and 3)
  else 
   @set args= {filepath} {destfilepath} (handles case 1)

"%app%/command.exe" {$args}

other thoughts
How to check if any files are selected in dopus commands?
does
@ifset:{destfilepath}
this work?

Also how can you set a variable for the entire toolbar?
Do you have to use a usercommand?