Using GetSizes in a script

I'm customising a hotkey to toggle the MD5sum columns on/off, and when enabled, use


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

	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;

@@toggle:set COLUMNSTOGGLE=md5sum
@if:set COLUMNSTOGGLE=md5sum

and it worked perfectly.

Is this a bug? Or am I misunderstanding how the Command object interacts with selected files?


We need to investigate further to work out exactly what's going on, but on first glance it doesn't look like you're doing anything wrong in your script.

This will be fixed in the next update.

Thanks for this. I wanted the scripting interface so I could "update" selected checksums rather without having to close and
reopen the md5 column. (The same way You can use Ctrl-L to update sizes on selected files)