rodiney Posted February 18, 2016 Share Posted February 18, 2016 I want to do an if in the array. in my array the value can be 0. $ Array [0] = 0 as I do to check if array is empty? if $ array [0] = "" the endif It works well? Link to comment Share on other sites More sharing options...
InunoTaishou Posted February 18, 2016 Share Posted February 18, 2016 Are you checking if the whole array is empty? #include <Array.au3> Global const $SORT_DESCENDING = 1 Global $array[] = [3, 2, 1, 5, 1, "Test", "String", 99, 3, 0] Global $array2[] = [0, 0, 0, 0, "", "", 0, 0] _ArraySort($array, $SORT_DESCENDING) _ArraySort($array2, $SORT_DESCENDING) If ($array[0] or StringLen($array)) Then MsgBox("", "", "The first array is not empty") Else MsgBox("", "", "The first array is empty") EndIf If ($array2[0] or StringLen($array2)) Then MsgBox("", "", "The second array is not empty") Else MsgBox("", "", "The second array is empty") EndIf rodiney 1 Link to comment Share on other sites More sharing options...
czardas Posted February 18, 2016 Share Posted February 18, 2016 (edited) 3 hours ago, rodiney said: It works well? No it does not work well. To test the first element, you could use: If $aArray[0] == "" Then MsgBox(0, "Contents", "nothing") To test if the array actually contains elements, you should use: If UBound($aArray) = 0 Then MsgBox(0, "Contents", "zero elements") These examples will only work with 1D arrays. Edited February 18, 2016 by czardas toto22 and SkysLastChance 2 operator64 ArrayWorkshop 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