Timing issues using Select or Go REFRESH

Hi masters! o)

I'm experiencing some weird issues in conjunction with refreshing a tab and afterwards selecting items.
I noticed that injecting some DOpus.Delay(~300); calls helps, but you may agree, delaying is no option for solid engineering. o)

It seems, some of the issues I see are related to the Go REFRESH command.

"Go REFRESH=source" takes around 300 ms, while
"Go REFRESH=dest" takes just 10-20ms.

I switch source/dest before to always refresh the same location of course.
I assume, the quick return when using REFRESH=dest is why a following command does not run reliably?

Any ideas or hints appreciated! o)
Thanks in advance, tb!

Find two buttons attached which refresh source/dest and measure the time passed by.

<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Refresh Source</label> <icon1>#newcommand</icon1> <function type="script"> <instruction>@script jscript</instruction> <instruction /> <instruction>function OnClick(data) {</instruction> <instruction> var start = new Date().getTime();</instruction> <instruction> data.func.command.RunCommand(&quot;Go refresh=source&quot;);</instruction> <instruction> DOpus.Output(&quot;Refreshing SOURCE took: &quot; + (new Date().getTime()-start));</instruction> <instruction>}</instruction> </function> </button>

<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Refresh Dest</label> <icon1>#newcommand</icon1> <function type="script"> <instruction>@script jscript</instruction> <instruction /> <instruction>function OnClick(data) {</instruction> <instruction> var start = new Date().getTime();</instruction> <instruction> data.func.command.RunCommand(&quot;Go refresh=dest&quot;);</instruction> <instruction> DOpus.Output(&quot;Refreshing DEST took: &quot; + (new Date().getTime()-start));</instruction> <instruction>}</instruction> </function> </button>

Refreshing the source probably takes longer because more things have to be updated in response to it. (e.g. The state of toolbar items.) Just a guess, though.

It shouldn't matter how long the refresh takes if something is supposed to be synchronous and run after it. What are the details of what's going wrong?

It's a "Select FROMSCRIPT MAKEVISIBLE" that fails.
Although it selects items (most of the time), it very often does not "make them visible" unless I add a lot of delays here and there.
This is quite easy to reproduce here (in a more complex script though) and does occur especially for a tab that is in "dest" mode.

I recently mentioned another problem for lister/tab.Update() - it might be related. Out of sync properties (Viewerpane status e.g)
My current impression is, that using commands that work on a tab/lister (Set VIEWPANE/CHECKBOXMODE etc.), are not safe to use from the scripting side and the Update() methods don't seem to help out.

Refreshing the destination with a 1500% speed increase just made me suspicious again.

This is what I use to toggle checkbox mode, because after a call to tab.Update(), tab.selstats does not always reflect the change.
It even seems as if I need to call Update() repeatedly to eventually continue. Although this appears to not directly relate to this topic, I cannot help to think it does.

/////////////////////////////////////////////////////////////////////// function SwitchCheckboxMode( cmd, truefalse, tab){ var targetState = "off"; if (truefalse) targetState = "on"; cmd.SetSourceTab(tab); cmd.RunCommand('Set CheckboxMode='+targetState); tab.Update(); var abort = 0; while ((truefalse != tab.selstats.checkbox_mode) && (abort++ < 100)){ Debug('E Setting CheckboxMode failed to set:' + tab.selstats.checkbox_mode + " target:"+targetState); DOpus.Delay(10); tab.Update(); } if (abort) Debug('E TOOK: '+ abort*10 +' milliseconds!'); return tab.selstats.checkbox_mode; }

MakeVisible may be a special case as there are some asynchronous events happening after a folder refresh which may affect that.

Turning off Preferences / File Displays / Options / Automatically select first file in folder (except in Power Mode) (and the similar option specific to Power Mode, if you use that) may help, although there may be other causes.

Thanks! o) Unfortunately, I don't have any of these options enabled. If these timing/asynchronous issues were not present, the scripting engine would really allow to reach another level of control. A solution to this special case would be a Go REFRESH MAKEVISIBLE native command btw., maybe that is easier to reach than full synchronousity? Just thinking of course. o)

If you have more hints or another option in mind, that maybe eases the effect, I'm all ear! o)

Embedded commands might work, although I'm not sure if they fix this, or if you can run them from the script command object. I've never tried either.

So you mean something like?:

Go REFRESH=source [ Select "events" ]
I had a quick test, it refreshed the tab, but did not select the "events" folder. If I remember correctly, not all commands support embedded functions, right? I'd need "Go NEW" e.g., to have the embedded part run I guess, but what I try to do must not open a new lister or tab..

Interesting approach nonetheless, thanks! o)

Maybe Refresh doesn't support them, yeah. I guess you could open a new tab and close the existing one.

Why do you need to force a refresh? So files created by the script have been seen and can be selected?

I refresh manually, because there are changes to file/folder attributes, for which DO does not start to query scripted columns or labels (it does so for a renamed/touched file e.g.) Another reason is network locations not being uptodate, changed scripts and thereby changed column values and often it's just "to make sure".

I actually don't mind refreshing, but the current selection and scrolling position always gets lost, which is a bummer.
I did the "RefreshKeepSelection" command because of this and I currently try to make it more bullet-proof for all scenarios.
Once you get used to a REFRESH not messing with your selection, you really wonder how you could get along without it! o)

Replacing the current tab is a too heavy operation for a having just a quick refresh I think.
You'd need to rebuild the whole tab to not pull your hair (vars, columns, viewmode, checkboxes etc.).