antai Posted January 24 Share Posted January 24 (edited) Hi, I use this kind of a function to update my arrays (stripped off anything not necessary): Func UpdateArray (ByRef $upArray, $addvariable) $upArray[0][0] += 1 $upArray[0][$upArray[0][0]] = $addvariable EndFunc I call this function like 1000 times to update $arrayA and $arrayB. It updates $arrayA ok then it switches to $arrayB, but then it does not switch back to $arrayA. Things get interesting. I have split the call into this and the result is the same: If $condition Then $arrayA[0][0] += 1 $arrayA[0][$arrayA[0][0]] = $addvariable MsgBox (0, "A", $addvariable) Else $arrayB[0][0] += 1 $arrayB[0][$arrayB[0][0]] = $addvariable MsgBox (0, "B", $addvariable EndIf Msg displays correct letter BUT then the variable is in the wrong array!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! How? Can I send the name of the variable directly to the MsgBox? I mean using the MsgBox that would display the name of the array which we are working on. Edited January 25 by antai Link to comment Share on other sites More sharing options...
ioa747 Posted January 24 Share Posted January 24 (edited) you don't need it because that's what you use in the $upArray parameter when you call the UpdateArray function. according to my knowledge what is missing is ReDim to resize the existing array. expandcollapse popup#include <AutoItConstants.au3> #include <Array.au3> Local $aArrayA[51][3] $aArrayA[0][0] = 50 For $i = 1 To $aArrayA[0][0] $aArrayA[$i][0] = "Var_" & $i Next Local $Var = "new" UpdateArray($aArrayA, $Var) UpdateArray($aArrayA, "new2") _ArrayDisplay($aArrayA, "$aArrayA") ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Local $aArrayB[11][5] $aArrayB[0][0] = 10 For $i = 1 To $aArrayB[0][0] $aArrayB[$i][0] = "Var_" & $i Next Local $Var = "new" UpdateArray($aArrayB, $Var) _ArrayDisplay($aArrayB, "$aArrayB") ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _ArrayAdd($aArrayB, "New with _ArrayAdd") $aArrayB[0][0] += 1 _ArrayAdd($aArrayB, "another|with|_ArrayAdd") $aArrayB[0][0] += 1 _ArrayDisplay($aArrayB, "$aArrayB") ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func UpdateArray(ByRef $upArray, $addvariable, $line = @ScriptLineNumber) ConsoleWrite("- Call from Line Number:" & $line & @CRLF) Local $iRows = UBound($upArray, $UBOUND_ROWS) ; Total number of rows. Local $iCols = UBound($upArray, $UBOUND_COLUMNS) ; Total number of columns. ConsoleWrite("$iRows:" & $iRows & ", $iCols:" & $iCols & @CRLF) ReDim $upArray[$iRows + 1][$iCols] $upArray[0][0] = $iRows $upArray[$iRows][0] = $addvariable EndFunc ;==>UpdateArray Edit: You shows us the function, but nowhere how you call it Edited January 24 by ioa747 update antai 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Solution jchd Posted January 24 Solution Share Posted January 24 @antai your code refers to $uArray. What's that? antai 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
antai Posted January 25 Author Share Posted January 25 19 hours ago, jchd said: @antai your code refers to $uArray. What's that? sorry typo (post corrected) Link to comment Share on other sites More sharing options...
antai Posted January 25 Author Share Posted January 25 (edited) 20 hours ago, ioa747 said: how you call it This causes loss of data during the array update: If $condition Then UpdateArray ($arrayA, $variable) ; UpdateArray ($arrayB, $variable) Else ; UpdateArray ($arrayA, $variable) UpdateArray ($arrayB, $variable) EndIf This works fine. All the data in the arrayA: If $condition Then UpdateArray ($arrayA, $variable) ; UpdateArray ($arrayB, $variable) Else UpdateArray ($arrayA, $variable) ; UpdateArray ($arrayB, $variable) EndIf This works fine, All thedata in the arrayB: If $condition Then ; UpdateArray ($arrayA, $variable) UpdateArray ($arrayB, $variable) Else ; UpdateArray ($arrayA, $variable) UpdateArray ($arrayB, $variable) EndIf Edited January 25 by antai Link to comment Share on other sites More sharing options...
antai Posted January 25 Author Share Posted January 25 SOLVED: typo. FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AAAAAAAAAAAAAAAAAAA CK!! 15 hours of testing and sleep deprivation because of a simple typo. Thanks guys, you really helped me. Your questions pointed me to the right direction. For those who care: the function is way longer and I several times update the $upArray[0][0] I mistyped that in one single occasion causing it to not get updated under certain conditions. No difference when throwing data only to a single array as it always goes up but more arrays caused problems due to calling a completely different variable! 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