future1995man Posted April 3, 2013 Share Posted April 3, 2013 Hi for all #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("autoitscript", 302, 153, 192, 124) $Label1 = GUICtrlCreateLabel("1", 40, 32, 18, 17) $Input1 = GUICtrlCreateInput("", 80, 32, 121, 21) $Label2 = GUICtrlCreateLabel("2", 40, 72, 10, 17) $Input2 = GUICtrlCreateInput("", 80, 64, 121, 21) $Button1 = GUICtrlCreateButton("collect", 96, 97, 81, 31) GUISetState(@SW_SHOW) $Input=GUICtrlRead($Input1) * GUICtrlRead($Input1) $text=$Input2 / $Input While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 MsgBox(0,"",$text) EndSwitch WEnd If user put 168 in INPUT1,, what is script that input 1 becomes 1,68 Another example: If you will put 172 in input1--- automatically it will be 1,72 If user put 77.3 in Input 2 ,, what is script that input 2 becomes 77 without ,3 Link to comment Share on other sites More sharing options...
czardas Posted April 3, 2013 Share Posted April 3, 2013 (edited) Firstly there was several problems with your script. I've cleaned that up a little bit. ;#include <ButtonConstants.au3> ;#include <EditConstants.au3> #include <GUIConstantsEx.au3> ;#include <StaticConstants.au3> ;#include <WindowsConstants.au3> Global $Form1 = GUICreate("autoitscript", 302, 153, 192, 124) Global $Label1 = GUICtrlCreateLabel("1", 40, 32, 18, 17) Global $Input1 = GUICtrlCreateInput("", 80, 32, 121, 21) Global $Label2 = GUICtrlCreateLabel("2", 40, 72, 10, 17) Global $Input2 = GUICtrlCreateInput("", 80, 64, 121, 21) Global $Button1 = GUICtrlCreateButton("collect", 96, 97, 81, 31) GUISetState(@SW_SHOW) Global $Input, $text, $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop case $Button1 $Input = GUICtrlRead($Input1) * GUICtrlRead($Input1) $text = GUICtrlRead($Input2) / $Input MsgBox(0,"",$text) EndSwitch WEnd Now as far as your questions are concerned, they are not entirely clear. You should look at the functions: Round() and maybe Floor() and Ceiling() depending on what you want. These functions all do a similar thing. You can also use the opperator /= 100. Edited April 3, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
MuchTex Posted April 3, 2013 Share Posted April 3, 2013 (edited) For Input1 (assuming all numbers will be 3 digits): $Input1Left = StringTrimLeft ( $Input1, 1 ) $Input1Right = StringTrimRight ($Input1,2) $Input1 = $Input1Left & "." & $Input1Right For Input2 (assuming you want to round the number up or down): Round ($Input2) Edited April 3, 2013 by MuchTex Link to comment Share on other sites More sharing options...
czardas Posted April 3, 2013 Share Posted April 3, 2013 (edited) Also possible: $iVal = 168 $iNewVal = StringReplace($iVal/100, ".", ",") MsgBox(0, "", $iNewVal) Edited April 3, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
future1995man Posted April 3, 2013 Author Share Posted April 3, 2013 #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1 = GUICreate("autoitscript", 302, 153, 192, 124) Global $Label1 = GUICtrlCreateLabel("1", 40, 32, 18, 17) Global $Input1 = GUICtrlCreateInput("", 80, 32, 121, 21) Global $Label2 = GUICtrlCreateLabel("2", 40, 72, 10, 17) Global $Input2 = GUICtrlCreateInput("", 80, 64, 121, 21) Global $Button1 = GUICtrlCreateButton("collect", 96, 97, 81, 31) GUISetState(@SW_SHOW) Global $Input, $text, $nMsg $Input1Left = StringTrimLeft ( $Input1, 1 ) $Input1Right = StringTrimRight ($Input1,2) $Input1 = $Input1Left & "." & $Input1Right $Input2=Round ($Input2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop case $Button1 $Input = GUICtrlRead($Input1) * GUICtrlRead($Input1) $text = GUICtrlRead($Input2) / GUICtrlRead($Input) MsgBox(0,"",GUICtrlRead($text)) EndSwitch WEnd This is my attempt Link to comment Share on other sites More sharing options...
FireFox Posted April 3, 2013 Share Posted April 3, 2013 Hi, Maybe this... expandcollapse popup#include <GUIConstantsEx.au3> #region GUI Local Const $hGUI = GUICreate("autoitscript", 302, 153) Local $iLabel1 = 0, $iInput1 = 0, $iLabel2 = 0, $iInput2 = 0, $iBtn1 = 0 $iLabel1 = GUICtrlCreateLabel("1", 40, 32, 18, 17) $iInput1 = GUICtrlCreateInput("", 80, 32, 121, 21) $iLabel2 = GUICtrlCreateLabel("2", 40, 72, 10, 17) $iInput2 = GUICtrlCreateInput("", 80, 64, 121, 21) $iBtn1 = GUICtrlCreateButton("collect", 96, 97, 81, 31) GUISetState(@SW_SHOW, $hGUI) #endregion Local $iMsg = 0, $sInput1Read = "", $sInput2Read = "" While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $iBtn1 $sInput1Read = GUICtrlRead($iInput1) If StringIsFloat($sInput1Read) = 0 Then GUICtrlSetData($iInput1, StringLeft($sInput1Read, 1) & "." & StringTrimLeft($sInput1Read, 1)) EndIf $sInput2Read = GUICtrlRead($iInput2) If StringIsFloat($sInput2Read) = 1 Then GUICtrlSetData($iInput2, StringLeft($sInput2Read, StringInStr($sInput2Read, ".", 2) -1)) EndIf EndSwitch WEnd GUIDelete($hGUI) Br, FireFox. Link to comment Share on other sites More sharing options...
czardas Posted April 3, 2013 Share Posted April 3, 2013 (edited) This is my attemptLook at the first changes I made for you in the second post and compair that with your original first post. You have to put the arguments inside the loop. You also have to read the data from the input controls with GUICtrlRead before you can do anything with it. These are the most important things you are not doing correctly, which is why it doesn't work as you expect.$input1 and $input2 are the input controls: they are not numbers. You have to read them. Edited April 3, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted April 4, 2013 Share Posted April 4, 2013 Here is a simplified example with comments explaining every step of the process in detail. You need to fully understand every line of code before you continue. expandcollapse popup; Get external libraries needed for the script #include <GUIConstantsEx.au3> ; Declare the varible names you need for the GUI Global $hGUI, $hInput, $hButton ; Create the GUI $hGUI = GUICreate("Example", 302, 153, 192, 124) ; Create a control $hInput = GUICtrlCreateInput("", 80, 32, 121, 21) ; Create another control $hButton = GUICtrlCreateButton("Read Input", 96, 97, 81, 31) ; Show the GUI GUISetState(@SW_SHOW) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Declare the varibles used in the loop Global $iMsg, $sData ; Loop forever While 1 ; Poll the controls to see if a message was received $iMsg = GUIGetMsg() ; See which message was received Switch $iMsg Case $GUI_EVENT_CLOSE ; Exit the loop ExitLoop case $hButton ; Read the input control $sData = GUICtrlRead($hInput) ; Do something with the data MsgBox(0 ,"Input Details", $sData) EndSwitch ; Go back to the start of the loop WEnd operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
future1995man Posted April 6, 2013 Author Share Posted April 6, 2013 (edited) #include <GUIConstantsEx.au3> #region GUI Local Const $hGUI = GUICreate("autoitscript", 302, 153) Local $iLabel1 = 0, $iInput1 = 0, $iLabel2 = 0, $iInput2 = 0, $iBtn1 = 0 $iLabel1 = GUICtrlCreateLabel("1", 40, 32, 18, 17) $iInput1 = GUICtrlCreateInput("", 80, 32, 121, 21) $iLabel2 = GUICtrlCreateLabel("2", 40, 72, 10, 17) $iInput2 = GUICtrlCreateInput("", 80, 64, 121, 21) $iBtn1 = GUICtrlCreateButton("collect", 96, 97, 81, 31) GUISetState(@SW_SHOW, $hGUI) #endregion Local $iMsg = 0, $sInput1Read = "", $sInput2Read = "" $sInput1Read = GUICtrlRead($iInput1) If StringIsFloat($sInput1Read) = 0 Then GUICtrlSetData($iInput1, StringLeft($sInput1Read, 1) & "." & StringTrimLeft($sInput1Read, 1)) EndIf $sInput2Read = GUICtrlRead($iInput2) If StringIsFloat($sInput2Read) = 1 Then $xinput= GUICtrlSetData($iInput2, StringLeft($sInput2Read, StringInStr($sInput2Read, ".", 2) -1))*GUICtrlSetData($iInput2, StringLeft($sInput2Read, StringInStr($sInput2Read, ".", 2) -1) EndIf $text= GUICtrlRead($sInput2Read) / $xinput $XTEXT=GUICtrlRead($text) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $iBtn1 MsgBox(0,"",$XTEXT) EndSwitch WEnd GUIDelete($hGUI) Edited April 6, 2013 by future1995man Link to comment Share on other sites More sharing options...
future1995man Posted April 6, 2013 Author Share Posted April 6, 2013 (edited) czardasFirefox(#6 )thanks Edited April 6, 2013 by future1995man Link to comment Share on other sites More sharing options...
future1995man Posted April 6, 2013 Author Share Posted April 6, 2013 (edited) #include <GUIConstantsEx.au3> #region GUI Local Const $hGUI = GUICreate("autoitscript", 302, 153) Local $iLabel1 = 0, $iInput1 = 0, $iLabel2 = 0, $iInput2 = 0, $iBtn1 = 0 $iLabel1 = GUICtrlCreateLabel("1", 40, 32, 18, 17) $iInput1 = GUICtrlCreateInput("", 80, 32, 121, 21) $iLabel2 = GUICtrlCreateLabel("2", 40, 72, 10, 17) $iInput2 = GUICtrlCreateInput("", 80, 64, 121, 21) $iBtn1 = GUICtrlCreateButton("collect", 96, 97, 81, 31) GUISetState(@SW_SHOW, $hGUI) #endregion Local $iMsg = 0, $sInput1Read = "", $sInput2Read = "" $sInput1Read = GUICtrlRead($iInput1) If StringIsFloat($sInput1Read) = 0 Then GUICtrlSetData($iInput1, StringLeft($sInput1Read, 1) & "." & StringTrimLeft($sInput1Read, 1)) EndIf $sInput2Read = GUICtrlRead($iInput2) If StringIsFloat($sInput2Read) = 1 Then $xinput= GUICtrlSetData($iInput2, StringLeft($sInput2Read, StringInStr($sInput2Read, ".", 2) -1))*GUICtrlSetData($iInput2, StringLeft($sInput2Read, StringInStr($sInput2Read, ".", 2) -1) EndIf $text= GUICtrlRead($sInput2Read) / $xinput $XTEXT=GUICtrlRead($text) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $iBtn1 MsgBox(0,"",$XTEXT) EndSwitch WEnd GUIDelete($hGUI) I want the result show in message for example INPUT 1 = 168 INPUT 2 = 88.3 OR 88,3 When I press collect button, It will show result in msgbox The result will be as number from following operation 88 / (1.68*1.68) result = INPUT 2 / (input1*input1) Edited April 6, 2013 by future1995man Link to comment Share on other sites More sharing options...
czardas Posted April 6, 2013 Share Posted April 6, 2013 Hmm, you are still reading the input controls before you type anything in them. You only read the control after you click the button - as I have shown in my previous post. Please look at it again. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
future1995man Posted April 6, 2013 Author Share Posted April 6, 2013 Hmm, you are still reading the input controls before you type anything in them. You only read the control after you click the button - as I have shown in my previous post. Please look at it again.I look it more one time but I can not do that. Link to comment Share on other sites More sharing options...
czardas Posted April 6, 2013 Share Posted April 6, 2013 (edited) I don't understand you. You are reading the controls (one time only) before you have time to type anything into them. So you are doing a calculation on nothing. The answer you get will always be wrong, unless you put GUICtrlRead in the right place (inside the while loop). I can't think of any simpler way to explain this. Edited April 6, 2013 by czardas James 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
future1995man Posted April 19, 2013 Author Share Posted April 19, 2013 expandcollapse popup#include <GUIConstantsEx.au3> #region GUI Local Const $hGUI = GUICreate("autoitscript", 302, 153) Local $iLabel1 = 0, $iInput1 = 0, $iLabel2 = 0, $iInput2 = 0, $iBtn1 = 0 $iLabel1 = GUICtrlCreateLabel("height", 40, 32, 40, 17) $iInput1 = GUICtrlCreateInput("", 80, 32, 121, 21) $iLabel2 = GUICtrlCreateLabel("mass", 40, 72, 30, 17) $iInput2 = GUICtrlCreateInput("", 80, 64, 121, 21) $iBtn1 = GUICtrlCreateButton("Body mass index", 90, 97, 100, 31) GUISetState(@SW_SHOW, $hGUI) #endregion Local $iMsg = 0, $sInput1Read = "", $sInput2Read = "" $sInput1Read = GUICtrlRead($iInput1) If StringIsFloat($sInput1Read) = 0 Then GUICtrlSetData($iInput1, StringLeft($sInput1Read, 1) & "." & StringTrimLeft($sInput1Read, 1)) EndIf $sInput2Read = GUICtrlRead($iInput2) If StringIsFloat($sInput2Read) = 1 Then GUICtrlSetData($iInput2, StringLeft($sInput2Read, StringInStr($sInput2Read, ".", 2) -1)) EndIf $height=$sinput1read*$siInput1Read $Bodymassindex=$sInput2Read/$height While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $iBtn1 MsgBox(0,"","Body mass index is"&$bodymassindex") EndSwitch WEnd GUIDelete($hGUI) I wait experts in this forum. Link to comment Share on other sites More sharing options...
FireFox Posted April 19, 2013 Share Posted April 19, 2013 Can you be at least one time enough clear to explain your problem? Link to comment Share on other sites More sharing options...
future1995man Posted April 19, 2013 Author Share Posted April 19, 2013 Can you be at least one time enough clear to explain your problem?I want make tool for next topichttp://en.wikipedia.org/wiki/Body_mass_index Link to comment Share on other sites More sharing options...
FireFox Posted April 19, 2013 Share Posted April 19, 2013 This is more vague than what you already said... Link to comment Share on other sites More sharing options...
future1995man Posted April 19, 2013 Author Share Posted April 19, 2013 This is more vague than what you already said...If any one enter his height(m) & weight(kg) inside boxex then calculate bottun, it will appear BMI Link to comment Share on other sites More sharing options...
jchd Posted April 19, 2013 Share Posted April 19, 2013 Are you the poster of If so, be aware that using multiple accounts is not within forum rules (link at the bottom right of these pages). This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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