Aurthuric Posted October 20, 2015 Share Posted October 20, 2015 I have used AutoIT for a lot of text manipulation programs, but now I want to move into a more functional program. Here is the basic concept that I have in mind, perhaps someone could shed some light on it or point me in the right direction.I want to load a array with part data (Partkey, description, weight, cost, group key, labor) About 20K lines so I was going to dimension an array as followsDIM - $product [20000][6]Then load data from a CSV into that arrayI have to then create a quote based on items I select from the list. First I though of scrolling through the list and check marking the items I want, but that would be cumbersome with so many items. So I wanted to do like a list view where you enter the partkey and it populates the rest of the fields, you enter quantity and it calculates the total weight, total labor and total cost. Then go to the next line. I also want to be able to break the quote into sections so that each section can be subtotaled as well as the entire quote. This data would be stored in another array and have the ability to save the quote.I have been looking at listview samples and mouse position/mouse click detection scripts but nothing that seems to fit. So please, I need some help here. Is there away to do it??? Is there a better way then using an array?? Better way then listview??Any samples you have would be greatly appreciated. I am basically looking at a way to quote/invoice items I sell on ebay (That is why the weight is in there).Thanks in advance Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 20, 2015 Moderators Share Posted October 20, 2015 (edited) Hi, Aurthuric, welcome to the forum. With 20k lines, it really sounds like you need a SQLite database to hold your data. It is a bit more difficult, but will be much easier to manage and make edits to in the future. Take a look at this as a quick and dirty example:expandcollapse popup#include <MsgBoxConstants.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Local $aFinal[1][6] $aFinal[0][0] = "PartKey" $aFinal[0][1] = "Description" $aFinal[0][2] = "Weight" $aFinal[0][3] = "Cost" $aFinal[0][4] = "GroupKey" $aFinal[0][4] = "Labor" Local $aResult, $iRows, $iColumns, $iRval, $hDB, $myDBase = @ScriptDir & "\Parts.tmp" Local $sDLL = _SQLite_Startup("sqlite.dll", 1) If @error Then MsgBox($MB_OK, "", "Failed with error: " & @error) Exit(-1) EndIf $hDB = _dbOpen($myDBase) $myTable = _tableCreate($hDB) _AddValues("001", "Part Number 1", "5 lbs", "$299.95", "42", "1 hour") _AddValues("002", "Part Number 2", "15 lbs", "$399.95", "43", "1 hour") _AddValues("003", "Part Number 3", "25 lbs", "$599.95", "44", "1 hour") _AddValues("004", "Part Number 4", "50 lbs", "$1199.95", "45", "1 hour") $iRval = _SQLite_GetTable2d(-1, "SELECT * FROM Parts;", $aResult, $iRows, $iColumns) If $iRval = $SQLITE_OK Then For $i = 1 To UBound($aResult) - 1 _ArrayAdd($aFinal, $aResult[$i][0] & "|" & $aResult[$i][1] & "|" & $aResult[$i][2] & "|" & $aResult[$i][3] & "|" & $aResult[$i][4]) Next EndIf _ArrayDisplay($aFinal, "Values to be added to database") ;Just to show you what is being written, can comment out. _SQLite_Close() _SQLite_Shutdown() Func _dbOpen($myDBase) _SQLite_Open($myDBase) If @error Then Return -1 Else Return 0 EndIf EndFunc Func _tableCreate($hDB) If $SQLITE_OK <> _SQLite_Exec($hDB, "CREATE TABLE Parts ('PartKey', 'Description', 'Weight', 'Cost', 'GroupKey', 'Labor');") Then MsgBox($MB_OK, "", "Error from TableCreate Function: " & _SQLite_ErrCode() & ". " & _SQLite_ErrMsg()) Exit (-1) Else Return 0 EndIf EndFunc Func _AddValues($sPartKey, $sDesc, $sWeight, $sCost, $sGroupKey, $sLabor) If $SQLITE_OK <> _SQLite_Exec($hDB, "INSERT INTO Parts VALUES ('" & $sPartKey & "','" & $sDesc & "', '" & $sWeight & "', '" & $sCost & "', '" & $sGroupKey & "', '" & $sLabor & "');") Then MsgBox($MB_OK, "", "Error from AddValues Function: " & _SQLite_ErrCode() & ". " & _SQLite_ErrMsg()) Exit(-1) Else Return 0 EndIf EndFuncYou can then build your gui around the database info. Please check out the SQLite functions in the help file, and be sure to ask on anything you would like clarification on. Edited October 20, 2015 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
kylomas Posted October 21, 2015 Share Posted October 21, 2015 What are "partkey"s and "groupkeys" and how are they related to parts?kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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