Use the icon of Script Add-ins in a script dialog in other scripts?

I tried it and it didn't work.

	//dlg.Control("static3").label = Script.LoadImage("Everything24.ico");    // Icon
	dlg.Control("static3").label = ScriptInitData.AddCommand.icon("Everything24.ico")    // Icon

I couldn't find it in the help documentation and forum.

function OnClick(clickData)

    //-- Add string trim() method
    String.prototype.trim = function(s){s=s||"\\s";return this.replace(new RegExp("^("+s+"){1,}\|("+s+"){1,}$","g"),"");}
    var cmd = clickData.func.command;
	var tab = clickData.func.sourcetab;
    // Read the history of the EverythingForDopus_History.ini file
    var filepath = "%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\EverythingForDopus_History.ini";   //File path

    fsu = DOpus.FSUtil;
	var ST = DOpus.Create.StringTools();
    if(fsu.Exists(filepath)) {
       var bom = fsu.OpenFile(filepath).Read();
       textbom = ST.Decode(bom, "utf-8 bom");
    } else {
       var textbom = "";
    var dlg = DOpus.Dlg;
    dlg.title = "Directory Opus";                                           // Tittle
    dlg.template = "dlgCombox";
	dlg.detach = true;
	dlg.Control("static").style = "b";
	dlg.Control("static").label = "[Everything]";                           // Topic
	dlg.Control("static2").label = "Enter Everything Search Query\nYou can do a /regex search \d\d\d/ using slashes";                  // Notes
	//dlg.Control("static3").label = Script.LoadImage("Everything24.ico");    // Icon
	dlg.Control("static3").label = ScriptInitData.AddCommand.icon("Everything24.ico")    // Icon
    var myArray = textbom.split("\r\n");            //Seprator
	   promptstr = clickData.func.sourcetab.selected(0).name_stem_m;
	   dlg.Control("combo").label = promptstr;      //Default value
	  } else {
	  dlg.Control("combo").label = myArray[0];
	dlg.Control("combo").SelectRange(0, -1);        //Select Default value
    for(i = 0; myArray[i]; i++) {
		dlg.Control("combo").AddItem(myArray[i]);   //Add each item to drop-down list

//msg loop
		msg = dlg.GetMsg();
		if(msg == true && dlg.Control("combo").focus == true) {
		if(dlg.result == 1) {
		   var fixstr = dlg.Control("combo").label;
		   searchString = fixstr.trim().replace(/\|/g,' |');
		} else {
		if(dlg.result == 0) {
		//If the button 3 is pressed
		if(dlg.result == 2) {
		   var fixstr = dlg.Control("combo").label;
		   fixstr = fixstr.trim().replace(/\|/g,' |');
		   searchString2 = searchString;
		   searchString = fixstr+" path:"+maybe_quote(path);
		//If the button 4 is pressed
		if(dlg.result == 3) {
		   var fixstr = dlg.Control("combo").label;
		   fixstr = fixstr.trim().replace(/\|/g,' |');
		   searchString2 = searchString;
		   searchString = fixstr+" parent:"+maybe_quote(path);
	} while (msg == true);
	cmd.AddLine('EverythingDopus "' + searchString+ '"')
    if(searchString) {
	   var newHistory = "";
       for(i = 0; myArray[i]; i++) {
	       if(i == 15) {break};
           if(searchString != myArray[i]) {newHistory += "\r\n" + myArray[i]};
       newHistory = searchString + newHistory;
       var oFileWrite = fsu.OpenFile (filepath, "wa");
       var utf8blob = ST.Encode(newHistory, "utf-8 bom");
       if(oFileWrite.error == 0)
          oFileWrite.Write (utf8blob)
       oFileWrite.Close ()


	<resource name="dlgCombox" type="dialog">
		<dialog fontsize="8" height="88" lang="english" resize="yes" title="Directory Opus" width="322">
			<control edit="yes" height="40" name="combo" type="combo" width="306" x="8" y="50" />
			<control close="3" height="14" name="btn4" resize="xy" title="&amp;Here" type="button" visible="no" width="60" x="81" y="67" />
			<control close="2" height="14" name="btn3" resize="xy" title="&amp;Below" type="button" visible="no" width="60" x="145" y="67" />
			<control halign="left" height="8" name="static" title="Topic" type="static" valign="top" width="280" x="30" y="10" />
			<control halign="left" height="16" name="static2" title="Notes" type="static" valign="top" width="280" x="30" y="22" />
			<control halign="center" height="14" image="yes" name="static3" title="Icon" type="static" valign="top" width="14" x="8" y="7" />
			<control close="1" default="yes" height="14" name="btnOK" resize="xy" title="&amp;OK" type="button" width="50" x="209" y="67" />
			<control close="0" height="14" name="btnCancel" resize="xy" title="&amp;Cancel" type="button" width="50" x="263" y="67" />

Not sure but LoadImage migth expect image files (icons might not be considered as images?).
When delivering icons with your script youre probably looking for!Documents/Scripting/Script_Package.htm

There's an example here:

While that loads a PNG, you can change it to load a ICO and it still works. The script package includes both PNG and ICO images, so you can test it by changing this line:

Dlg.control("cat").label = Script.LoadImage("cat.png")

To this:

Dlg.control("cat").label = Script.LoadImage("cat32.ico")

I've packaged osp file with icons, my question is how to use those icons in script dialog in other scripts.
Sorry I didn't explain it clearly. :expressionless:

I'm not sure if a script in one package can load an icon from another. Just copy the icon into both packages? They don't take up much space.

Not Script Add-ins. . .

function OnClick(clickData)
    some code

Put the code, icon and dialog into the script add-in, as a script command. Then run that command from your button.

Well, this is something I kind of don't want to do, it would be nice if the loaded script icons could be used everywhere.

I initially thought the same way, but having a command comes with a lot of benefits. Editing this code is much more fluent when using an external editor, this way you dont always have to edit the corresponding button. You can hide this command from the command list if you mind having it available there.
But why not simply creating a icons folder in your /dopusdata directory? I think this way you can even include them into your backup files and reference them with /dopusdata/YOURICONDIR. This way you have them once and can use them from every script/button/whatever.

Adding them under /dopusdata/User Data is best, as that directory will be included in config backups and USB exports, and is also guaranteed not to cause problems if you put your own random files in it (that's what it's for).