Can dialogs be dynamic?

Can I have a box that lets the user enter a string and then based on that string a drop downlist is dynamically added/shown with choices based on the string typed?

I assume I have to do one pop-up to get the string and then take that input to create a new pop based on that string to show the choices. This program can do so much, so I thought I should ask before assuming. I did a search for "directory opus dynamic dialog" but nothing came up.

Yes, you can: https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Script_Dialogs1.htm

Wow, I know what I'm going to be doing all day tommorrow. :heart_eyes:

I think this was probably the page you ment to link to since it seems to give an example of in interactive dialog. https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Interacting_with_Dialog_Controls.htm

I linked to the start of the section as it’s best to start from there and seemed like you had not found it yet. If you start at the later part you won’t understand it without going back first.

Thanks, I will start from the begining then. I didn't realize they were all part of the same thing.

That’s generally how manuals work. :slight_smile:

I have followed along and created a dialog, but now I am trying to figure out how to put the html into the script-addin.
according to https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Resources.htm

I can just add the code to the botton of the script

Everything before the line ==SCRIPT RESOURCES is considered part of the script code, and everything after it is the XML-formatted resources.

This causes an error and doesn't work.
error

I have am currently trying this option:
Script resources can be loaded from an external file, or a raw XML string, using the Script.LoadResources** method.

	Script.LoadResources  ('
		<resources>
		<resource name="SelectDestination" type="dialog">
			<dialog fontsize="8" height="120" lang="english" resize="yes" width="550">
				<control halign="left" height="8" name="static1" title="Source Folder:" type="static" valign="top" width="50" x="18" y="18" />
				<control height="30" name="group1" title="Source" type="group" width="540" x="5" y="6" />
				<control halign="left" height="8" name="SourceFolder" title="sourcefolder" type="static" valign="top" width="440" x="72" y="18" />
				<control height="24" name="group2" title="Search Field" type="group" width="540" x="5" y="36" />
				<control halign="left" height="12" name="search" title="search" type="edit" width="276" x="137" y="42" />
				<control height="40" name="combo" type="combo" width="540" x="5" y="66" />
				<control close="1" height="14" name="button1" title="Move Selected" type="button" width="61" x="161" y="90" />
				<control close="2" height="14" name="button2" title="Move Source Folder" type="button" width="73" x="232" y="90" />
				<control close="0" default="yes" height="14" name="button3" title="cancel" type="button" width="50" x="317" y="90" />
			</dialog>
		</resource>
</resources>

');

Something is incorrect about this, but I have no idea what I did wrong.

So the last thing to try I guess is

can be loaded from an external file

Seems like this would take more over head, and I will have a separate file that could get "lost". I would really prefer to keep the code in the script if possible.

Looks like you have a space between the == and the SCRIPT RESOURCES.

Thanks VS code auto formated a space there. I removed the space but it still gives the syntax error when I run it in Directory opus

If you upload the script I'll have a look.

Currently, It's part of one big script addin that I have combined lots of stuff in. Let me try to put it in just a bare minium script and if it still doesn't work I will post it. thanks.



function OnInit(initData) {
    initData.name = "TestHelperAddIn";
    initData.version = "1.0";
    initData.copyright = "(c) 2023 chris";
    initData.desc = "TestHelperAddIn";
    initData.default_enable = true;
    initData.min_version = "12.0";

    // Create a new ScriptCommand object and initialize it to add the command to Opus
    var cmd = initData.AddCommand();
    cmd.name = initData.name;
    cmd.method = "start";
    cmd.desc = initData.desc;
    cmd.label = "TestHelperAddIn";
    //For arguments Ex: DazMove funcname to "folder"
    cmd.template = "items/k,";
}

function start(scriptCmdData) {
    DOpus.ClearOutput();
    var cmd = scriptCmdData.func.command;
    var dlg = cmd.Dlg;
    dlg.template = "SelectDestination";
    dlg.Show;

    if (scriptCmdData.func.args.got_arg.items) {//Check if parameter TO was passed an argument
        var arg = scriptCmdData.func.args.items;
        DOpus.Output(arg);
    } else {
        DOpus.Output("No args passed to TestHelperAddIn");
    }
}

 ==SCRIPT RESOURCES
    <resources>
    <resource name="SelectDestination" type="dialog">
        <dialog fontsize="8" height="120" lang="english" resize="yes" width="550">
            <control halign="left" height="8" name="static1" title="Source Folder:" type="static" valign="top" width="50" x="18" y="18" />
            <control height="30" name="group1" title="Source" type="group" width="540" x="5" y="6" />
            <control halign="left" height="8" name="SourceFolder" title="sourcefolder" type="static" valign="top" width="440" x="72" y="18" />
            <control height="24" name="group2" title="Search Field" type="group" width="540" x="5" y="36" />
            <control halign="left" height="12" name="search" title="search" type="edit" width="276" x="137" y="42" />
            <control height="40" name="combo" type="combo" width="540" x="5" y="66" />
            <control close="1" height="14" name="button1" title="Move Selected" type="button" width="61" x="161" y="90" />
            <control close="2" height="14" name="button2" title="Move Source Folder" type="button" width="73" x="232" y="90" />
            <control close="0" default="yes" height="14" name="button3" title="cancel" type="button" width="50" x="317" y="90" />
        </dialog>
    </resource>
</resources>

There's a space in front of the == as well.

:hot_face: I should have seen that.

Thanks, it works as expected now.

1 Like