Rad Posted August 23, 2006 Share Posted August 23, 2006 (edited) Yeah... Im not really sure what to do and this is really buggin me because its just a calculator... It looks like this: [C][/][*][-] [7][8][9][+] [4][5][6][+] [1][2][3][E] [ 0 ][. ][E] Theres a little colum to the right that lists previous equations too You type some stuff, add it, hit enter and it puts the string just fine: 126+32 But how do you solve that as a string? I can manage sepering each equation, but I dont get how to solve the string... theres gotta be a function that does it, but I dont really know what to search for. I doubt theres a StringSolveEquation($sEquation) function...calculator.bmp Edited August 23, 2006 by Rad Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 23, 2006 Share Posted August 23, 2006 Yeah... Im not really sure what to do and this is really buggin me because its just a calculator... It looks like this: [C][/][*][-] [7][8][9][+] [4][5][6][+] [1][2][3][E] [ 0 ][. ][E] Theres a little colum to the right that lists previous equations too You type some stuff, add it, hit enter and it puts the string just fine: 126+32 But how do you solve that as a string? I can manage sepering each equation, but I dont get how to solve the string... theres gotta be a function that does it, but I dont really know what to search for. I doubt theres a StringSolveEquation($sEquation) function... I'm not on a Windows box, so can't verify at the moment, but I don't think AutoIT is as picky as some languages about variable types in arithmetic operations. You can use Number() to convert the string "123" to the number 123, but I think AutoIT might give the same result for both: $x = "123" + "456" $x = 123 + 456 There's some fancy college-boy computers 101 term for that like "non-srict variable typing" or some such, but I'm not a college boy... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Rad Posted August 23, 2006 Author Share Posted August 23, 2006 Number().... ... omg LOL ok thanks that will probrably work, wow I feel so stupid right now... I need sleep cept if i go to sleep ill sleep to long n thats not good so im staying up all night lol Link to comment Share on other sites More sharing options...
Marc Posted August 23, 2006 Share Posted August 23, 2006 (edited) or even easier: take a look at "Eval()" Edit: ooops. forget what I said Edited August 23, 2006 by Marc Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
Rad Posted August 23, 2006 Author Share Posted August 23, 2006 (edited) Eval() is wierd... I dont understand it at all... Dim $a_b = 12 $s = Eval("a" & "_" & "b") ; $s is set to 12 ?... It doesnt add anything either: $a = "5+12" $s = Eval("a") msgbox(0,"",$s) returns 5+12 As for the Number() thing, Im gonna have to redo the entire calculator lol... Omg... Look at number example: $w = Number(1+2+10);returns 13 $x = Number("3.14");returns 3.14 $y = Number("24/7");returns 24 $z = Number("tmp3");returns 0 How can you make a string into a regular ... text...? Edited August 23, 2006 by Rad Link to comment Share on other sites More sharing options...
SlimShady Posted August 23, 2006 Share Posted August 23, 2006 MsgBox(64, @ScriptName, '5*5 = ' & _Calc('5*5')) MsgBox(64, @ScriptName, '25+5 = ' & _Calc('25+5')) $expr = InputBox(@ScriptName, 'Enter a math expression...', '20*3') MsgBox(64, @ScriptName, $expr & ' = ' & _Calc($expr)) Func _Calc($str) Return Execute($str) EndFunc Link to comment Share on other sites More sharing options...
Rad Posted August 23, 2006 Author Share Posted August 23, 2006 Execute? I never would have thought that... SlimShady YOU ARE THE MAN! Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 23, 2006 Share Posted August 23, 2006 Execute? I never would have thought that...SlimShady YOU ARE THE MAN!Grampa said "Learn something new every day."Execute()Cool! I'm done for day!:-) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Rad Posted August 23, 2006 Author Share Posted August 23, 2006 works like a charm!! thanks again u saved me alot of tweaking slimGrampa said "Learn something new every day."haha its 6am I guess I shouldnt look forward to learning anything else today now huh 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