How to update File Function progress window and show individual filenames

Hi all and happy new year,

This is something I've observed for most custom scripts, which start script functions which often call external programs but not necessarily. Currently I'm developing some user columns which first call an external prog. No matter what I select as the command parameter file, file$, allfile, allfile$ or modifiers, @sync, @async... the progress dialog always gets stuck at the first file selected. If I understand correctly, file/file$ call a script separately once for each file, so I'm expecting the dialog to show which file is currently being passed to my script, but regardless of how long the operation takes, it always shows first file.

I usually loop over selected items like this:
for (var e = new Enumerator(scriptCmdData.func.sourcetab.selected); !e.atEnd(); e.moveNext()) {...}
Is there any way to report back to DOpus from the loop or method which file is currently being processed? How do I show the individual file names? Any sample script?

If you mean from scripting, there is a progress dialog object which scripts can use to control what is shown in the progress dialog.

If your script-command is looping through all the selected files itself then it does not make sense to pass {file$} to it as an argument, since it is ignoring that and just looping through the selection, and it would potentially result in the script being run for every file for every file (i.e. if 10 file are selected, it would be run 10 times, and do each file 10 times, which isn't what you want).

it does not make sense to pass {file$} to it as an argument, since it is ignoring that and just looping through the selection

Is there any simple way of passing a single file at a time to a command and process only that one, and pass the next one and so on, so that I can continue to use file$ or whatever you'd suggest?

Custom dialogs are fine and well, but I can adjust other scripts much faster according to your suggestion, than programming a new progress dialog for each custom script.

Scripts can work however you want them to, it's just a matter of making them look at the arguments they are passed instead of looping through the selected files in the lister.

LOL, no doubt scripts do what we tell them to do :smiley:

In the meantime, I've defined my command as:

cmd.name        = 'CuCustomColumnSave';
cmd.template    = 'FILE/O';

adjusted my button to:

CuCustomColumnSave FILE={file$}
@nodeselect

Now if I select multiple files and call it, I still get only the 1st file and method is called only once. Passing FILE={allfile$} passes "{allfile$}" as string. If I understand it correctly using FILE/M would also pass a vector, i.e. all selected files at once, that's very similar to what I already do.

How do I call the script once for each selected file? But regardless of that, what I'm really asking is for a sample script which shows the file name in the progress dialog. I want to make sure that the progress dialog DOpus shows can really show individual names and does not simply show a placebo dialog.

This seems to be a restriction of script-addins to me.

If I define a user command directly via DOpus Customize like below, and select multiple files, the command is indeed called once for each file.

But the command I'm implementing is in a script-addin as .js file because it consists of too many methods. And I cannot get my command to get called once for each selected file. Any idea?

I see what you mean now.

You can work around it by running the script command via dopusrt:

dopusrt /acmd CuCustomColumnSave FILE={file$}

Maybe we can make it work automatically as well. Need to look at what's happening in more detail. But that should make things work for now.

1 Like

dopusrt is a real gem of a tool but in this case it's not for me for few reasons: The script becomes very slow and DOpus becomes unresponsive. And a progress dialog popup shows up and closes, but the script is still running in the background long after it's closed.

I looked at custom dialogs, hoping there'd be a progress bar control. Alas, there isn't. An alternative I thought is a static text as header "x of y files processed" and a scrolling multiline text view below where I put a new line for each file. Not in scope though.

I'll live with the current progress dialog with 1st file being stuck, but would love to see it working in future. I mean it's there, it's shown automatically, then it should be possible to control it somehow :smiley: And as for scripts being called separately once for each file, take your time. I'm just surprised that nobody has realized it before.

Anyway, thanks so far!

There is the progress dialog object I mentioned earlier: https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Progress.htm

1 Like

Of course! I was too focused on main issue and overlooked your message. 99% of the time what people ask for is already there in Opus :smiley:

1 Like