# How to combine scripts with raw commands?

**URL:** <https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000>\
**Category:** Help & Support\
**Created:** [April 4, 2014, 2:30pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000 "2014-04-04T14:30:40Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [April 4, 2014, 2:30pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/1 "2014-04-04T14:30:40Z")

</div>

Is it possible to append a raw command like Select Next after a script? Maybe there is a way  
to merge script parts with raw commands into one single command?

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [April 4, 2014, 2:37pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/2 "2014-04-04T14:37:10Z")

</div>

Almost all of the example scripts run commands. Have a look at them. 🙂

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [April 4, 2014, 3:29pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/3 "2014-04-04T15:29:08Z")

</div>

Hmm, i can't find any example, where scripts are combined with a raw command. This is what i tried:

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  
Select Next

So, obviously, the raw command isn't working in script mode, even if it's placed after the function. I am trying to alter Kundal's button to select the next item.

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [April 4, 2014, 4:02pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/4 "2014-04-04T16:02:11Z")

</div>

Your code looks malformed to me, do you check the "other"-logs Log-Window for errors, when running this?

To my understanding, if you do something like: ClickData.Func.Command.RunCommand("SetAttr META comment:")  
You used a raw command already.. o)

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [April 4, 2014, 4:03pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/5 "2014-04-04T16:03:49Z")

</div>

> [@abr](#):
>
> Hmm, i can't find any example, where scripts are combined with a raw command.

[gpsoft.com.au/help/opus11/in ... nction.htm](http://www.gpsoft.com.au/help/opus11/index.html#!Documents/Scripting/Simple_Script_Function.htm)

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [April 4, 2014, 4:04pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/6 "2014-04-04T16:04:40Z")

</div>

[quote="tbone"]To my understanding, if you do something like: ClickData.Func.Command.RunCommand("SetAttr META comment:")  
You used a raw command already.. o)[/quote]

Yep!

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [April 4, 2014, 4:09pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/7 "2014-04-04T16:09:26Z")

</div>

[quote="tbone"]Your code looks malformed to me, do you check the "other"-logs Log-Window for errors, when running this?

To my understanding, if you do something like: ClickData.Func.Command.RunCommand("SetAttr META comment:")  
You used a raw command already.. o)[/quote]

The green part works ok. I've added the red bit to show, what i'm trying to achieve.

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [April 4, 2014, 4:11pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/8 "2014-04-04T16:11:34Z")

</div>

You need to run the command using ClickData.Func.Command.RunCommand, the same as all the other commands are being run in your script.

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [April 4, 2014, 4:14pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/9 "2014-04-04T16:14:02Z")

</div>

Also, you want to run the command before the end of the function, not after it.

[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

ClickData.Func.Command.RunCommand("Select NEXT")

End Function[/code]

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [April 4, 2014, 4:14pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/10 "2014-04-04T16:14:20Z")

</div>

[quote="leo"][quote="tbone"]To my understanding, if you do something like: ClickData.Func.Command.RunCommand("SetAttr META comment:")  
You used a raw command already.. o)[/quote]

Yep![/quote]

Ok, so raw commands are already in use in that code. But why doesn't "Select nect" work in that case?

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [April 4, 2014, 4:16pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/11 "2014-04-04T16:16:40Z")

</div>

> [@abr](#):
>
> Ok, so raw commands are already in use in that code. But why doesn't "Select nect" work in that case?

Because you're writing in VBScript and "Select Next" is an Opus command, not VBScript code. Using RunCommand is how you run Opus commands from VBScript.

---

<div class="post-metadata">

**Author:** ![kundal](https://resource.dopus.com/user_avatar/resource.dopus.com/kundal/32/24277_2.png) [@kundal](https://resource.dopus.com/u/kundal)\
**Post date:** [April 4, 2014, 4:20pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/12 "2014-04-04T16:20:00Z")

</div>

Because inside a script you'll have to use what the script language understands. 😃  
What you could do to combine scripts with raw commands is to make the script a user-defined command named My\_command and then call it from a button like this:

`My_command
Select NEXT`

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [April 4, 2014, 4:33pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/13 "2014-04-04T16:33:29Z")

</div>

> [@kundal](#):
>
> Because inside a script you'll have to use what the script language understands. 😃

I was aware of that.

[quote]What you could do to combine scripts with raw commands is to make the script a user-defined command named My\_command and then call it from a button like this:

`My_command
Select NEXT`[/quote]

Hmm, then i have to go on select the next file manually, because user defined commands don't support shortcuts. But i need to start the command using a shortcut, because that's the way my helper application works. I have to use some macro, to move that small window out of the way, under the lister. Otherwise it is placed right in the middle of the image i want to check for tags, which is obviously disturbing. I once requested a change, to make Opus remember the positions of dialog boxes, so they wouldn't get in the way. ☹

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [April 4, 2014, 4:39pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/14 "2014-04-04T16:39:06Z")

</div>

> [@leo](#):
>
> [quote="abr"]Ok, so raw commands are already in use in that code. But why doesn't "Select nect" work in that case?

Because you're writing in VBScript and "Select Next" is an Opus command, not VBScript code. Using RunCommand is how you run Opus commands from VBScript.[/quote]

I've tried that, too. I placed following under the code:

ClickData.Func.Command.RunCommand("Select next")

It didn't work. I wish, you would explain such programmer's things a bit more clearly.

---

<div class="post-metadata">

**Author:** ![kundal](https://resource.dopus.com/user_avatar/resource.dopus.com/kundal/32/24277_2.png) [@kundal](https://resource.dopus.com/u/kundal)\
**Post date:** [April 4, 2014, 4:41pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/15 "2014-04-04T16:41:07Z")

</div>

leo already provided the correct script and explained that the line has to be the last but one (before End Function).

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [April 4, 2014, 5:01pm UTC](https://resource.dopus.com/t/how-to-combine-scripts-with-raw-commands/18000/16 "2014-04-04T17:01:13Z")

</div>

@Leo, thanks! I didn't realize, that it was already done in your example script. I tried to put some command before the code, but i have absolutely no clues about script languages,  
so the code was ridiculously wrong, i guess. Also thanks to kundal, i will try to figure out, if i can intergrate your new version of the code (from the other posting) into my  
"move window by macro" workaround. I possibly have to nag the developers to make an option, to include some "dlg window position" option, so i could get rid of that macro solution. 😁
