Maxtreeme Posted April 3, 2007 Share Posted April 3, 2007 (edited) Dunno if anyone will find it usefull, but i did I updated the code, thanks Zedna Resistor_Calculator.au3 Edited April 4, 2007 by Maxtreeme Link to comment Share on other sites More sharing options...
gseller Posted April 3, 2007 Share Posted April 3, 2007 That is very nice, could have used that several yrs back when I was into electronics.. LOL Fingers are too fat now to mess with it.. LOL Link to comment Share on other sites More sharing options...
condoman Posted April 3, 2007 Share Posted April 3, 2007 Great job. It beats reciting BBROUGBVGW. Link to comment Share on other sites More sharing options...
jvanegmond Posted April 3, 2007 Share Posted April 3, 2007 Nice job. I have been wanting to do this a long time.. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Maxtreeme Posted April 3, 2007 Author Share Posted April 3, 2007 Thanks for the replies, i was working on it some time to get it right Maybe i will post some more scripts laterz Link to comment Share on other sites More sharing options...
Zedna Posted April 3, 2007 Share Posted April 3, 2007 Nice. Little idea for improve: Instead of resulting messagebox use labels on your GUI and use GUICtrlSetData. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Maxtreeme Posted April 4, 2007 Author Share Posted April 4, 2007 made some changes to the code no messageboxes Link to comment Share on other sites More sharing options...
Valuater Posted April 4, 2007 Share Posted April 4, 2007 (edited) Love it!!! As I was Taught in College Bad Boys Rape Our Young Girls But Violet Gives Willingly... (The Resistor code) 8) Edited April 4, 2007 by Valuater Link to comment Share on other sites More sharing options...
Zedna Posted April 4, 2007 Share Posted April 4, 2007 (edited) made some changes to the code no messageboxes Here is another corrected version of your code: when you changed some colors there was artefacts due to not using GUICtrlSetData but GUICtrlCreateLabel repeatedly and some other little optimizations. And another idea for improve: remove button Calculate and use GUIRegisterMsg to catch event for editchanged (I dn't know exactly what event) expandcollapse popup#include <GUIConstants.au3> GUICreate("Resistance Calculator v1.0",500,200) $1 = GUICtrlCreateCombo ("First color", 10,10,100,20) GUICtrlSetData($1,"Brown|Red|Orange|Yellow|Green|Blue|Violet|Gray|White") $2 = GUICtrlCreateCombo ("Second color", 120,10,100,20) GUICtrlSetData($2,"Black|Brown|Red|Orange|Yellow|Green|Blue|Violet|Gray|White") $3 = GUICtrlCreateCombo ("Third color", 230,10,100,20) GUICtrlSetData($3,"Silver|Gold|Black|Brown|Red|Orange|Yellow|Green|Blue|Violet|Gray|White") $4 = GUICtrlCreateCombo ("Fourth color", 340,10,100,20) GUICtrlSetData($4,"Silver|Gold|Brown|Red") $calc = GUICtrlCreateButton ("Calculate",400,140,70,30) GUICtrlCreateLabel ("More scripts on: www.scripthut.z1.ro",10,180) $result_ohm = GUICtrlCreateLabel ("",10,60,300) $result_kohm = GUICtrlCreateLabel ("",10,80,300) $result_mohm = GUICtrlCreateLabel ("",10,100,300) GUISetState (@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf If $msg = $calc Then $read1 = GUICtrlRead ($1) $read2 = GUICtrlRead ($2) $read3 = GUICtrlRead ($3) $read4 = GUICtrlRead ($4) If $read1 = "First color" Or $read2 = "Second color" Or $read3 = "Third color" Or $read4 = "Fourth color" Then GUICtrlSetData($result_ohm,"") GUICtrlSetData($result_kohm,"") GUICtrlSetData($result_mohm,"") MsgBox (48,"Resistance Calculator v1.0","You didn't select all the colors!") Else If $read1 = "Brown" Then $color1 = 1 ElseIf $read1 = "Red" Then $color1 = 2 ElseIf $read1 = "Orange" Then $color1 = 3 ElseIf $read1 = "Yellow" Then $color1 = 4 ElseIf $read1 = "Green" Then $color1 = 5 ElseIf $read1 = "Blue" Then $color1 = 6 ElseIf $read1 = "Violet" Then $color1 = 7 ElseIf $read1 = "Gray" Then $color1 = 8 ElseIf $read1 = "White" Then $color1 = 9 EndIf If $read2 = "Black" Then $color2 = 0 ElseIf $read2 = "Brown" Then $color2 = 1 ElseIf $read2 = "Red" Then $color2 = 2 ElseIf $read2 = "Orange" Then $color2 = 3 ElseIf $read2 = "Yellow" Then $color2 = 4 ElseIf $read2 = "Green" Then $color2 = 5 ElseIf $read2 = "Blue" Then $color2 = 6 ElseIf $read2 = "Violet" Then $color2 = 7 ElseIf $read2 = "Gray" Then $color2 = 8 ElseIf $read2 = "White" Then $color2 = 9 EndIf If $read3 = "Black" Then $color3 = 1 ElseIf $read3 = "Brown" Then $color3 = 10 ElseIf $read3 = "Red" Then $color3 = 100 ElseIf $read3 = "Orange" Then $color3 = 1000 ElseIf $read3 = "Yellow" Then $color3 = 10000 ElseIf $read3 = "Green" Then $color3 = 100000 ElseIf $read3 = "Blue" Then $color3 = 1000000 ElseIf $read3 = "Violet" Then $color3 = 10000000 ElseIf $read3 = "Gray" Then $color3 = 100000000 ElseIf $read3 = "White" Then $color3 = 1000000000 ElseIf $read3 = "Silver" Then $color3 = 0.01 ElseIf $read3 = "Gold" Then $color3 = 0.1 EndIf If $read4 = "Silver" Then $tol = "+- 10%" ElseIf $read4 = "Gold" Then $tol = "+- 5%" ElseIf $read4 = "Brown" Then $tol = "+- 1%" ElseIf $read4 = "Red" Then $tol = "+- 2%" EndIf $ohm = $color1 & $color2 * $color3 $kohm = $ohm / 1000 $mohm = $kohm / 1000 GUICtrlSetData($result_ohm,$ohm & " " & $tol & " Ohm") If $ohm > 1000 Then GUICtrlSetData($result_kohm,$kohm & " " & $tol & " KOhm") Else GUICtrlSetData($result_kohm,"") EndIf If $kohm > 1000 Then GUICtrlSetData($result_mohm,$mohm & " " & $tol & " MOhm") Else GUICtrlSetData($result_mohm,"") EndIf EndIf EndIf Sleep (10) WEnd Edited April 4, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Maxtreeme Posted April 4, 2007 Author Share Posted April 4, 2007 Here is another corrected version of your code:when you changed some colors there was artefacts due to not using GUICtrlSetData but GUICtrlCreateLabel repeatedlyand some other little optimizations.And another idea for improve: remove button Calculate and use GUIRegisterMsg to catch event for editchanged (I dn't know exactly what event)The reason i didn't use lots of commands relating to GUI, is because i'm not that familiar with GUI, still experimenting and learning them. But thanks for pointing out things, explaining, and giving advices They are very much appreciated Link to comment Share on other sites More sharing options...
Lemmens Peter Posted April 4, 2007 Share Posted April 4, 2007 Hi, Must say great idea ! But I'm sorry to disapoint you. There are some errors in your program 1.) Try using the following colors color1-color2-Color3 Red-Yellow-Green : 2400000 Ohm --> correct Red-Black-Green : 20 Ohm --> Wrong !!! (Should be 2000000 Ohm) Red-Red-Black : 22 Ohm --> correct Red-Red-Silver : 20.02 Ohm --> Wrong !!! (should be 0.22 Ohm) I resolved this problem. 2.) In school I learned to create userfriendly programs, so I try to avoid to use buttons when it can be avoided. Therefore I changed the program so the result is immediately shown the moment one of the comboboxes (One of the 4 colors) changes. (EventMode) 3.) Users can type in one of the comboboxes garbage-characters. Therefore I changed the program so the user can't type garbage into the comboboxes. Instead when the user types the first character of a existing color, this color is shown. Adapted code : see attachement Hope to be of help, Best regards, PeterResistor_Calculator.au3 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