TokeySmurf Posted June 23, 2007 Share Posted June 23, 2007 say I have $input = GUICtrlCreateInput ("Input", 5, 100) Now say I type in 1 + 1 = 3 I want the $input to be able identify the + symbol and then have the program calculate 1 + 1 to see if it actually = 3 if not give the new correct answer.. But I don't know how to get it to actually identify the "+" symbol then actually take an make it do 1 + 1. Please help Link to comment Share on other sites More sharing options...
xcal Posted June 23, 2007 Share Posted June 23, 2007 MsgBox(0, '', Execute('1+1')) How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
TokeySmurf Posted June 23, 2007 Author Share Posted June 23, 2007 MsgBox(0, '', Execute('1+1')) eh.. I know how to get the program to do 1+1 raw.. I mean taking what the user types in and identifying that it typed in a + symbol and then reads the other 2 numbers so it'd be like $word1 $symbol $word2 = .. $word1 would be like the first 1 the word2 would be the second number 1 and then $symbol would be like the addition symobl... Basically I'm trying to identify that the user entered a Addition symbol or any kind of math symbol to then try and solve the equation before storing the information. expandcollapse popup#include <GUIConstants.au3> #include <file.au3> GUICreate ("Brain", 300, 400) $learnButton = GUICtrlCreateButton ("Learn Knowledge", 100, 100) Global $learnInput = GUICtrlCreateInput ("Help me Learn", 5, 100) $talkButton = GUICtrlCreateButton ("Talk", 120, 300) Global $talkInput = guictrlcreateinput ("Test Your Knowledge",5,300,120,50) Guisetstate (@SW_SHOW) Global $fileName = "learn.txt" Global $file = fileopen (@scriptdir & "learn.txt",01) Global $user = "c-note" Global $math = "+" & "-" & "x" & "*" & "/" while 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit case $msg = $learnButton learn() Case $msg = $talkButton talk() EndSelect WEnd func learn() $learn = guictrlread ($learnInput) if $learn = "+" Then Return ;do math equation or math func.. Else _filewritelog ($fileName, $user & ": start entry" & @CRLF) FileWriteLine ($fileName, $learn & @CRLF) FileWriteLine ($fileName, $user & ": end entry" & @CRLF ) EndIf EndFunc func talk() $stringToSearch = guictrlread ($talkInput) $data = fileread($fileName) $dataMatch = stringinstr ($data,$stringToSearch) If $dataMatch = True Then msgbox (0,"Talk", $stringToSearch & " Found") Else msgbox(0,"no match",$stringToSearch & " Not Found") EndIf EndFunc Link to comment Share on other sites More sharing options...
xcal Posted June 23, 2007 Share Posted June 23, 2007 (edited) Just trying to give you ideas... #include <guiconstants.au3> GUICreate('Eh', 120, 106) $Ú[]HÕRPÝÜX]R[] ÌÎNÉÌÎNËLLL BÌÍØ]ÛHÕRPG&Ä7&VFT'WGFöâb33´6Æ7VÆFRb33²ÂÂCÂÂ#b¢b33c¶Æ&VÂÒuT7G&ÄÉÑ1° ÌäíͽµÑáÐÌäì°ÄÀ°ÜØ°ÄÀÀ°ÈÀ°ÀÌØíMM} 9QH¤()¥´ÀÌ;array[2][5] = [['+', '-', 'x', '*', '/ÌÎN×KÉÌÎNØY][ÛÌÎNË ÌÎNÜÝXXÝ[ÛÌÎNË ÌÎNÛ][XØ][ÛÌÎNËb33¶×VÇFÆ6Föâb33²Âb33¶Ff6öâb33µÕÐ ¤uT6WE7FFR ¥vÆR b3ÌØíµÍôU%Ñ5Í ¤(%MÝ¥Ñ ÀÌØíµÍ($% ÍÀÌØíU%}Y9Q} 1=M($$%á¥Ð Case $button $read = GUICtrlRead($input) If StringInÝ ÌÍÜXY ÌÎNÏIÌÎNÊH[BBBSÙÐÞ ÌÎNÉÌÎNË ÌÎNÖ[Ý[ÝÙ2b33²fײ7G&æuG&ÔÆVgBb33c·&VBÂ7G&ætå7G"b33c·&VBÂb33³Òb3ä줤µÀì1µÀì|($$$$$$ÌäíQ¡½ÉÉйÍÝÈ¥ÌÌäìµÀìáÕÑStringLeft($read, StringInStr($read, '=') - 1))) Else BBBSÙÐÞ ÌÎNÉÌÎNË ÌÎNÕH[ÝÙÈ ÌÎNÈ [È^XÝ]J ÌÍÜXY VæD` VæE7vF6 f÷"b33c¶ÒFò@ b7G&ætå7G"uT7G&Å&VBb3ÌØí¥¹ÁÕФ°ÀÌØíÉÉålÁulÀÌØí¥t¤Q¡¸U% ÑɱMÑÑ ÀÌØí±°°ÀÌØírray[1][$i]) Next WEnd Edited June 23, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 24, 2007 Share Posted June 24, 2007 Now say I type in 1 + 1 = 3 I want the $input to be able identify the + symbol and then have the program calculate 1 + 1 to see if it actually = 3 if not give the new correct answer.. But I don't know how to get it to actually identify the "+" symbol then actually take an make it do 1 + 1. The power of Execute(): While 1 $Input = InputBox("Formulaic", "Input math expression: ") If @error Then Exit If StringInStr($Input, "=") Then $avSplit = StringSplit($Input, "=") If $avSplit[0] = 2 Then $Result = Execute($avSplit[1]) If $Result = $avSplit[2] Then MsgBox(64, "Correct", "Yes, " & $avSplit[1] & " does in fact equal " & $avSplit[2] & ".") Else MsgBox(16, "Incorrect", "No, " & $avSplit[1] & " does not equal " & $avSplit[2] & @CRLF & _ "It equals " & $Result & ".") EndIf Else MsgBox(16, "Error", "Input a math expression, i.e. 2 + 3 = 5") ContinueLoop EndIf Else MsgBox(16, "Error", "Input a math expression, i.e. 2 + 3 = 5") ContinueLoop EndIf WEnd 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...
TokeySmurf Posted June 24, 2007 Author Share Posted June 24, 2007 Just trying to give you ideas... c2--><!--I2luY2x1ZGUgJmx0O2d1aWNvbnN0YW50cy5hdTMmZ3Q7CgpHVUlDcmÕ[ÒS^ÕPÖZ^ÍÓÐ^ZÒQ]ÓZÒÐÚVZQLXÒQÔULÔXSVÑÇV4c´5¤×¦³t¦×¤õG74DWtÄ4Ô7vtÕDtÄ4Ô6´´¦×t×¥uåcDsTCu#d¥¥'$9åi]ÁiU(Å!IÙ¥µ%é4Õ Hey thanks for the info. There is alot here so I'm going to search through it all and really try to understand exactly what's going on. Arrays are a bit more of my trouble area. though I understand them. Parralel arrays (think thats what they are called) throw me off.. where you have the [2][5] but I'm sure It'll make sense to me once I work through it some Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 24, 2007 Share Posted June 24, 2007 Hey thanks for the info. There is alot here so I'm going to search through it all and really try to understand exactly what's going on. Arrays are a bit more of my trouble area. though I understand them. Parralel arrays (think thats what they are called) throw me off.. where you have the [2][5] but I'm sure It'll make sense to me once I work through it some Nothing mysterious about 2D arrays. Just think of it like a spread sheet: [row][column]. So [2][5] is the third row, sixth column (remembering they are zero-based). 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...
Mast3rpyr0 Posted June 24, 2007 Share Posted June 24, 2007 once you see something with _ArrayDisplay() its really easy. try this out and i think youl get it more. #include <File.au3> #include <array.au3> Dim $szPath, �ÍÜÞ]K ÌÍÜÞ ÌÍÜÞ[YK ÌÍÜÞ^ÌÍÜÞ]H ][ÝÐÎ3#´&Æb3#´&Æ"b3#´&Æ2b3#´&ÆfÆRçFW7BgV÷C°¢b33cµF'&Ò}AÑ¡MÁ±¥Ð ÀÌØíÍéAÑ °ÀÌØíÍéÉ¥Ù°ÀÌØíÍé¥È°ÀÌØíÍé9µ°ÀÌØízExt) _ArrayDisplay($PathArray) Hope that clears things up with arrays for you. My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
xcal Posted June 24, 2007 Share Posted June 24, 2007 (edited) Hey thanks for the info. There is alot here so I'm going to search through it all and really try to understand exactly what's going on. Arrays are a bit more of my trouble area. though I understand them. Parralel arrays (think thats what they are called) throw me off.. where you have the [2][5] but I'm sure It'll make sense to me once I work through it some Something is wrong with autoit ... /autoit tags. I noticed that when I tried to edit, too. Anyway, to elaborate on what others are saying... and here's a way to look at it. $array[2][5] means $array[2 columns][5 rows]. ______| Array column 0 | Array column 1 Row 0 | + | addition Row 1 | - | subtraction Row 2 | x | multiplication Row 3 | * | multiplication Row 4 | / | division When accessing the array, it is zero based, which is why my loop is For 0 To 4. Edited June 24, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 24, 2007 Share Posted June 24, 2007 Something is wrong with autoit ... /autoit tags. I noticed that when I tried to edit, too. Anyway, to elaborate on what others are saying... and here's a way to look at it. $array[2][5] means $array[2 columns][5 rows]. ______| Array column 0 | Array column 1 Row 0 | + | addition Row 1 | - | subtraction Row 2 | x | multiplication Row 3 | * | multiplication Row 4 | / | division When accessing the array, it is zero based, which is why my loop is For 0 To 4. Well... almost. If you do an _ArrayDisplay() on your array, you'll see the convention is [row][column], not vice-versa: #include <array.au3> Dim $array1[2][5] = [["+", "-", "X", "*", "/"],["Addition", "Subtraction", "Multiplication", "Multiplication", "Division"]] Dim $array2[5][2] = [["+", "Addition"],["-", "Subtraction"],["X", "Multiplication"],["*", "Multiplication"],["/", "Division"]] _ArrayDisplay($array1, "Demo: $array1") _ArrayDisplay($array2, "Demo: $array2") 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...
xcal Posted June 24, 2007 Share Posted June 24, 2007 Oops How To Ask Questions The Smart Way 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