546f6d6173 Posted March 2, 2008 Share Posted March 2, 2008 Hi all. I heave question. Why do not working this comparison of two values ? It compare correct only first two position of numbers. Try to write for example 100 and 50. Where is the problem?? Sorry for my english. Many thanks. CODE#include <GUIConstants.au3> GuiCreate("Compare two values", 280, 200, 200, 200) $val1 = GUICtrlCreateInput ( "", 20, 110, 50, 20) $name1 = GUICtrlCreateLabel("First value", 75, 115, 60, 20) $val2 = GUICtrlCreateInput ( "", 20, 130, 50, 20 ) $name2 = GUICtrlCreateLabel("second value", 75, 135, 80, 20) $okbt = GUICtrlCreateButton("OK", 170, 130, 60, 20) GUISetState() Do $msg = GUIGetMsg() if $msg = $okbt Then $v1 = GUICtrlRead($val1) $v2 = GUICtrlRead($val2) MsgBox(0,"Info","First value is: " & $v1) MsgBox(0,"Info","Second value is: " & $v2) ;---------------------- if $val1 > $val2 Then MsgBox(0,"Info","First value is GREATER than second") ExitLoop Else MsgBox(0,"info","First value is SMALLER than second") EndIf ;--------------------- ExitLoop EndIf Until $msg = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
GEOSoft Posted March 2, 2008 Share Posted March 2, 2008 Hi all. I heave question. Why do not working this comparison of two values ? It compare correct only first two position of numbers. Try to write for example 100 and 50. Where is the problem?? Sorry for my english. Many thanks. CODE#include <GUIConstants.au3> GuiCreate("Compare two values", 280, 200, 200, 200) $val1 = GUICtrlCreateInput ( "", 20, 110, 50, 20) $name1 = GUICtrlCreateLabel("First value", 75, 115, 60, 20) $val2 = GUICtrlCreateInput ( "", 20, 130, 50, 20 ) $name2 = GUICtrlCreateLabel("second value", 75, 135, 80, 20) $okbt = GUICtrlCreateButton("OK", 170, 130, 60, 20) GUISetState() Do $msg = GUIGetMsg() if $msg = $okbt Then $v1 = GUICtrlRead($val1) $v2 = GUICtrlRead($val2) MsgBox(0,"Info","First value is: " & $v1) MsgBox(0,"Info","Second value is: " & $v2) ;---------------------- if $val1 > $val2 Then MsgBox(0,"Info","First value is GREATER than second") ExitLoop Else MsgBox(0,"info","First value is SMALLER than second") EndIf ;--------------------- ExitLoop EndIf Until $msg = $GUI_EVENT_CLOSEif $v1 > $v2 Then MsgBox(0,"Info","First value is GREATER than second") ExitLoop Else MsgBox(0,"info","First value is SMALLER than second") EndIf ;--------------------- ExitLoop EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
martin Posted March 2, 2008 Share Posted March 2, 2008 Hi all. I heave question. Why do not working this comparison of two values ? It compare correct only first two position of numbers. Try to write for example 100 and 50. Where is the problem?? Sorry for my english. Many thanks. CODE#include <GUIConstants.au3> GuiCreate("Compare two values", 280, 200, 200, 200) $val1 = GUICtrlCreateInput ( "", 20, 110, 50, 20) $name1 = GUICtrlCreateLabel("First value", 75, 115, 60, 20) $val2 = GUICtrlCreateInput ( "", 20, 130, 50, 20 ) $name2 = GUICtrlCreateLabel("second value", 75, 135, 80, 20) $okbt = GUICtrlCreateButton("OK", 170, 130, 60, 20) GUISetState() Do $msg = GUIGetMsg() if $msg = $okbt Then $v1 = GUICtrlRead($val1) $v2 = GUICtrlRead($val2) MsgBox(0,"Info","First value is: " & $v1) MsgBox(0,"Info","Second value is: " & $v2) ;---------------------- if $val1 > $val2 Then MsgBox(0,"Info","First value is GREATER than second") ExitLoop Else MsgBox(0,"info","First value is SMALLER than second") EndIf ;--------------------- ExitLoop EndIf Until $msg = $GUI_EVENT_CLOSEGuiCtrlRead returns a string, so you need a number so use $val = Number(GuiCtrlRead(...)) Also, a small error in your logic, the values could be equal so Else MsgBox(0,"info","First value is NOT LARGER than second") 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. Link to comment Share on other sites More sharing options...
FreeRider Posted March 2, 2008 Share Posted March 2, 2008 Hello If you want to compare values... be sure to compare numbers... and compare the values but not the controls (you use $val1 and $val2 instead of $v1 and $v2) With your script modified (see below) it works : #include <GUIConstants.au3> GuiCreate("Compare two values", 280, 200, 200, 200) $val1 = GUICtrlCreateInput ( "", 20, 110, 50, 20) $name1 = GUICtrlCreateLabel("First value", 75, 115, 60, 20) $val2 = GUICtrlCreateInput ( "", 20, 130, 50, 20 ) $name2 = GUICtrlCreateLabel("second value", 75, 135, 80, 20) $okbt = GUICtrlCreateButton("OK", 170, 130, 60, 20) GUISetState() Do $msg = GUIGetMsg() if $msg = $okbt Then $v1 = Number(GUICtrlRead($val1)) $v2 = Number(GUICtrlRead($val2)) MsgBox(0,"Info","First value is: " & $v1) MsgBox(0,"Info","Second value is: " & $v2) ;---------------------- if $v1 > $v2 Then MsgBox(0,"Info","First value is GREATER than second") ExitLoop ElseIf $v1 < $v2 Then MsgBox(0,"info","First value is SMALLER than second") ElseIf $v1 = $v2 Then MsgBox(0,"info","First value is EQUAL to second") EndIf ;--------------------- ExitLoop EndIf Until $msg = $GUI_EVENT_CLOSE Bye... FreeRiderHonour & Fidelity Link to comment Share on other sites More sharing options...
546f6d6173 Posted March 2, 2008 Author Share Posted March 2, 2008 Oh my.. I was really used $val1 and $val2 instead of $v1 and $v2. Of course...But the main problem was here: Number(GUICtrlRead($val1)).Now it's working fine! Many thanks for all !Bye. Link to comment Share on other sites More sharing options...
GEOSoft Posted March 2, 2008 Share Posted March 2, 2008 (edited) Oh my.. I was really used $val1 and $val2 instead of $v1 and $v2. Of course... But the main problem was here: Number(GUICtrlRead($val1)). Now it's working fine! Many thanks for all ! Bye.That of course was the best solution. You could however also use If Number($v1) > Number($v2) Then Edit: If the inputs should only except numbers then use $ES_NUMBER (0x2000) in the style. or at least do a check with If IsNumber() Edited March 2, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
FreeRider Posted March 2, 2008 Share Posted March 2, 2008 No problem my friend... I had exactly the same problem in the past and it took me time to realize that I was using text instead of numbers... And regarding the wrong variable usage.... don't worry I continue to sometime make errors due to this. FreeRiderHonour & Fidelity Link to comment Share on other sites More sharing options...
JWille Posted March 4, 2008 Share Posted March 4, 2008 (edited) I am having a similar problem but I am wanting to read the text from the control.The text I am wanting to read is formatted like so: "10/10". I keep getting "1" as the return value when I want the actual text "10/10"Any help much appreciated! Never mind.Figured out my typo...One of those days!! Edited March 4, 2008 by JWille 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