Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is because <code>global.au3</code> doesn't get updated. It's providing initial values to your variables. Using <code>#include "global.au3"</code> is the same as writing:</p> <pre><code>;main.au3 #include-once Global $g1 = "" Global $g2 = "" $g1 = "stuff" $g2 = "stuff" Run("copy.exe") </code></pre> <p>and</p> <pre><code>;copy.au3 #include-once Global $g1 = "" Global $g2 = "" MsgBox(0, $g1, $g2) </code></pre> <p>As you can see, <code>copy.au3</code> (<code>copy.exe</code>) has <code>$g1</code> and <code>$g2</code> set to <code>""</code>.</p> <p>To pass your <code>$g1</code> and <code>$g2</code> variables to <code>copy.exe</code>, you can either use <code>IniRead()/IniWrite()</code> to read/write an .ini file or pass the variables as command line parameters.</p> <p>Here's an example of the command line parameters option: </p> <p>(no global.au3 needed; compile main.au3 and copy.au3; double click main.exe to run)</p> <p><strong>main.au3</strong></p> <pre><code>;main.au3 $g1 = "stuff" $g2 = "stuff" ShellExecute('copy.exe', $g1 &amp; ' ' &amp; $g2) </code></pre> <p><strong>copy.au3</strong></p> <pre><code>;copy.au3 $g1 = $CmdLine[1] $g2 = $CmdLine[2] MsgBox(0, $g1, $g2) </code></pre> <p>I used <code>ShellExecute()</code> instead of <code>Run()</code> because <code>Run()</code> has been a pain in the a$$ in the past (for me). I don't usually have any issues with <code>ShellExecute()</code> and <code>ShellExecuteWait()</code>.</p> <p>Also, for more info on command line parameters you can search on "Command Line Parameters" in the AutoIt help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload