Dialog.Save() type not working

Im trying to use a Save Dialog with a predefined file type. Im using the template from the docs but the file type does not show up in the type dropdown.

image

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Save Dialog Type</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(clickData)</instruction>
		<instruction>{</instruction>
		<instruction>	var tab = clickData.func.sourcetab;</instruction>
		<instruction>	var cmd = clickData.func.command;</instruction>
		<instruction />
		<instruction>	var dlg = clickData.func.Dlg;</instruction>
		<instruction>	var resultPath = dlg.Save(&quot;Save&quot;,  &quot;Defaultname&quot;, null, &quot;#Text Files!*.txt!Doc Files!*.doc.&quot;);//,&quot;#Link file!*.lnk&quot;);</instruction>
		<instruction>	if(resultPath.result)</instruction>
		<instruction>		Log(resultPath);</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>function Log(msg, e)</instruction>
		<instruction>{</instruction>
		<instruction>	DOpus.Output(String(msg), e || false);</instruction>
		<instruction>}</instruction>
	</function>
</button>

You can't pass null for the window argument. Use tab there instead.

Also, the . at the end isn't supposed to be part of the example string; it just ends the sentence.

function OnClick(clickData)
{
	var tab = clickData.func.sourcetab;
	var dlg = clickData.func.Dlg;
	var resultPath = dlg.Save("Save", "Defaultname", tab, "#Text Files!*.txt!Doc Files!*.doc");
}

(I've made a note to clarify the manual when I get a spare moment.)

1 Like

Thanks for the solution. The dot at the end was just an attempt (in case it ended the statement and not the sentence from the docs :smile:. The tab argument made it work, I relied on " window - specify parent window for the dialog (a Lister or a Tab). If not specified, the Dialog object's window property will be used." (tbh yes then its specified but undefined :smiley: )

Crazy how the whole dialog changed its appearance :smiley:

1 Like

I had a deeper look at this today, while making some improvements to the documentation, and it turns out there's an easier way. You can omit the window argument entirely:

function OnClick(clickData)
{
	var dlg = clickData.func.Dlg;
	var resultPath = dlg.Save("Save", "Defaultname", "#Text Files!*.txt!Doc Files!*.doc");
}
1 Like

Thanks for coming back to this topic and for clarification.