Conditional Logic

It would be wonderful if DO could give us some conditional logic. I have a network of a PC and two laptops, all running Windows 7, and I want to have basically the same setup of DO on all three, with just a few changes peculiar to each computer. But I want to be able to copy the 'backup' file from my PC to the two laptops and 'restore' it on the two laptops, and I don't want to have to run around afterwards adjusting things that are different on the laptops.

I have sorted out the paths completely with environment variables on all three computers, so that's no problem.

But, for example, the screen sizes are different, so I want different layouts on the laptops from the PC. Thus I want to say things like:
" If [it's the PC] then [bring up this dual layout] else [bring up this single layout] endif"
and there are similar things with programmes that are only installed on one of the three machines, or directories that only exist on one of the machines.

Any chance of some rudimentary conditional logic in the near future?

You can do that using env-vars like the way you've done it with paths.

For example, this will open a layout with the same name as your computer:

Prefs LAYOUT="%COMPUTERNAME%"

Very nice! It works perfectly. Thank you very much. I had no idea that I could use environment variables in such a position.

So that solves one whole group of problems, and I already had the required environment variables at hand. The other type is launching a programme like NitroPDF that is on the PC but no on the laptops. I want to say, in conditional language:

If [it's the PC] "C:\Program Files\Nitro PDF\Professional\NitroPDF.exe" else [do nothing, or put a polite note on the screen] endif

Of course I can build the same path on the laptops and put something there, but that's inelegant. I could also use an environment variable for the full pathname of the programme, but that seems overkill.

You could create a button in Opus, set it to run in MS-DOS Batch mode, and paste the following code into it to launch NitroPDF if it's on your computer. If it's not there the "DOS Window" will tell you it doesn't exist.

@echo off IF EXIST "C:\Program Files\Nitro PDF\Professional\NitroPDF.exe" ( start "" "C:\Program Files\Nitro PDF\Professional\NitroPDF.exe" ) ELSE ( echo NitroPDF is not installed on this computer. echo Press any key to exit. pause>NUL )

That's good, and it's a genuine conditional test. But it involves having the DOS box up all the time when NitroPDF is running (unless you specifically click on it and close it), which is also inelegant.

I don't think that there is any way to close the DOS box automatically once NitroPDF starts, is there?

It would be good to be able to do it inside DO.

Well, this isn't quite the end you want,
but the global toolbars configuration is in the xml file /dopusglobaldata\ConfigFiles\toolbars.oxc .
It could be swapped out after restoring a DOpus backup file from the main computer.

[quote="Julianon"]That's good, and it's a genuine conditional test. But it involves having the DOS box up all the time when NitroPDF is running (unless you specifically click on it and close it), which is also inelegant.

I don't think that there is any way to close the DOS box automatically once NitroPDF starts, is there?

It would be good to be able to do it inside DO.[/quote]

Add @runmode hide to the top of the command and the DOS box won't appear at all.

Be careful not to use any internal Opus commands in the middle of the conditional logic as they will cause the batch file to be split up and break everything. (If you want to be extra safe, you could save a .bat file and have Opus run that instead of having the batch logic within the button itself. If you're going to use an external file you can use nicer languages like VBScript or JScript instead of batch files, too. :slight_smile: )

If you want to store external scripts, go to /dopusdata, create a Scripts folder and put them in there. Opus will include everything within that folder when it does a backup and restore. (It has to be called Scripts to be backed up.)

Another way you can get conditional logic is by "abusing" rename scripts, which is a trick to embed VBScript, JScript etc. into a button. (It really just gives you a way to avoid having the external file, so it may not be worth using here. Up to you!)

It works! Thanks very much.

I wrote a test batch file called D:\di.bat that contains an IF EXIST procedure for Disk Investigator (DI comes up quicker than NitroPDF), then wrote the following code in the DO button (using Standard Function, not MS-DOS Batch Function):

@runmode hide
@async: D:\di.bat
Toolbar NAME=*this CLOSE

This has the double effect of not bringing up the DOS box because of the @runmode hide, and of closing the floating toolbar as soon as the programme starts because of the @async:. So it all works precisely as I want.

I know DOS from years ago, but I don't know VBScript or JScript, so two more dumb questions, and I think this is all sorted out:

  1. Can I put a DOS batch file in a Scripts folder?
  2. Failing that, is there a resource on the web that expounds VBScript or JScript systematically? I read the postings "Abusing Rename Scripts" and "Rename scripts in JScript, VBScript and PerlScript" and the codes don't seem too hard. Perhaps the w3schools.com website quoted in your second posting is the best.

Yep, you can put any type of file into the Scripts folder. Anything in there will be included in config backups.

Great. I'm away. Thanks very much for your help.

Yep, you can put any type of file into the Scripts folder. Anything in there will be included in config backups.[/quote]

I use this Scripts folder a lot also, but there's just one little thing to know about it for backup purposes.
Only files that are present in the folder will be backed up... The backup process doesn't handle subfolders (for what I remember from previous versions, I didn't tried to put some subfolders again with the latest version).

I've had sub-folders in the /dopusdata\Scripts folder for quite awhile now. I'm not sure when it was that it "didn't" work, but as of any 9.5.x version of Opus, subfolders get backed up along with everything else...

Personally, I keep copies of "situation specific" buttons in a set of Scripts\sub-folders... one for VM's and another for USB export. Then when I run Opus from either a virtual machine or on another system from USB key, I'll "update" the global / common settings using the regular method (restore or re-export) and then run a button to copy the correct "situation specific" buttons from the appropriate Scripts\sub-folder.