qwer85 Posted September 19, 2007 Share Posted September 19, 2007 I have foll script. Why my file is empty, when i use string in array? Global $users[255][3] For $i = 0 To UBound($users, 1) - 1 For $k = 0 To UBound($users, 2) - 1 $users[$i][$k] = 0 Next Next $users[0][0] = "User1231" ; This expression doesn't work ;$users[0][0] = 1231 ; But this one WORKS FINE! $users[0][1] = 12312382 Local $file = FileOpen("test.txt", 2) For $i = 0 To UBound($users) - 1 If $users[$i][0] = 0 Then ContinueLoop FileWriteLine($file, $users[$i][0] & " | " & $users[$i][1]) Next FileClose($file) Link to comment Share on other sites More sharing options...
qwer85 Posted September 19, 2007 Author Share Posted September 19, 2007 (edited) Ok I found out why it's not writing in file - If $users[$i][0] = 0 Then ContinueLoop is activated and it's exiting the loop. But... wtf? Why after $users[0][0] = "User1231" the If statement shows true on $users[$i][0] = 0 expression? Edited September 19, 2007 by qwer85 Link to comment Share on other sites More sharing options...
qwer85 Posted September 19, 2007 Author Share Posted September 19, 2007 (edited) Well I managed to fix the problem by changing If $users[$i][0] = 0 Then ContinueLoop to If $users[$i][0] = "" Then ContinueLoop. But I can't undersand why string = 0 in arrays. Edited September 19, 2007 by qwer85 Link to comment Share on other sites More sharing options...
ResNullius Posted September 19, 2007 Share Posted September 19, 2007 But I can't undersand why string = 0 in arrays.Not just in arrays: MsgBox(0,"TEST","STRING" = 0) From the helpfile under "Language Reference - Datatypes" A variant can contain numeric or string data and decides how to use the data depending on the situation it is being used in. For example, if you try and multiply two variants they will be treated as numbers, if you try and concatenate (join) two variants they will be treated as strings. ... If a string is used as a number, an implicit call to Number() function is done. So if it doesn't contain a valid number, it will be assumed to equal 0. For example, 10 * "fgh" equals the number 0. 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