VB sourcetab

For Each f In clickData.func.sourcetab.selected For Each tag In f.metadata.tags If (tagString <> "") Then tagString = tagString & "; " tagString = tagString & tag Else tagString = tag End If Next Next

I use this to get the tags out of an image file. Now I want to get the tags out of the image displayed in a viewer window. Naturally this only works with a Lister. How do I amend the code to do what I need?

You mean the standalone viewer?
Check the DO 12 release notes, there's an example on how to get through to the current image.

For buttons launched from the viewer, use clickData.func.viewer.current to get the current file (Item object).

(Looks like this is missing from the current beta manual.)

For each f in clickData.func.viewer.current
For Each tag In f.metadata.tags
            If (tagString <> "") Then
               tagString = tagString & "; "
               tagString = tagString & tag
            Else
               tagString = tag
            End If	
     Next
     Next

I had kinda figured that out, but gave up on it when it did not appear to work. Using this, the tagString variable is always empty.

I am using the standalone vieser, Tbone

Is "clickData.func.viewer.current" somethnig that needs or even works with a "for each" block?
To me this is not some kind of collection, so that may be why tagString is always empty (inner for-loop did not run)?
Try to insert some DOpus.Output("I'm here!") statements to see which lines get executed or skipped.

Your are quite right Tbone the inner loop does not run..WHich begs the question how do I extract the tags from the current file in the viewer

clickData.func.sourcetab.selected

works, but the image has to be selected in the Lister as well as the viewer which is not ideal.

Any ideas, my friend?

Maybe this get's you going.. not tested. o)

dim f : f = clickData.func.viewer.current For Each tag In f.metadata.tags If (tagString <> "") Then tagString = tagString & "; " tagString = tagString & tag Else tagString = tag End If Next Next

Sorry, Tbone this fails with the following error

Error at line 19, position 1
Object required: 'f' (0x800a01a8)

Ah, that quirky vbs again. Edit the corresponding line to look like this (added "set" statement):

dim f : set f = clickData.func.viewer.current

Please consider to post the full code if new problems arise.

Yes sir, you nailed it. I have the tags.

Could I just trouble you with another question. What I have done is to create a button which opens a form that shows all the interesting metadata in a picture and allows me to change it without using the Opus metadata panel. The biggest advantage is that it is much more readable than the metadata panel and I can have a multiline caption input box.

The problem I have when I use it with the viewer is that I have to close the viewer, reopen it and select the next picture to get the button to work. It has me baffled.


Great. o) Now what's your exact question, cannot make out any question marks in your text. o)

My question is:

Although the script works fine the first time. If I advance the viewer to the next image and run the script again it does not pick up any metadata from the the new image. (Although the script does pick up the file name).

It is as though the script somehow does not realise that the image has changed. If I close the viewer and re-open the new picture, the script works fine. Any idea what I am doing wrong?

I suddenly realised what the problem was!!

I needed to set my preferences to re-use the viewer window. It works like a charm now.

I am very grateful for the time and trouble you have taken to help me.