Jump to content

I'm bad at types


 Share

Recommended Posts

IniWrite(@ScriptDir&"\Scores.txt","X",5,15)

$temp = IniRead(@ScriptDir&"\Scores.txt","X",4,10000)
If IniRead(@ScriptDir&"\Scores.txt","X",5,10000) > $temp Then
    MsgBox(0,"WTF","look at the comparison"&@CRLF&"15 > 10000 ?")
EndIf

$temp = IniRead(@ScriptDir&"\Scores.txt","X",4,9999)
If IniRead(@ScriptDir&"\Scores.txt","X",5,9999) > $temp Then
    MsgBox(0,"WTF","now look at the comparison"&@CRLF&"15 > 9999 ?")
EndIf

I am using BETA 3.2.9.1, and using XP Pro. but those shouldn't matter. Look at the two codes, nearly exactly the same, one is 10000 and the other 9999. 15 is less than both, but when in this format only registers as greater than 10000. what am I doing wrong?

Edited by crzftx
Link to comment
Share on other sites

  • Moderators

IniWrite(@ScriptDir&"\Scores.txt","X",5,15)

$temp = IniRead(@ScriptDir&"\Scores.txt","X",4,10000)
If IniRead(@ScriptDir&"\Scores.txt","X",5,10000) > $temp Then
    MsgBox(0,"WTF","look at the comparison"&@CRLF&"15 > 10000 ?")
EndIf

$temp = IniRead(@ScriptDir&"\Scores.txt","X",4,9999)
If IniRead(@ScriptDir&"\Scores.txt","X",5,9999) > $temp Then
    MsgBox(0,"WTF","now look at the comparison"&@CRLF&"15 > 9999 ?")
EndIf

I am using BETA 3.2.9.1, and using XP Pro. but those shouldn't matter. Look at the two codes, nearly exactly the same, one is 10000 and the other 9999. 15 is less than both, but when in this format only registers as greater than 10000. what am I doing wrong?

Has to be a bug?

Let me see if I can explain this so you go :):P;)

IniRead basically equals:

FileOpen

FileRead

String Manipulation

Return Val

FileClose

Nothing in there shows you it would return an integer or a number. The return value is actually a string :P ...

To do what you want: Number(IniRead(etc...)) or Int(IniRead(etc...)) will work.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Ahh, you are right. Why does IniRead(@ScriptDir&"\Scores.txt","X",4,10000) return "10000" instead of 10000?

Why would it return anything other than a string? You are "reading" a string value... how can it decide that this "1234" should be a number and not a string? Easier and less error prone to just make them all strings wouldn't you think (and leave it up to the user to make that string a number if deemed neccessary)?

And why is 15 > "10000" but less than "9999"?

Strings have a numeric value... just not what is listed in that string.

15 may be greater than "abcde" but may be less than "abcd".

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...