Help with scripting

I'm not good in scripting/programming, so does anybody have a template, which popups a window with 2 buttons and each button executes a separate DO usercommand using a DO-alias (e.g. /dopusdata)?

Such a basic script would be a good startup for me to enhance my skills :slight_smile:.

If nobody else gets to it, I'll post something later tonight...

That would be great, thank you very much.

Sasa

Here is an example button. Script code is below.


<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Open New Script</label>
	<icon1>#script</icon1>
	<function type="script">
		<instruction>@script vbcript</instruction>
		<instruction />
		<instruction>Function OnClick(ByRef ClickData)</instruction>
		<instruction />
		<instruction>	Dim i</instruction>
		<instruction />
		<instruction>	With ClickData.Func.Dlg</instruction>
		<instruction>		.message = &quot;Please select what to open.&quot;</instruction>
		<instruction>		.title = &quot;Open in a new lister&quot;</instruction>
		<instruction>		.buttons = &quot;/desktop|/dopusdata&quot;</instruction>
		<instruction>		i = .show</instruction>
		<instruction>		.message = &quot;Button &quot; &amp; i &amp; &quot; was clicked.&quot;</instruction>
		<instruction>		DOpus.Outputstring .message</instruction>
		<instruction>		&apos;.buttons = &quot;OK|Quit&quot;</instruction>
		<instruction>		&apos;i = .show</instruction>
		<instruction>		if i = 0 then</instruction>
		<instruction>			DOpus.CreateCommand.RunCommand &quot;Go /DopusData NEW=nodual,tree&quot;</instruction>
		<instruction>		elseif i = 1 then</instruction>
		<instruction>			DOpus.CreateCommand.RunCommand &quot;Go /desktop NEW=nodual,tree&quot;</instruction>
		<instruction>		else</instruction>
		<instruction>		end if</instruction>
		<instruction>	End With	</instruction>
		<instruction />
		<instruction>End Function</instruction>
	</function>
</button>

Regards, AB

Great, many thanks. That's a good example to start scripting and optimizing some of my usercommands. :thumbsup:

No problem. For some related discussion, see the thread at DO11 Scripting - Support For Forms/Controls?

Regards, AB

Ah, AB beat me to it :slight_smile:...

There are also several examples included at the scripting reference page that GPSoft pointed to in the initial beta announcement:

viewtopic.php?f=26&t=20480

Thanks.

Leo's comments about the limitations of VBScript in another thread inspired me to see if I could do this in JavaScript. After a bit of hacking, the following button code now works.

function OnClick(ClickData)
{
var one = "/DopusData"; var two = "/Desktop";
var n = DOpus.Dlg.Request("Pick a target to open in a new lister",one + "|" + two);
if (n == 1) {tgt = one}; else {tgt = two};
DOpus.CreateCommand.RunCommand("Go " + tgt + " NEW=nodual,tree");
}


Regards, AB

Thanks for your support, today I'll "play" with it :slight_smile:.