SetAttr META tags: pasted tags cut off

When pasting more than maybe 150-200 characters using the command SetAttr META "tags:{dlgstring}", the rest is cut off,
although it is possible to paste everything into the metapanel.

1 Like

This is probably unrelated to SetAttr META and tags, and just about {dlgstring}. (A quick way to test is to make a button with a long tag hardcoded where the {dlgstring} would be.)

I'm not sure what the {dlgstring} limit is (I'd expect it to be longer than 200, at least 250, but might be wrong).

Using scripting to do the same thing would allow you to specify the maximum length of string that the dialog will accept.

Here's an example for setting a comment with a limit of 512 characters:

Function OnClick(ByRef ClickData) Meta = ClickData.Func.Dlg.GetString("Type your long string:",,512,,"Edit Comment") ClickData.Func.Command.RunCommand("SetAttr META ""comment:" & Meta & """") End Function

I've edited the RunCommand line above slightly as I noticed an error in the quoting and brackets.

It may also make sense to check for the dialog being cancelled, and/or an empty string.

[quote]It may also make sense to check for the dialog being cancelled, and/or an empty string.[/quote]Ah yes, Without checking for an empty string clicking OK or Cancel will clear the comment field if the string is empty instead of doing nothing. This one prevents this:

Function OnClick(ByRef ClickData) Meta = ClickData.Func.Dlg.GetString("Type your long string:",,512,"OK,|Cancel","Edit Comment") If Not Meta = "" Then ClickData.Func.Command.RunCommand("SetAttr META ""comment:" & Meta & """") End If End Function

Thanks, Leo. It's not really an issue, since i rarely copy such many tags. I wanted to report it anyway.

@Kundal:

I get an error message, "function can't be found". I suppose, this is not a code to use in a normal button?

You have to choose the appropriate function: "script function" in the button editor to get it working.

Here's an example of a more advanced button for editing tags and/or comment. The dialog box let you choose whether to edit tags and/or comment. The checkbox for editing tags is enabled by default and a +-sign is set to the text field for adding tags to the existing ones. With an additional button you can also clear the chosen metadata fields.


[code]Function OnClick(ByRef ClickData)
Set dlg = ClickData.Func.Dlg
dlg.message = "Choose to edit tags and/or comment and insert your new content:"
dlg.title = "Edit Metadata"
dlg.buttons = "OK|Clear|Cancel"
dlg.options(0).label = "Edit Tags"
dlg.options(1).label = "Edit Comment"
dlg.max = 512
dlg.options(0).state = True
dlg.options(1).state = False
dlg.default = "+"
i = dlg.show

If dlg.options(0).state = True Then
	If i = 1 Then
		If Not (dlg.input  = "" Or dlg.input = "+") Then
			ClickData.Func.Command.RunCommand("SetAttr META ""tags:" & dlg.Input & """")
		End If
	End If
	If i = 2 Then
		ClickData.Func.Command.RunCommand("SetAttr META ""tags:")
	End If
End If
If dlg.options(1).state = True Then
	If i = 1 Then
		If Not (dlg.input  = "" Or dlg.input = "+") Then
			ClickData.Func.Command.RunCommand("SetAttr META ""comment:" & dlg.Input & """")
		End If
	End If
	If i = 2 Then
		ClickData.Func.Command.RunCommand("SetAttr META ""comment:")
	End If
End If

End Function
[/code]

Ah, yes, there it was. Didn't use this type until now. Thanks for the new script, i replaced my old function now. It's also a good idea, to use the "+" default.
By the way, would it be possible to make those boxes appear in a different position? Preferably i would place it right under the lister, so i can still look at the images
while typing in the tags.

Hi abr,
I saw your question about combining scripts with raw commands in this thread. I think what you want to do is editing one item after the other with the script command I provided. Here's a version that will do that in an endless loop until you click the additional Stop button. Hope you enjoy it:

Edit: Don't use this code. It's not working correctly. Get the working version here: Tagger.

[code]Function OnClick(ClickData)
Call Edit(ClickData)
End Function

Sub Edit(ClickData)
Set dlg = ClickData.Func.Dlg
dlg.message = "Choose to edit tags and/or comment and insert your new content:"
dlg.title = "Edit Metadata"
dlg.buttons = "OK|Clear|Stop|Cancel"
dlg.options(0).label = "Edit Tags"
dlg.options(1).label = "Edit Comment"
dlg.max = 512
dlg.options(0).state = True
dlg.options(1).state = False
dlg.default = "+"
i = dlg.show

If dlg.options(0).state = True Then
	If i = 1 Then
		If Not (dlg.input  = "" Or dlg.input = "+") Then
			ClickData.Func.Command.RunCommand("SetAttr META ""tags:" & dlg.Input & """")
		End If
	End If
	If i = 2 Then
		ClickData.Func.Command.RunCommand("SetAttr META ""tags:")
	End If
End If
If dlg.options(1).state = True Then
	If i = 1 Then
		If Not (dlg.input  = "" Or dlg.input = "+") Then
			ClickData.Func.Command.RunCommand("SetAttr META ""comment:" & dlg.Input & """")
		End If
	End If
	If i = 2 Then
		ClickData.Func.Command.RunCommand("SetAttr META ""comment:")
	End If
End If
If Not i = 3 Then
	ClickData.Func.Command.RunCommand("Select Next")
	Call EditNext(ClickData)
End If
 End Sub

Sub EditNext(ClickData)
Call Edit(ClickData)
End Sub
[/code]

Thanks, kundal. Unfortunately that's not working for me, because this window appears right in the middle of the lister, obscuring parts of the preview. I'm using Hot Keyboard Pro, to press the shortcut for me, which opens the dialog box, & to move that small window under the lister, so i can still see the various items in my photos (i use a special style for that). It does so very quickly (with a x100 factor), so the code change you've provided leaves no gap for the macro to work properly, i'm afraid. So i would strongly vote for a "dlg.position" option or something, so the dialog box could be placed under a lister.

DOpus scripting allows to insert a delay before the next box is popping up. This could give your macro time enough to move the dialog box. Just insert the line DOpus.Delay 500 at line 44 (between Sub EditNext(ClickData) and Call Edit(ClickData)) and experiment with the delay value (milliseconds).

Yeah, +1 for that.
In another scripting project I created a dialog box with several clickboxes and I wish I could avoid scrolling to see all of them by adjusting the size of the dialog box. It could be equivalent to adjusting the size of a lister: dlg.pos = "[width],[heigth],[pos_x],[pos_y]"

That doesn't work, because every time the window would pop up in the wrong (= uncorrected) position.

Thanks, kundal. I reverted to my old code for now, because the macro i'm using has some strange side effects with the new codes anyway (despites of a *100 factor, the macros are very slow). But it's still very promising, that new scripting function, because it might allow skilled users to add some minor changes to Opus' gigantic functionality, which IS already very tough for many users to keep an overview.

The last script code I provided didn't really work.
You can get a working version of the Tagger Script (including an Autohotkey hack to move the dialog box) here: Tagger

Awesome. I got it to work, with the window popping up at the exact position (800/860). However, the auto-step function has a drawback compared to my old workflow - if i missed some item/tag in the old version, i could simply use "arrow up" to go back to the previous image to add the missing tags. Now the input box has always the focus, making it hard to correct the errors, although it's great, when no mistakes are made. If i just could use the "Esc" key as an equivalent to the "stop" button, it would be perfect. :thumbsup:

Glad you like it. :smiley:
I removed the Stop button because it wasn't really necessary. The Cancel button finishes the loop now so it's working with the Esc key.

Excellent! That saves me 99 extra key strokes in a 100 images session. :bulb: :arrow_right:

I handle pictures taken with digital cameras very often, so I'm curious about what kind of tags do you add to your images and how do you make use of these (what kind of search e.g.)?