diff Posted July 11, 2021 Posted July 11, 2021 (edited) Hello, maybe this topic exist in forum, I just don't know how should I search it. The idea of my function is go get 2 inputs from GUI and run on same function. It's looks like this ; GUI has these created inputs $firstInput = GUICtrlCreateInput("", x, x, x, x) $secondInput = GUICtrlCreateInput("", x, x, x, x) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $buttonToExecute $firstValue = GUICtrlRead($firstInput) $secondValue = GUICtrlRead($secondInput) _executionFunc($firstValue) _executionFunc($secondValue) EndSwitch WEnd So the function collect data to Array for $firstValue and then converts _ArrayToString to another variable $collectedDataFromFirstValue = "here is all collected data from array" with all data in one variable (which is good for me), then next step is run function again with $secondValue and here is my issue, how I can save all my collected values in $collectedDataFromFirstValue without overwrite? Because If the function runs again with all $firstValue data saved before in array then it gets overwritten by $secondValue and moved again to $collectedDataFromFirstValue. Hope I explained well to understand what I meant. Edited July 11, 2021 by diff
Solution Subz Posted July 11, 2021 Solution Posted July 11, 2021 Use two parameters for example: _executionFunc($firstValue, $secondValue) and then process both values at the same time within the function. You could also use a flag Basic example (note, don't really understand the need for _ArrayToString, or if you're adding, concatenating data to $collectedDataFromFirstValue) Global $collectedDataFromFirstValue = "" _excutionFunc($firstValue, 1) _excutionFunc($secondValue) Func _excutionFunc($_Value, $_iFlag = 0) Switch $_iFlag Case 1 $collectedDataFromFirstValue &= $_Value Case Else ;~ Do something for other values EndSwitch EndFunc diff 1
diff Posted July 11, 2021 Author Posted July 11, 2021 On 7/11/2021 at 9:50 PM, Subz said: Use two parameters for example: _executionFunc($firstValue, $secondValue) and then process both values at the same time within the function. You could also use a flag Basic example (note, don't really understand the need for _ArrayToString, or if you're adding, concatenating data to $collectedDataFromFirstValue) Global $collectedDataFromFirstValue = "" _excutionFunc($firstValue, 1) _excutionFunc($secondValue) Func _excutionFunc($_Value, $_iFlag = 0) Switch $_iFlag Case 1 $collectedDataFromFirstValue &= $_Value Case Else ;~ Do something for other values EndSwitch EndFunc Expand In my case I cannot process both values at the same time within function, so the $_iFlag option works perfectly for me and separates values data with two different variables. Amazing, totally forgot about flags with Switch, thank you _ArrayToString I use because the collected words from $firstValue and $secondValue I need only in one line delimited by comma, so I thought that this could be the best solution for me
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