Sign in to follow this  
Followers 0
mianz

Integer bug or my code problem?

3 posts in this topic

$datesplit = _StringSplit("18/11/2008", "/")

$date_day = GUICtrlCreateCombo("", 128, 176, 38, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))

GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31")

If $datesplit[0] < GUICtrlRead($date_day) Then

call("test")

lets say $datesplit[0] = 20 and GUICtrlRead($date_day) = 8

by right this shouldn't call test function, but it does.

if

$datesplit[0] = 20 and GUICtrlRead($date_day) = 16

this works fine as it won't call the function

if

$datesplit[0] = 20 and GUICtrlRead($date_day) = 23

this works fine as it call the function

i found that it only did not work if GUICtrlRead($date_day) is from 1 to 9

i try to edit the combo box

$date_day = GUICtrlCreateCombo("", 128, 176, 38, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))

GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31")

now everything works perfectly fine. why is this so?

Share this post


Link to post
Share on other sites



$datesplit = _StringSplit("18/11/2008", "/")

$date_day = GUICtrlCreateCombo("", 128, 176, 38, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))

GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31")

If $datesplit[0] < GUICtrlRead($date_day) Then

call("test")

lets say $datesplit[0] = 20 and GUICtrlRead($date_day) = 8

by right this shouldn't call test function, but it does.

if

$datesplit[0] = 20 and GUICtrlRead($date_day) = 16

this works fine as it won't call the function

if

$datesplit[0] = 20 and GUICtrlRead($date_day) = 23

this works fine as it call the function

i found that it only did not work if GUICtrlRead($date_day) is from 1 to 9

i try to edit the combo box

$date_day = GUICtrlCreateCombo("", 128, 176, 38, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))

GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31")

now everything works perfectly fine. why is this so?

It's a common brain problem :P

Try this

if "20" < "8" Then
  ConsoleWrite("????" & @CRLF)
  EndIf

You are using strings but you think you are using numbers. You need to convert variables to Number before you compare them as numbers.

If Number($datesplit[0]) < Number(GUICtrlRead($date_day)) Then
      call("test")
Endif

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Hi mianz,

I assume that Autoit sees the contents of your variables as strings.

If this is true then a left to right comparison is done and therefore stops after the

first character as "2" (as in "20") is lower then "8".

Check the datatype with "Ifstring($datesplit[0])"

HTH

Thomas


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0