Scripting: retrieving changed metadata values fails

When changing metadata (tags and ratings in this case) from within a script retrieving the changed values (even after doing ClickData.Func.Command.sourcetab.Update) fails. I'll get the old unchanged values.
I need to apply ClickData.Func.Command.Runcommand("Go REFRESH") to make it work.

I don't know if this is related to your problem, but I recently noticed, that Tab.Update() e.g., sometimes needs "some time". This may be true for the things you do on files as well. Look the attached function, which disables/enables the checkbox mode. It requires a while loop which waits for the Tab object to represent the changed checkbox mode status (calling Tab.Update() repeatedly in the while-loop may be not required).

I just assume you have a similar situation, where your script is "too fast" or DO not correctly synchronizing(?).
Asynchronous methods are not mentioned anywhere yet, so some kind of explanation why that is and when it happens, would be very useful.

/////////////////////////////////////////////////////////////////////////////// function SwitchCheckboxMode( truefalse, tab){ var targetState = "off"; if (truefalse) targetState = "on"; Debug(' Set CheckboxMode='+targetState); var cmd = DOpus.NewCommand(); 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:' + tab.selstats.checkbox_mode + " target:"+targetState); DOpus.Delay(10); tab.Update(); } if (abort){ Debug('E CheckboxMode final:' + tab.selstats.checkbox_mode); Debug('E TOOK: '+ abort*10 +' milliseconds!'); } return tab.selstats.checkbox_mode; }

I don't think it's a timing problem. I tried Dopus.Delay at several places with no luck. The script advances through the files in an endless loop. So coming around the corner to the first file again it should be possible to retrieve the new values after several Tab.Updates but it doesn't. Nevertheless there might be some bogus in my script because I'm no professional.

If you want to test my script or have a look at the code I'd be glad to send you the current version by mail. It allows to show picture metadata and edit/show tags, ratings and user description while viewing files in fullscreen mode with the standalone viewer. It's working pretty nice now with a transparent dialog window and several options where you can adjust what exactly you want to have. At the moment abr is my first test person and he's very glad with it.

Yes, let me see that. Must install autohotkey then as well I think, doable.
Please add a note/approx. linenumber where the problem is located: mb_code a@t

You should use fsutil.GetMetadata to get the metadata for files if you've modified them in the script and need to ensure you get a new version of the metadata that reflects the just-made changes.

Thanks for the hint. I'll try (& error :smiley:) to use fsutil.GetMetadata.

I wrote the line DOpus.FSUtil.GetMetadata(item) and DOpus immediately crashed (Thread 'dopusrunscriptthread'). Something wrong with this? DOpus.FSUtil.Resolve is working fine. A bug?

I can try to look at it if you could zip up the crash dump, script and a file that you see the crash on when loading its metadata.

If you can simplify the script as much as possible, while still having it cause a crash on your system, that will help greatly when we try to reproduce it on our systems.

Many thanks for your great support.
I simplified the script so you don't need Autohotkey.exe and will not see the standalone viewer but only the dialog box (if not crashing). You don't need to select any special files. The crash will happen every time you click on a button with the command FullScreenMetaEdit if you have at least one file with extension ".jpg .png .bmp .psd" in sourcepath. I tested most of the time with *.jpg. The relevant lines are 96-105. (84.9 KB)


There was a bug, which has been fixed now, but it was only triggered because of a mistake in the script itself.

You're calling DOpus.FSUtil.GetMetadata(item) without storing the result, which throws away the metadata you just loaded and presumably wanted to use. If you put the result in a variable then the crash should stop happening (and you can then get the metadata from the object in the variable.)

Many many Thanks leo!
After all these crashes I got everything working fine now. I mailed my script to tbone who probably finds something that can be done more efficient but apart from this I think it's ready to be published in the Scripting area the next days.

Thanks Leo and Jon, it works much better now, no crashes occurred.