You can change this a little and also use parameters if you need to.
If $CMDLINE[0] > 0 then
Switch $CMDLINE[0]
Case 1
Call($CMDLINE[1])
Case 2
Call($CMDLINE[1],$CMDLINE[2])
Case 3
Call($CMDLINE[1],$CMDLINE[2],$CMDLINE[3])
Case 4
Call($CMDLINE[1],$CMDLINE[2],$CMDLINE[3],$CMDLINE[4])
Case 5
Call($CMDLINE[1],$CMDLINE[2],$CMDLINE[3],$CMDLINE[4],$CMDLINE[5])
Case Else
;
EndSwitch
Exit
EndIf
_RunExternal("_MyExternallyRanFunction")
_RunExternal("_MyExternallyRanFunction",'"I have 1 param"')
_RunExternal("_MyExternallyRanFunction",'"I have 2 params" "See this is my Second param"')
_RunExternal("_MyExternallyRanFunction",'"I have 3 params" "This is my Second param" "And this is my Third param"')
_RunExternal("_MyExternallyRanFunction",'"I have 4 params" "This is my Second param" "This is my Third param" "Look it''s my Fourth param"')
MsgBox(0,"Msgbox1","I am running from the main script!" & @crlf & "My PID = " & @AutoItPID)
Func _RunExternal($COMMAND,$Param = "")
If @Compiled then
Run('"' & @ScriptFullPath & '" ' & $COMMAND & " " & $Param, @ScriptDir)
Else
Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" ' & $COMMAND & " " & $Param,@ScriptDir)
EndIf
EndFunc
Func _MyExternallyRanFunction($param1="",$param2="",$param3="",$param4="")
Msgbox(0,"Msgbox2","I am the message box running in an external process" & @crlf & "My PID = " & @AutoItPID & @CRLF & $param1 & @CRLF & $param2 & @CRLF & $param3 & @CRLF & $param4)
EndFunc