<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[expansionInstallCallback inside a for loop]]></title><description><![CDATA[<p dir="auto">I have a custom expansionInstallCallback that shows an Alert Window after successfully installing an Expansion to inform users they need to restart the plugin. It works fine for single installations, but when I put it inside a loop to Batch Install multiple Expansions, it shows the alert window every time.</p>
<p dir="auto">Is there a neat way to only show the alert window on the last Expansion install? I'm currently trying to get some sort of counter that keeps track of the number of remaining expansions but haven't been successful with it.</p>
<pre><code>function expansionInstallCallback(obj)
{
        if(obj.Status == 2 &amp;&amp; isDefined(obj.Expansion))
            Engine.showMessageBox("Installation Complete", "Library installed successfully, please restart NEAT Player.", 0);
}

expHandler.setInstallCallback(expansionInstallCallback);
</code></pre>
<pre><code>//Bulk Install Method

var num_expansions_remaining = 0;

inline function onButton_BulkInstallControl(component, value)
{
    if (value)
           {
            Engine.showYesNoWindow("Bulk Install", "Please select the folder containing the .hr1 files.", function(response)
            {
                if (!response) return;       
                FileSystem.browseForDirectory(FileSystem.Downloads, function(f)
                {
                    if (f.isDirectory())
                    {
                        hrList = FileSystem.findFiles(f, "*.hr1", 0);
                        Engine.showYesNoWindow("Target Directory", "Please select the folder to install the samples to.", function(response)
                        {
                            if (!response) return;       
                            FileSystem.browseForDirectory(FileSystem.Downloads, function(dir)
                            {                            
                                if (dir.isDirectory())
                                {
                                    num_expansions_remaining = hrList.length;
                                    for (i=0; i&lt;hrList.length; i++)
                                    {
                                        num_expansions_remaining = hrList.length - (i + 1);
                                        expHandler.installExpansionFromPackage(hrList[i], dir);                                        
                                    }
                                }
                            });
                        });
                    }
                });
            });
           }
};
</code></pre>
<p dir="auto">Cheers :)</p>
]]></description><link>https://forum.hise.audio/topic/6996/expansioninstallcallback-inside-a-for-loop</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 15:59:26 GMT</lastBuildDate><atom:link href="https://forum.hise.audio/topic/6996.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Dec 2022 02:40:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to expansionInstallCallback inside a for loop on Tue, 27 Dec 2022 23:44:38 GMT]]></title><description><![CDATA[<p dir="auto">@d-healey said in <a href="/post/60006">expansionInstallCallback inside a for loop</a>:</p>
<blockquote>
<p dir="auto">Don't use <code>var</code> unless you have to. Use <code>reg</code> for your counter.</p>
</blockquote>
<p dir="auto">Yeh I'll probably have to start namespacing soon, was trying to avoid it but I'm all out of regs :)</p>
<p dir="auto">Got it working (so far):</p>
<pre><code>var num_expansions_to_install;
var expansionInstallIndex = 1;

function expansionInstallCallback(obj)
{
        if(obj.Status == 2 &amp;&amp; isDefined(obj.Expansion))
        {
            if (expansionInstallIndex &gt;= num_expansions_to_install)
            {
                expansionInstallIndex = 1;
                Engine.showMessageBox("Installation Complete", "Library installation successful, please restart NEAT Player.", 0);
            }
            else
                expansionInstallIndex++;
        }       
}


//Single

if (dir.isDirectory())
{
    num_expansions_to_install = 1;
    expansionInstallIndex = 1;
    expHandler.installExpansionFromPackage(nest.hr, dir);
}

//Batch

if (dir.isDirectory())
{
    num_expansions_to_install = hrList.length;
    expansionInstallIndex = 1;
    for (i=0; i&lt;hrList.length; i++)   
    {
        expHandler.installExpansionFromPackage(hrList[i], dir);                                          
    }  
        
}
</code></pre>
<p dir="auto">It's a bit clunky but it does the job, cheers!</p>
]]></description><link>https://forum.hise.audio/post/60022</link><guid isPermaLink="true">https://forum.hise.audio/post/60022</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 27 Dec 2022 23:44:38 GMT</pubDate></item><item><title><![CDATA[Reply to expansionInstallCallback inside a for loop on Tue, 27 Dec 2022 11:29:11 GMT]]></title><description><![CDATA[<p dir="auto">Don't use <code>var</code> unless you have to. Use <code>reg</code> for your counter.</p>
<p dir="auto"><code>num_expansions_remaining = hrList.length;</code> Try to stick to one naming convention, either use <code>_</code> or use camelCase (HISE uses camel case so I recommend using the same).</p>
<p dir="auto">You need to increase your counter in the expansion callback, once the install is complete. Then you check and see if the counter &gt;= the number of hrs, if it is then you show your message.</p>
]]></description><link>https://forum.hise.audio/post/60006</link><guid isPermaLink="true">https://forum.hise.audio/post/60006</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Tue, 27 Dec 2022 11:29:11 GMT</pubDate></item><item><title><![CDATA[Reply to expansionInstallCallback inside a for loop on Tue, 27 Dec 2022 03:43:09 GMT]]></title><description><![CDATA[<p dir="auto">@d-healey said in <a href="/post/59997">expansionInstallCallback inside a for loop</a>:</p>
<blockquote>
<p dir="auto">after a successful install set it to true.</p>
</blockquote>
<p dir="auto">Yeh that was my first attempt before this counter method, but the expansion install callback is on a different thread so putting the message outside of the callback makes it display instantly after clicking the button.</p>
<blockquote>
<p dir="auto">Also I think this video will be helpful to you</p>
</blockquote>
<p dir="auto">I actually like nesting code, I know it's uglier but I generally hate having single-use methods outside of the place they're being used, my brain just likes that more for some reason. :)</p>
]]></description><link>https://forum.hise.audio/post/59999</link><guid isPermaLink="true">https://forum.hise.audio/post/59999</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 27 Dec 2022 03:43:09 GMT</pubDate></item><item><title><![CDATA[Reply to expansionInstallCallback inside a for loop on Tue, 27 Dec 2022 02:56:46 GMT]]></title><description><![CDATA[<p dir="auto">Also I think this video will be helpful to you</p>
<p dir="auto"><a href="https://youtu.be/CFRhGnuXG-4" rel="nofollow ugc">https://youtu.be/CFRhGnuXG-4</a></p>
]]></description><link>https://forum.hise.audio/post/59998</link><guid isPermaLink="true">https://forum.hise.audio/post/59998</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Tue, 27 Dec 2022 02:56:46 GMT</pubDate></item><item><title><![CDATA[Reply to expansionInstallCallback inside a for loop on Tue, 27 Dec 2022 02:56:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/4560">@iamlamprey</a> Just have a flag called something like <code>installComplete</code>. Set it to false before your install loop, after a successful install set it to true. After all installs complete check the state of the flag, if it's true then you show the alert.</p>
]]></description><link>https://forum.hise.audio/post/59997</link><guid isPermaLink="true">https://forum.hise.audio/post/59997</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Tue, 27 Dec 2022 02:56:09 GMT</pubDate></item></channel></rss>