Function OnClick(ByRef ClickData)
Dim oFile, oFiles, oTags, Tag
Set oFiles = ClickData.Func.SourceTab.Selected_Files
For Each oFile In oFiles
If UCase(oFile.Ext) = ".MP3" Then
DOpus.Output "Count = " & oFile.Metadata.Tags.Count
Set oTags = oFile.Metadata.Tags
For Each Tag In oTags
DOpus.output "Tag = " & Tag
Next 'Tag
End If
Next 'oFile
End Function
[/code]
If I edit an MP3 file and add a tag to it, then run the code above, it works just fine. If I run the code again (without doing anything else), the Count is empty and no tags are displayed. After that point, it no longer works for that file until I modify the tags in the file. If I modify the tags again, then it will work for one run but no longer works on any subsequent runs.
Am I doing something wrong or is this a bug? I'm using Directory Opus 11.4.4 (beta) (64-bit) on Windows 8.
(Aside: You have @nodeselect at the top of the button, but that does not work with script buttons. @script vbscript (or similar) is the only modifier that should appear at the top of a script. Use ClickData.Func.Command.Deselect = False to do the equivalent of @nodeselect from a script.)
Oh, cool! Thanks for the tip on the deselect command. I'll start using that from now on.
Here's my process to recreate the issue:
I highlight an MP3 file and then open the Metadata Pane.
Under Extended Properties, I click in the Tags field, type in a tag name (e.g., "red"), and click Apply.
I click on the button to run the script above, and it displays "Count = 1" and "Tag = red".
I click on the button to run the script a second time, and it displays "Count = " and nothing else. No matter how many times I run the script after this point, it never displays the tag again.
I change the tag to something else (e.g., "blue"), using the process in step 2.
I click on the button to run the script again, and it displays "Count = 1" and "Tag = blue".
I click on the button to run the script again, and it displays "Count = " and nothing else. The tag never displays again after this point.
Sometimes when I click the button to run the script in step 4, it will actually display the correct "Count = #" but it doesn't display the tag. Any additional button clicks just result in "Count = " and nothing else. The only time I can ever get the tag to display is right after I add or change it.
Is there any other info I can give you to help narrow down this issue? I'm happy to help anyway that I can. Thanks!