Scripting: dialogs

Hey GPD's...

Hadn't really played too much with any of the dialog object stuff... but have a few questions (about both the proper 'Dialog' object as well as the 'Progress' dialog object), based on my experience in writing the script here.

For the 'Progress' object:
First, I was unsure about this note in the help (destroy the object):

...so, in my use of this - I show the progress dialog (got it from using ScriptCommandData.func.command.progress), run a command (using ScriptCommandData.func.command.RunCommand), and then based on the note above, I do a Progress.Hide followed by a Set objProgress = Nothing. It seems to work, but is doing a Set Nothing on the Progress object variable what was meant by 'destroying' the object?

Second, while I was happy that the progress dialog increments both a percentage ticker in the dialog title as well as the progress bar in the main dialog space... as the 'Clipboard COPYNAMES=hash*' command does its work. But from the objects documentation, I wasn't expecting it to work! I thought I needed to control all of that 'progress' indication using the various Set/Step methods documented. So... happy, but unclear why it's working out so well :slight_smile:.

For the 'Dialog' object:
In my case, I'm getting the object from ScriptCommandData.func.Dlg... but I'm sure this is common no matter how the object is created. The title gets truncated if the string data in Dialog.message isn't long enough to size the dialog window widely enough to show the whole title. I know there's some max width that can be shown in any case, but I think it'd be desirable for the Dialog.title string length to dictate the width of the dialog window (up to whatever the max width is). You can't even fake it out by padding the Dialog.message string with lots of spaces or tab chars... as it seems whitespace gets trimmed when the dialog actually gets generated.

Related to the above, any possibility of getting some sort of bool property for each of these objects to suppress the " - Directory Opus" string appended to the dialog title strings?

Besides any of that, I also couldn't see any effect from setting the Dialog.status string value (where / when is it supposed to appear)?

Lastly, this was a bit counter intuitive in the manual for the HideFileByteCounts method:

So, passing 'True' to a method called 'Hide*' means it will be SHOWN and not hidden? That seems like some kind of double-negative thing... But in any case, I didn't see any difference in the dialog regardless of passing either True or False. Maybe I'm not using some other required methods in order to get this string to be shown?

Hi steje,

I also started playing around with dialogs and came across the problems with dialog width.

It appears that whitespace doesn't get trimmed from the message but longer lines are wrapped at a certain max width, which can make the text rather hard to read. I figured out a way to work around this, but it's ugly: My dialog has a single OK button and I padded the 'OK' with lots of leading an trailing spaces. Doesn't look great, but forces the dialog to be wider, allowing for longer text lines - and also a longer dialog title, of course.

Some sort of height/width attributes for dialogs would be really useful...

The Progress dialog is a bit of a mystery to me still. It worked out great (though again, unexpectedly so) in my 'HashCompare' script... however, manually controlling the progress indication using the set and step methods for the object just don't seem to work at all. I'll try posting a stripped down version of another script I'm working on... but basically, I'm doing the following:

  • looping through a large collection of selected items, evaluating properties of folder and files in the folders
  • as I find differences of concern, I add commands to a command object (command.AddLine())
  • once I'm done with the collection, execute the potentially MULTIPLE command lines added to the object via command.Run()

What I've found is two separate problems:

  1. Even if I create a separate command object (DOpus.NewCommand) in order to create a progress dialog for use during my evaluation of the selected item collection properties, I can't get the progress meter to move as I loop through the collection. I'll try and get a basic example script posted later with comments in it about what I 'expected' to see happen, but in this case - I'm not actually running any Opus commands yet. I simply wanted a progress dialog as my script looped through a large collection of items and did other script specific stuff that could take a while to complete. So my hope was to set the total number of files being operated on via progress.SetFiles(), then increment the dialog using either or both progress.SetPercentProgress() || progress.StepFiles()... without ever actually running an Opus command using the parent command object. Shouldn't this be possible...?

  2. Once I've evaluated my list of selected items, I "may" have added multiple command lines to the command object (tried using a separate command object from the one used in the looping above). In this case, I'm not clear on what the 'expected' behavior of Opus should be... but I want to say that whether or not I saw any progress movement once I executed the command(s) (command.Run()) depended on what command is being run - but maybe I'm wrong. For instance, I couldn't get any progress movement if I added multiple (say 1,000) individual Setattr commands for each item I wanted to make a change to. When you execute many individual command lines with AddLine/Run - should Opus track progress for each individual command? Would we need a progress.full set to true in order to have two progress meters for individual command completion vs progress of the entire command queue - even though the full progress dialog seems geared for separate bytes vs file/percent completion.

I can't figure out... will post examples soon.