I'm customising a hotkey to toggle the MD5sum columns on/off, and when enabled, use
GetSizes NODESELECT MD5 USEHASHCACHE
to populate the MD5 sums of the selected files.
I started with the following; (Its very early scripting days for me still)
function OnClick(clickData)
{
var cols = clickData.func.sourcetab.format.columns
var enum_cols = new Enumerator(cols)
var cmd = clickData.func.Command
cmd.deselect = false
cmd.SetFiles( clickData.func.sourcetab.selected_files )
var found = 0
while( !enum_cols.atEnd() ) {
if( enum_cols.item() == "md5sum" ) {
found = 1
}
enum_cols.moveNext()
}
if( found == 1 )
{
DOpus.Output("Found it.. must hide column")
cmd.RunCommand("set format=!folder")
} else {
DOpus.Output("Not Found.. must show column")
cmd.RunCommand("getsizes nodeselect md5 usehashcache")
}
}
It successfully toggled the MD5sum column on/off, logging the correct 'Found'/'Not Found' messages, but if any files were
selected, NO md5 sums would be populated. If nothing was selected, all MD5 sums would be calculated, which wasn't quite what I wanted.
I then tried the same thing in VB script, and got the same results. I drew the conclusion that the GetSizes function doesn't quite work when called from Run() or RunCommand().
Finally, I tried the following;
@nodeselect
@@toggle:set COLUMNSTOGGLE=md5sum
@if:set COLUMNSTOGGLE=md5sum
Set COLUMNSTOGGLE=md5sum
@if:else
GetSizes NODESELECT MD5 USEHASHCACHE
and it worked perfectly.
Is this a bug? Or am I misunderstanding how the Command object interacts with selected files?
Thanks