RAMzor Posted June 24, 2022 Share Posted June 24, 2022 (edited) Hello All! I want to ask you to help me with the idea. I apologize in advance for the long explanation of my issue. I'm creating a GUI - Test Sequencer where tests will be dynamically loaded into ListView (several columns as test name, result, units and PASS/ FAIL). Tests are functions in a separate file (each test is a separate function) that always return the same 'standard' array (eg: test result, lower bound, upper bound, units) to the sequencer's ListView. The test sequencer is compiled exe. My question is how to organize a dynamic call of functions from a compiled script (Test Sequencer) and transfer back the test result array from the function to the main sequencer program. I found some information on the forum but could not use it for my own purposes. Please help with ideas and short examples. I don't have any clue how to start. Here some scripts that simulate what I need You should compile Main GUI.au3 to exe - This GUI should not be changed (recompiled) while the test files may change and be updated with new features. The rest files Test_Set_1.au3 and Test_Set_1.au3 should simulate tests that may have different sets of functions and always can be changed/updated with new features. Dynamically loaded to Main GUI.exe * The files Test_Set_1.au3 and Test_Set_1.au3 are currently not included in any way in Main GUI.au3 - Basically this is my issue . Thanks in advance Main GUI.au3 Test_Set_1.au3 Test_Set_2.au3 Edited June 25, 2022 by RAMzor Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 24, 2022 Moderators Share Posted June 24, 2022 It sounds to me like you want to collect your functions into a UDF, and then #include that with your calling script. See the Wiki on this subject: UDF-spec - AutoIt Wiki (autoitscript.com) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
RAMzor Posted June 24, 2022 Author Share Posted June 24, 2022 1 hour ago, JLogan3o13 said: It sounds to me like you want to collect your functions into a UDF, and then #include that with your calling script. See the Wiki on this subject: UDF-spec - AutoIt Wiki (autoitscript.com) Thanx for replay but maybe I didn't explain well. There is no option to load UDF dynamically into already compiled script Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 24, 2022 Moderators Share Posted June 24, 2022 I missed that this is a compiled script, which it sounds like you have no access to the source code for. Is the compiled script already set up to accept cmdline params then? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Zedna Posted June 24, 2022 Share Posted June 24, 2022 I think that this could be solution: #include "your_external_functions.a3x" Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
RAMzor Posted June 25, 2022 Author Share Posted June 25, 2022 12 hours ago, Zedna said: I think that this could be solution: #include "your_external_functions.a3x" Although it's new to me that a3x can be included 😏 but in any case something not working in this way for me 😬 I updated my main post and post some scripts that simulate what I need. Link to comment Share on other sites More sharing options...
RAMzor Posted June 25, 2022 Author Share Posted June 25, 2022 15 hours ago, JLogan3o13 said: I missed that this is a compiled script, which it sounds like you have no access to the source code for. Is the compiled script already set up to accept cmdline params then? Ho problem to make changes. The all scripts are written by me but... Main exe GUI (The test sequencer) is for general use in different project's. It is quite complicated with lot of logic and I don't wont recompile it each time I need to update my test functions. Please kindly see my updated main post with some scripts that should simulate what I need. Link to comment Share on other sites More sharing options...
Solution Gianni Posted June 26, 2022 Solution Share Posted June 26, 2022 (edited) On 6/24/2022 at 8:27 PM, RAMzor said: ... Please help with ideas and short examples. I don't have any clue how to start. ... just a hint on one possible way. You can use the functions present in an external file by running that script using /AutoIt3ExecuteScript and getting the return results by reading the StdOut stream. How?... you have to make calls to those functions like this: instead of using a normal call in the form of _func_1([$ params ...]) as for functions contained in the same script you have to use this other format instead: Run (@AutoItExe & "/AutoIt3ExecuteScript " & 'Filename.au3 Param1 Param2 ...', '', '', 8) From the external script, to be able to send results to the main script just use ConsoleWrite ($ Var) instead of Return $ Var As usual, a simple example script is worth more than too many words save the following two scripts in the same directory and run the MainScript.au3 p.s The main script can be compiled as well as the external script. Obviously if you compile the external script in an .exe or .a3x you must also change the command to call the external script accordingly. Check it out here: https://www.autoitscript.com/autoit3/docs/intro/running.htm I hope this helps MainScript.au3: #include <array.au3> ; Local $STDERR_MERGED = 8 Local $vReturn Local $sFilename = '.\ExternalFunc.au3' ; call func_1 $vReturn = CallExternal($sFilename, 1) MsgBox(0, 'Return', "Received: " & $vReturn) ; call func_2 $vReturn = CallExternal($sFilename, 2) _ArrayDisplay(StringSplit($vReturn, "|", $STR_NOCOUNT)) Func CallExternal($sFilename, $iParams) Local $vStdOut Local $hPID = Run(@AutoItExe & " /AutoIt3ExecuteScript " & $sFilename & ' ' & $iParams, '', '', $STDERR_MERGED) While ProcessExists($hPID) Sleep(250) $vStdOut &= StdoutRead($hPID) WEnd Return $vStdOut EndFunc ;==>CallExternal ExternalFunc.au3: ; #include <array.au3> Local $iParams = $CmdLine[0] If Not $iParams Then ConsoleWriteError("missing parameters error.") Exit EndIf Local $iParam1 = $CmdLine[1] Local $aWeekDays[] = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] Switch $iParam1 Case 1 _func_1() Case 2 _func_2() Case Else ConsoleWriteError("function number undefined error.") EndSwitch ; returns a random number Func _func_1() ; use ConsoleWrite instead of Return ConsoleWrite(Random(0, 100, 1)) EndFunc ;==>_func_1 ; returns a (pseudo) array Func _func_2() Local $sString ; ConsoleWrite(_ArrayToString($aWeekDays)) For $i = 0 To UBound($aWeekDays) - 1 $sString &= $aWeekDays[$i] & "|" Next ; use ConsoleWrite instead of Return ConsoleWrite(StringTrimRight($sString, 1)) EndFunc ;==>_func_2 Edited June 26, 2022 by Gianni robertocm, ioa747, AutoBert and 1 other 2 2 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
RAMzor Posted June 28, 2022 Author Share Posted June 28, 2022 (edited) On 6/26/2022 at 7:22 PM, Gianni said: just a hint on one possible way. You can use the functions present in an external file by running that script using /AutoIt3ExecuteScript and getting the return results by reading the StdOut stream. ... Thanx for the idea! You gave me the right way! Apparently I will use Call($sDataReceived) to call function by name received from StdoutRead($hPID) Thanx! Edited June 28, 2022 by RAMzor Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now