12 posts in this topic
I have a requirement to return both a string and an array from a function so as a result I put them both into an array and returned that. I can access them in their entirety after returning them but then I can't seem to access the array elements after this. Should I be able to or is there a prettier way?
#include <Array.au3> ;Memory info returned as a string and an array $memoryInfo = _getMemoryInfo() msgbox(0,"Memory Info",$memoryInfo) _ArrayDisplay($memoryInfo,"Memory as an Array") Local $newArray $memoryInfo = $newArray msgbox(0,"Test element",$newArray) _ArrayDisplay($newArray) Func _getMemoryInfo() Local $newArray Local $array = MemGetStats() $newArray = $array ;% of memory in use $newArray = Round($array/1024 * 0.001,2) ;Total physical RAM $newArray = Round($array/1024 * 0.001,2) ;Availaible physical RAM $newArray = Round($array/1024 * 0.001,2) ;Total pagefile $newArray = Round($array/1024 * 0.001,2) ;Available pagefile $newArray = Round($array/1024 * 0.001,2) ;Total virtual $newArray = Round($array/1024 * 0.001,2) ;Available virtual $memoryUsage = $newArray - $newarray $pagefileUsage = $newArray - $newarray ;Output/Return Local $returnArray $returnArray = "Memory: " & $memoryUsage & " GB/" & $newArray & " GB " & @CRLF & "Pagefile: " & $pagefileUsage & " GB/" & $newArray & " GB " $returnArray = $newArray return $returnArray EndFunc A bit messy but hopefully it's understandable what I'm trying to achieve.
2 writes and how returning?
$var1 = "1.variable" $var2 = "2.variable" $var3 = "3.variable" For $i = 1 To 3 Step 1 MsgBox(0,"test Message header",$var1) Next For $i = 1 To 3 Step 1 MsgBox(0,"test Message header",$var2) Next If ($var2 = 2) Then Return $var1 For $i = 1 To 3 Step 1 MsgBox(0,"test Message header",$var3) Next
#Region ### START Koda GUI section ### Form=c:\users\paulo\documents\gui.kxf Global $Form1_1 = GUICreate("Test", 499, 196, -1127, 323) Global $Amount = GUICtrlCreateLabel("Amount", 176, 80, 40, 17) Global $AmountInput = GUICtrlCreateInput("", 224, 80, 57, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $x = This one is just a test, but I want the value of $x to be whatever numbers the user types in.
If I embedd a compiled autoit script into my new script, is there a possibility to pass some data from the compiled embedded exe to my script?
I know it's possible with an ini or txt-file. But is there something without creating a file? I plan to return an array or an unformatted string of datas with delimiters inside.
Maybe I'm just too tired, but I came across this and didn't quite know how to solve it at once:
Func myFunc() If $something Then StopTimer() Return 0 ElseIf $somethingElse Then StopTimer() Return 1 Else StopTimer() Return 2 EndIf EndFunc My idea was to make a return function to get rid of all the StopTimer() lines:
Func MyFunc_Return($val) StopTimer() Return $val EndFunc And then use it like so:
If $something Then MyFunc_Return(0) ElseIf $somethingElse Then... But then the problem persists of course - how do we get MyFunc to actually return and exit the function?
In my real script there is lots of returns...
Edit: bleh typo... how do I change topic title?