Firefoxy Posted December 13, 2007 Share Posted December 13, 2007 (edited) Hi. I'm making a program that multiplies 3x3 matricies and also, seperately, finds the determinant. I've only put the input boxes in for the multiplication, nothing else. I'm currently working on the determinant solver. This is my code:expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Hunter\Desktop\AutoIt\3x3.kxf $Form2 = GUICreate("3x3 Matrix Determinant Finder/Multiplier", 701, 376, 193, 145) $Input1 = GUICtrlCreateInput("1,1", 8, 64, 33, 24) $Input2 = GUICtrlCreateInput("1,2", 64, 64, 33, 24) $Input3 = GUICtrlCreateInput("1,3", 120, 64, 33, 24) $Input4 = GUICtrlCreateInput("2,1", 8, 104, 33, 24) $Input5 = GUICtrlCreateInput("2,2", 64, 104, 33, 24) $Input6 = GUICtrlCreateInput("2,3", 120, 104, 33, 24) $Input7 = GUICtrlCreateInput("3,1", 8, 144, 33, 24) $Input8 = GUICtrlCreateInput("3,2", 64, 144, 33, 24) $Input9 = GUICtrlCreateInput("3,3", 120, 144, 33, 24) $Label = GUICtrlCreateLabel("3x3 Multiplication", 144, 8, 104, 20) $Label1 = GUICtrlCreateLabel("Matrix A", 40, 32, 51, 20) $Input01 = GUICtrlCreateInput("1,1", 248, 64, 33, 24) $Label2 = GUICtrlCreateLabel("*", 192, 104, 16, 41) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $Input10 = GUICtrlCreateInput("2,1", 248, 104, 33, 24) $Input11 = GUICtrlCreateInput("3,1", 248, 144, 33, 24) $Input12 = GUICtrlCreateInput("1,2", 304, 64, 33, 24) $Input13 = GUICtrlCreateInput("2,2", 304, 104, 33, 24) $Input14 = GUICtrlCreateInput("3,2", 304, 144, 33, 24) $Input15 = GUICtrlCreateInput("1,3", 360, 64, 33, 24) $Input16 = GUICtrlCreateInput("2,3", 360, 104, 33, 24) $Input17 = GUICtrlCreateInput("3,3", 360, 144, 33, 24) $Label3 = GUICtrlCreateLabel("-------------------------------------------------------------------------------------------------", 8, 184, 392, 20) $Label4 = GUICtrlCreateLabel("3x3 Determinant", 136, 216, 99, 20) $MultSolve = GUICtrlCreateButton("=", 424, 96, 41, 41, 0) $Label5 = GUICtrlCreateLabel("Matrix B", 280, 32, 51, 20) $det11 = GUICtrlCreateInput("1,1", 72, 248, 33, 24) $det12 = GUICtrlCreateInput("1,2", 128, 248, 33, 24) $det13 = GUICtrlCreateInput("1,3", 184, 248, 33, 24) $det21 = GUICtrlCreateInput("2,1", 72, 288, 33, 24) $det22 = GUICtrlCreateInput("2,2", 128, 288, 33, 24) $det23 = GUICtrlCreateInput("2,3", 184, 288, 33, 24) $det31 = GUICtrlCreateInput("3,1", 72, 328, 33, 24) $det32 = GUICtrlCreateInput("3,2", 128, 328, 33, 24) $det33 = GUICtrlCreateInput("3,3", 184, 328, 33, 24) $DetSolve = GUICtrlCreateButton("Solve", 248, 272, 49, 49, 0) $DetAnswer = GUICtrlCreateInput("", 336, 280, 33, 24) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;End Koda While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $DetSolve = 1 _GUICtrlEdit_AppendText($DetAnswer, ($det11*$det22*$det33+$det12*$det23*$det31+$det13*$det21*$det32)-($det11*$det23*$det32+$det12*$det21*$det33+$det13*$det22*$det31)) EndSwitch WEndThis part of the code is what I'm mainly worried about:Case $DetSolve = 1 _GUICtrlEdit_AppendText($DetAnswer, ($det11*$det22*$det33+$det12*$det23*$det31+$det13*$det21*$det32)-($det11*$det23*$det32+$det12*$det21*$det33+$det13*$det22*$det31))How would I make it where it solved the equation and then put it into the input box 'DetAnswer'? Edited December 13, 2007 by Firefoxy ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
smashly Posted December 13, 2007 Share Posted December 13, 2007 Wow that's a step on from a basic calculator..lol You will need to actually use GUICtrlRead() to get the value of the input box.. I notice your input's for the matrix are comma delimited.. I'm clueless when it come to matricies I don't think you can do a simple 1,2 * 1,3 = ? You can do 1.2 * 1.3 = 1.56 For example if your inputs weren't comma delimited you could use GUICtrlSetData($DetAnswer, execute(GuiCtrlRead($det11) * GuiCtrlRead($det22))) But since your inputs are comma delimited it won't equate. Cheers Link to comment Share on other sites More sharing options...
therks Posted December 13, 2007 Share Posted December 13, 2007 Any particular reason you used Execute() smashly? My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
smashly Posted December 13, 2007 Share Posted December 13, 2007 Not really , just being dopey as usual Link to comment Share on other sites More sharing options...
Firefoxy Posted December 13, 2007 Author Share Posted December 13, 2007 Wow that's a step on from a basic calculator..lolYou will need to actually use GUICtrlRead() to get the value of the input box..I notice your input's for the matrix are comma delimited..I'm clueless when it come to matriciesI don't think you can do a simple 1,2 * 1,3 = ?You can do 1.2 * 1.3 = 1.56For example if your inputs weren't comma delimited you could use GUICtrlSetData($DetAnswer, execute(GuiCtrlRead($det11) * GuiCtrlRead($det22)))But since your inputs are comma delimited it won't equate.CheersThere are no commas in the actual equation. The text that is in the box only shows the coordinates of what number should go in there. 1,2 just means put the number that's in Row 1, Column 2 in that space.This is an example of what is would do if it actually worked and used the formula to solve: ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
smashly Posted December 14, 2007 Share Posted December 14, 2007 (edited) That's good to see What aare you using the matrices for may I ask? I was trying to get to grips with using matrices in transforms for GDIPlus but after a short read I realized I was finding it to hard to understand. Edit: PS when you changed the pic in your first post you maybe should of changed the code in the post as well, so it'll match the pic Edited December 14, 2007 by smashly Link to comment Share on other sites More sharing options...
Firefoxy Posted December 14, 2007 Author Share Posted December 14, 2007 Edit: PS when you changed the pic in your first post you maybe should of changed the code in the post as well, so it'll match the pic The numbers that are in there now are numbers I've put in there myself. ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
Firefoxy Posted December 14, 2007 Author Share Posted December 14, 2007 I tried this but it said line 62 had an unknown function name. expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Hunter\Desktop\AutoIt\3x3.kxf $Form2 = GUICreate("3x3 Matrix Determinant Finder/Multiplier", 701, 376, 193, 145) $Input1 = GUICtrlCreateInput("1,1", 8, 64, 33, 24) $Input2 = GUICtrlCreateInput("1,2", 64, 64, 33, 24) $Input3 = GUICtrlCreateInput("1,3", 120, 64, 33, 24) $Input4 = GUICtrlCreateInput("2,1", 8, 104, 33, 24) $Input5 = GUICtrlCreateInput("2,2", 64, 104, 33, 24) $Input6 = GUICtrlCreateInput("2,3", 120, 104, 33, 24) $Input7 = GUICtrlCreateInput("3,1", 8, 144, 33, 24) $Input8 = GUICtrlCreateInput("3,2", 64, 144, 33, 24) $Input9 = GUICtrlCreateInput("3,3", 120, 144, 33, 24) $Label = GUICtrlCreateLabel("3x3 Multiplication", 144, 8, 104, 20) $Label1 = GUICtrlCreateLabel("Matrix A", 40, 32, 51, 20) $Input01 = GUICtrlCreateInput("1,1", 248, 64, 33, 24) $Label2 = GUICtrlCreateLabel("*", 192, 104, 16, 41) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $Input10 = GUICtrlCreateInput("2,1", 248, 104, 33, 24) $Input11 = GUICtrlCreateInput("3,1", 248, 144, 33, 24) $Input12 = GUICtrlCreateInput("1,2", 304, 64, 33, 24) $Input13 = GUICtrlCreateInput("2,2", 304, 104, 33, 24) $Input14 = GUICtrlCreateInput("3,2", 304, 144, 33, 24) $Input15 = GUICtrlCreateInput("1,3", 360, 64, 33, 24) $Input16 = GUICtrlCreateInput("2,3", 360, 104, 33, 24) $Input17 = GUICtrlCreateInput("3,3", 360, 144, 33, 24) $Label3 = GUICtrlCreateLabel("-------------------------------------------------------------------------------------------------", 8, 184, 392, 20) $Label4 = GUICtrlCreateLabel("3x3 Determinant", 136, 216, 99, 20) $MultSolve = GUICtrlCreateButton("=", 424, 96, 41, 41, 0) $Label5 = GUICtrlCreateLabel("Matrix B", 280, 32, 51, 20) $det11 = GUICtrlCreateInput("1,1", 72, 248, 33, 24) $det12 = GUICtrlCreateInput("1,2", 128, 248, 33, 24) $det13 = GUICtrlCreateInput("1,3", 184, 248, 33, 24) $det21 = GUICtrlCreateInput("2,1", 72, 288, 33, 24) $det22 = GUICtrlCreateInput("2,2", 128, 288, 33, 24) $det23 = GUICtrlCreateInput("2,3", 184, 288, 33, 24) $det31 = GUICtrlCreateInput("3,1", 72, 328, 33, 24) $det32 = GUICtrlCreateInput("3,2", 128, 328, 33, 24) $det33 = GUICtrlCreateInput("3,3", 184, 328, 33, 24) $DetSolve = GUICtrlCreateButton("Solve", 248, 272, 49, 49, 0) $DetAnswer = GUICtrlCreateInput("", 336, 280, 33, 24) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;End Koda While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $DetSolve = 1 $11 = GUICtrlRead($det11) $12 = GUICtrlRead($det12) $13 = GUICtrlRead($det13) $21 = GUICtrlRead($det21) $22 = GUICtrlRead($det22) $23 = GUICtrlRead($det23) $31 = GUICtrlRead($det31) $32 = GUICtrlRead($det32) $33 = GUICtrlRead($det33) Sleep(500) _GUICtrlEdit_AppendText($DetAnswer, (($11*$22*$33)+($12*$23*$31)+($13*$21*$32))-(($11*$23*$32)+($12*$21*$33)+($13*$22*$31))) EndSwitch WEnd ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
smashly Posted December 14, 2007 Share Posted December 14, 2007 (edited) hi, as a guess you need to add #Include <GuiEdit.au3>oÝ÷ ÚÚ-ëh¦ò¢êìr¸©´êâË^iÛ¬y«¢+ÙU% ÑɱMÑÑ ÀÌØíѹÍÝÈ° ÀÌØìÄĨÀÌØìÈȨÀÌØìÌ̤¬ ÀÌØìÄȨÀÌØìĘ̀ÀÌØìÌĤ¬ ÀÌØìĄ̈ÀÌØìÈĨÀÌØìÌȤ¤´ ÀÌØìÄĨÀÌØìĘ̀ÀÌØìÌȤ¬ ÀÌØìÄȨÀÌØìÈĨÀÌØìÌ̤¬ ÀÌØìĄ̈ÀÌØìÈȨÀÌØìÌĤ¤ Edited December 14, 2007 by smashly Link to comment Share on other sites More sharing options...
Firefoxy Posted December 14, 2007 Author Share Posted December 14, 2007 It works now...with a slight problem. Instead of it starting when I press the 'SOLVE' button it actively calculates it. How would I fix this? ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
smashly Posted December 14, 2007 Share Posted December 14, 2007 Hi, change Case $DetSolve = 1Cheers Link to comment Share on other sites More sharing options...
Firefoxy Posted December 14, 2007 Author Share Posted December 14, 2007 Great. It works perfectly. Now that I know how to do this I can finish the whole thing. Thanks! ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
smashly Posted December 14, 2007 Share Posted December 14, 2007 (edited) Hi, after looking into 3x3 matrix structure a bit more I've wondered if you ever thought of creating your controls in an array similar to a matrix? I mean store your Control ID's in an Array eg: $CtrlMatrix[3][3] This way when you read the inputs you can quickly read the values into a matrix array with simple loops.expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> Global $cMatrix[3][3] $Gui = GUICreate("", 95, 110) _Matrix3x3($cMatrix, 5, 5) $Display = GUICtrlCreateButton("Display Array", 5, 85, 85, 20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Display Dim $m[3][3] ; Matrix Array that stores the values from Ctrl read. For $i = 0 To 2 For $j = 0 To 2 $m[$j][$i] = GUICtrlRead($cMatrix[$j][$i]) Next Next _ArrayDisplay($m, "Matrix Values") EndSwitch WEnd Func _Matrix3x3(ByRef $cArray, $iX, $iY) Local $nX = $iX, $nY = $iY For $i = 0 To 2 For $j = 0 To 2 $cArray[$j][$i] = GUICtrlCreateInput($j + 1 & "." & $i + 1 , $nX, $nY, 25, 20, $ES_CENTER) $nY += 25 Next $nX += 30 $nY = $iY Next EndFunc Cheers Edited December 14, 2007 by smashly Link to comment Share on other sites More sharing options...
Firefoxy Posted December 14, 2007 Author Share Posted December 14, 2007 Hi, after looking into 3x3 matrix structure a bit more I've wondered if you ever thought of creating your controls in an array similar to a matrix? I mean store your Control ID's in an Array eg: $CtrlMatrix[3][3] This way when you read the inputs you can quickly read the values into a matrix array with simple loops.expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> Global $cMatrix[3][3] $Gui = GUICreate("", 95, 110) _Matrix3x3($cMatrix, 5, 5) $Display = GUICtrlCreateButton("Display Array", 5, 85, 85, 20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Display Dim $m[3][3] ; Matrix Array that stores the values from Ctrl read. For $i = 0 To 2 For $j = 0 To 2 $m[$j][$i] = GUICtrlRead($cMatrix[$j][$i]) Next Next _ArrayDisplay($m, "Matrix Values") EndSwitch WEnd Func _Matrix3x3(ByRef $cArray, $iX, $iY) Local $nX = $iX, $nY = $iY For $i = 0 To 2 For $j = 0 To 2 $cArray[$j][$i] = GUICtrlCreateInput($j + 1 & "." & $i + 1 , $nX, $nY, 25, 20, $ES_CENTER) $nY += 25 Next $nX += 30 $nY = $iY Next EndFunc Cheers ......I'm sooooo confused. I don't understand any of that. xD ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf 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