In a very simple custom button, I want to run one command (or several commands) if any files were selected when the button was pressed. And if no files were selected, I want to run a different command or set of commands.
I'm looking for a simple way to do this and it'd be nice if the logic all showed inside the button's "Command Editor" box. But if I must get into a custom command (is that a script in Dopus?), that's okay.
Create a new button type "script function" with this code:
Function OnClick(ClickData)
Set cmd = ClickData.Func.Command
If ClickData.Func.sourcetab.selected.count = 0 Then
cmd.AddLine("[first line of a multi line command]")
cmd.AddLine("[second line]")
cmd.AddLine("[third line]")
cmd.Run
Else
cmd.RunCommand("[single line command]")
End If
End FunctionReplace the parts with square brackets with your commands. The commands above "Else" will be executed if nothing is selected. The single line command example after "Else" will be executed if something is selected.
It's a bit tricky if your command string contains double quotes because they have to be doubled or separetely added with & """" to the string like this:cmd.AddLine("""" & "C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe " & """" & "/command:commit /pathfile:" & """" & "{allfilepath|filem|ucsle|nobom}" & """" & " /closeonend:3")