Agent Posted November 11, 2009 Share Posted November 11, 2009 in relation to my topic here: http://www.autoitscript.com/forum/index.php?showtopic=105226&st=0&gopid=744357&#entry744357but now im having problems calling formula ($var1 - $var2) / 10 where as Var1 would be for inputbox1 Var2 would be inputbox2 and calculate then show that value in which it equals to within a inputbox3how would you set it as a variable so it can be called through a function?keeps saying Warning: $Var1: possibly used before declaration Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 11, 2009 Share Posted November 11, 2009 in relation to my topic here: http://www.autoitscript.com/forum/index.php?showtopic=105226&st=0&gopid=744357&#entry744357but now im having problems calling formula ($var1 - $var2) / 10 where as Var1 would be for inputbox1 Var2 would be inputbox2 and calculate then show that value in which it equals to within a inputbox3how would you set it as a variable so it can be called through a function?Say what? keeps saying Warning: $Var1: possibly used before declarationThat means exactly what is says, $Var1 is possibly used before declaration.We can't really help you any better unless you tell us what the problem is, and maybe post a reproducer (short but runnable). .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Agent Posted November 11, 2009 Author Share Posted November 11, 2009 (edited) Say what? That means exactly what is says, $Var1 is possibly used before declaration.We can't really help you any better unless you tell us what the problem is, and maybe post a reproducer (short but runnable).Ok, so I made a GUI and what I'm trying to make it do is calculate numbers in only these two forms:(readfrominputbox1 - readfrominputbox2) / 10 = sendanswertoinputbox3so its like (1400 - 1000) / 10 = 40 Answer is to be converted down into a percentage form. thats why the above formula is being used in that manner...so if I put 1400 in one inputbox and 1000 in another input box, when I click the button" Calculate" it should output the answer into the input box designated for holding/showing the answer.Since there are three different input boxes each one containing a different variable and always the same secondary variable with same formula as above being used calculating into a different percentage... and outputting it seperately to a different input box designated for holding/showing each of their answers....take the numbers to the answer input boxes and add them all together, showing them within the total of all numbers input box...so its like (1400 - 1000) / 10 = 40(1200 - 1000) / 10 = 20(1800 - 1000) / 10 = 8040 + 20 + 80 = 140so the 140 would show 140 in the "total of all numbers input box" so it could mean something like... 140% chance to do a critical hit etc.. depending on how I'm using the formula.or if the cap for a critical hit would be 200%, it would then be 60% from critical hit cap Edited November 11, 2009 by Agent Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 11, 2009 Share Posted November 11, 2009 Look at GUICtrlRead() and GUICtrlSetData(). .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Agent Posted November 11, 2009 Author Share Posted November 11, 2009 Look at GUICtrlRead() and GUICtrlSetData().Ok, so I think I'm missing something as now no errors but the button isnt inserting the numbers into the fields... Link to comment Share on other sites More sharing options...
CodyBarrett Posted November 11, 2009 Share Posted November 11, 2009 Can you provide working example code of what you are trying to accomplish? [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Agent Posted November 11, 2009 Author Share Posted November 11, 2009 cody can I send it to you in a pm? Link to comment Share on other sites More sharing options...
Mison Posted November 11, 2009 Share Posted November 11, 2009 Study this example, who knows, this might help: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= GUICreate("Form1", 221, 122, 221, 149) $Input1 = GUICtrlCreateInput("", 8, 16, 41, 21) $Input2 = GUICtrlCreateInput("", 72, 16, 41, 21) $Input3 = GUICtrlCreateInput("", 144, 16, 49, 21) GUICtrlCreateLabel("+", 56, 16, 10, 17) GUICtrlCreateLabel("=", 120, 16, 10, 17) $Button1 = GUICtrlCreateButton("Calculate", 64, 64, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetData($Input3,GUICtrlRead($Input1)+GUICtrlRead($Input2)) EndSwitch WEnd Hi ;) Link to comment Share on other sites More sharing options...
Agent Posted November 11, 2009 Author Share Posted November 11, 2009 ah ok so I revamped the code i was using and made it a little more cleaner... Anything used in relation to create the same type of application as I, please give me credit in terms of "giving you inspiration to create" expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Math.au3> ;^^^^^^^^^^^^^^^^^^^Control Libraries to Include so it can fully read everything as intended^^^^^^^^^^^^^^^^^^^ ;============================================================================================================== ;============================================================================================================== ;===============This Program is not to be used in any other way except for its intended purpose================ ;==================================Created on the year 2009==================================================== ;========================By, Ambisagrus/Alabaster of Elyos Siel server on NA Aion Online v1.0.1================ ;============================================================================================================== ;============================================================================================================== ;###################################GUI Creation##################################### ;==================================Title of Program================================== $ACMForm = GUICreate("% Calculator by www.theuber.org", 412, 227, 368, 243) $Group1 = GUICtrlCreateGroup("", 8, 72, 393, 145) $Eacc = GUICtrlCreateInput("Enemy Accuracy goes here", 96, 88, 161, 21) $Yeva = GUICtrlCreateInput("Your Evade value", 96, 112, 161, 21) $Cevacha = GUICtrlCreateInput("Evade %", 272, 112, 113, 21) $Cparcha = GUICtrlCreateInput("Parry %", 272, 136, 113, 21) $Cblocha = GUICtrlCreateInput("Block %", 272, 160, 113, 21) $Yblo = GUICtrlCreateInput("Your Block value", 96, 160, 161, 21) $Ypar = GUICtrlCreateInput("Your Parry value", 96, 136, 161, 21) $Sall = GUICtrlCreateInput("Total outcome of all the % are calculated and shown here", 96, 184, 289, 21) $Evade = GUICtrlCreateButton("Evade", 16, 112, 73, 17, $WS_GROUP) $Parry = GUICtrlCreateButton("Parry", 16, 136, 73, 17, $WS_GROUP) $Block = GUICtrlCreateButton("Block", 16, 160, 73, 17, $WS_GROUP) $addtop3 = GUICtrlCreateButton("Add Top 3", 16, 184, 73, 17, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) $Header = GUICtrlCreatePic("", 16, 8, 377, 57, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Evade CalculateEvade() Case $Parry CalculateParry() Case $Block CalculateBlock() Case $addtop3 Addall() EndSwitch WEnd Func CalculateEvade() $enemyaccuracy = GUICtrlRead($Eacc) $evadevalue = GUICtrlRead($Yeva) $evademath = Number(($evadevalue - $enemyaccuracy) / 10) $evadepercent = GUICtrlSetData($Cevacha, $evademath) EndFunc ;==>CalculateEvade Func CalculateParry() $enemyaccuracy = GUICtrlRead($Eacc) $parryvalue = GUICtrlRead($Ypar) $parrymath = Number(($parryvalue - $enemyaccuracy) / 10) $parrypercent = GUICtrlSetData($Cparcha, $parrymath) EndFunc ;==>CalculateParry Func CalculateBlock() $enemyaccuracy = GUICtrlRead($Eacc) $blockvalue = GUICtrlRead($Yblo) $blockmath = Number(($blockvalue - $enemyaccuracy) / 10) $blockpercent = GUICtrlSetData($Cblocha, $blockmath) EndFunc ;==>CalculateBlock Func Addall() $totalevadepercent = GUICtrlRead($Cevacha) $totalparrypercent = GUICtrlRead($Cparcha) $totalblockpercent = GUICtrlRead($Cblocha) $var1 = number(0.70 * $totalevadepercent) $var2 = number(0.70 * $totalparrypercent) $var3 = number(0.70 * $totalblockpercent) $addedall = number($var1 + $var2 + $var3) GUICtrlSetData($Sall, $addedall) EndFunc ;==>Calculate Link to comment Share on other sites More sharing options...
martin Posted November 11, 2009 Share Posted November 11, 2009 Do you have a problem with the code you posted? 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...
Agent Posted November 11, 2009 Author Share Posted November 11, 2009 (edited) Do you have a problem with the code you posted? Yes, it keeps outputting numbers in decimal form and I'm wanting it as whole numbers from 1-100 and to be shown as percentages as a whole number... Also on top of that its giving me negatives, though answer is correct, its in negative form.. o.o anyway to block negative numbers unless given numbers on input box is typed as a negative? Below is new code.. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Math.au3> ;^^^^^^^^^^^^^^^^^^^Control Libraries to Include so it can fully read everything as intended^^^^^^^^^^^^^^^^^^^ ;============================================================================================================== ;============================================================================================================== ;===============This Program is not to be used in any other way except for its intended purpose================ ;==================================Created on the year 2009==================================================== ;========================By, Ambisagrus/Alabaster of Elyos Siel server on NA Aion Online v1.0.1================ ;============================================================================================================== ;============================================================================================================== ;###################################GUI Creation##################################### ;==================================Title of Program================================== $ACMForm = GUICreate("% Calculator by www.theuber.org", 412, 227, 368, 243) $Group1 = GUICtrlCreateGroup("", 8, 72, 393, 145) $Eacc = GUICtrlCreateInput("Enemy Accuracy goes here", 96, 88, 161, 21) $Yeva = GUICtrlCreateInput("Your Evade value", 96, 112, 161, 21) $Cevacha = GUICtrlCreateInput("Evade %", 272, 112, 113, 21) $Cparcha = GUICtrlCreateInput("Parry %", 272, 136, 113, 21) $Cblocha = GUICtrlCreateInput("Block %", 272, 160, 113, 21) $Yblo = GUICtrlCreateInput("Your Block value", 96, 160, 161, 21) $Ypar = GUICtrlCreateInput("Your Parry value", 96, 136, 161, 21) $Sall = GUICtrlCreateInput("Total outcome of all the % are calculated and shown here", 96, 184, 289, 21) $Evade = GUICtrlCreateButton("Evade", 16, 112, 73, 17, $WS_GROUP) $Parry = GUICtrlCreateButton("Parry", 16, 136, 73, 17, $WS_GROUP) $Block = GUICtrlCreateButton("Block", 16, 160, 73, 17, $WS_GROUP) $addtop3 = GUICtrlCreateButton("Add Top 3", 16, 184, 73, 17, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) $Header = GUICtrlCreatePic("", 16, 8, 377, 57, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Evade CalculateEvade() Case $Parry CalculateParry() Case $Block CalculateBlock() Case $addtop3 Addall() EndSwitch WEnd Func CalculateEvade() $enemyaccuracy = GUICtrlRead($Eacc) $evadevalue = GUICtrlRead($Yeva) $evademath = Number(($evadevalue - $enemyaccuracy) / 10) $evadepercent = GUICtrlSetData($Cevacha, $evademath) EndFunc ;==>CalculateEvade Func CalculateParry() $enemyaccuracy = GUICtrlRead($Eacc) $parryvalue = GUICtrlRead($Ypar) $parrymath = Number(($parryvalue - $enemyaccuracy) / 10) $parrypercent = GUICtrlSetData($Cparcha, $parrymath) EndFunc ;==>CalculateParry Func CalculateBlock() $enemyaccuracy = GUICtrlRead($Eacc) $blockvalue = GUICtrlRead($Yblo) $blockmath = Number(($blockvalue - $enemyaccuracy) / 10) $blockpercent = GUICtrlSetData($Cblocha, $blockmath) EndFunc ;==>CalculateBlock Func Addall() $totalevadepercent = GUICtrlRead($Cevacha) $totalparrypercent = GUICtrlRead($Cparcha) $totalblockpercent = GUICtrlRead($Cblocha) $70perctodegree = 40.1070457 $30perctodegree = 17.1887339 $40perctodegree = 22.9183118 $50perctodegree = 28.6478898 $var1 = cos((180 * $30perctodegree) * $totalevadepercent) $var2 = cos((180 * $40perctodegree) * $totalparrypercent) $var3 = cos((180 * $50perctodegree) * $totalblockpercent) $addedall = cos((180 * $70perctodegree) * $var1 + (180 * $70perctodegree) * $var2 + (180 * $70perctodegree) * $var3) GUICtrlSetData($Sall, $addedall) EndFunc ;==>Addall Edited November 11, 2009 by Agent Link to comment Share on other sites More sharing options...
martin Posted November 11, 2009 Share Posted November 11, 2009 Look up the functions Int, Ceiling and Floor.If you want to test if the input in an edit is a negative number all you need isIf Number(GuiCrtlRead($input)) < 0 then $itsnegative = TrueThese are very basic things though and the help file should be where you look. But perhaps I have not understood. 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...
CodyBarrett Posted November 11, 2009 Share Posted November 11, 2009 as martin said.int (($var1 - $var2) / 10) = ?? it SHOULD bring up a whole number. [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Agent Posted November 11, 2009 Author Share Posted November 11, 2009 (edited) lol omg im going insane, think im gonna try a slightly different formula real quick see if that fixes it.. ok that fixed it... case closed for now had to do different math, kept including failure percentages but not success percentages =\ so XD Edited November 11, 2009 by Agent Link to comment Share on other sites More sharing options...
DaveB Posted April 10, 2011 Share Posted April 10, 2011 (edited) Say what? That means exactly what is says, $Var1 is possibly used before declaration. We can't really help you any better unless you tell us what the problem is, and maybe post a reproducer (short but runnable). Ha guys, just play around with this code. Dave expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 233, 254, 255, 147) $Input1 = GUICtrlCreateInput("Input1", 40, 104, 145, 21) $Input2 = GUICtrlCreateInput("Input2", 40, 144, 145, 21) $Label1 = GUICtrlCreateLabel(" ", 16, 32, 200, 29) ;GUICtrlSetFont(-1, 16, 800, 0, "Bell MT") ;GUICtrlSetBkColor(-1, 0xFFFFFF) $Button1 = GUICtrlCreateButton("add", 72, 208, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $a=0, $b=0, $c=0 Func add() ;input $a ;input $b $c = $a + $b $Label1 = GUICtrlCreateLabel($c, 16, 32, 200, 29) GUICtrlSetFont(-1, 16, 800, 0, "Bell MT") GUICtrlSetBkColor(-1, 0xFFFFFF) Return EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;Case $Form1 Case $Input1 $a = GUICtrlRead($Input1) Case $Input2 $b = GUICtrlRead($Input2) Case $Button1 add() EndSwitch WEnd Edited April 10, 2011 by DaveB Link to comment Share on other sites More sharing options...
martin Posted April 10, 2011 Share Posted April 10, 2011 Hi DaveB. Every time you show a new value you are creating another label. You are giving it the reference $Label1 so you end up with lots of labels underneath the new one and you have lost the references to them so you can't do anything to them without a lot of effort. Don't create a new component when you want to update it, just update it. If you want to create a replacement component then delete the old one first. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 233, 254, 255, 147) $Input1 = GUICtrlCreateInput("Input1", 40, 104, 145, 21) $Input2 = GUICtrlCreateInput("Input2", 40, 144, 145, 21) $Label1 = GUICtrlCreateLabel(" ", 16, 32, 200, 29) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 16, 800, 0, "Bell MT") $Button1 = GUICtrlCreateButton("add", 72, 208, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 add() EndSwitch WEnd Func add() GUICtrlSetData($Label1, GUICtrlRead($Input1), GUICtrlRead($Input2)) Return EndFunc ;==>add 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...
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