Rex Posted January 16, 2010 Posted January 16, 2010 (edited) Hi. I have 30 inputs that i have to read from and react to. I started to write this. expandcollapse popupIf $Read_Tab_F1_Customer1 = "" And $len > "224" Then $RCustomer[0] = "" ; Customer 2 $RCustomer[1] = "" ; Customer 3 $RCustomer[2] = "" ; Customer 4 $RCustomer[3] = "" ; Customer 5 $RCustomer[4] = "<b>--- Total ---</b>" ; Customer 6 $RCollieCount[0] = "" ; CollieCount 2 $RCollieCount[1] = "" ; CollieCount 3 $RCollieCount[2] = "" ; CollieCount 4 $RCollieCount[3] = "" ; CollieCount 5 $RCollieCount[4] = "<u><b>" & $Read_Info_CollieCount & "</u></b>" ; CollieCount 6 $RCollieType[0] = "" ; Collie Type 2 $RCollieType[1] = "" ; Collie Type 3 $RCollieType[2] = "" ; Collie Type 4 $RCollieType[3] = "" ; Collie Type 5 $RCollieType[4] = "" ; Collie Type 6 $RWeight[0] = "" ; Collie Weight 2 $RWeight[1] = "" ; Collie Weight 3 $RWeight[2] = "" ; Collie Weight 4 $RWeight[3] = "" ; Collie Weight 5 $RWeight[4] = "<u><b>" & $Read_Info_CollieWeight & " Kg</u></b>" ; Collie Weight 6 $ROrdre[0] = $String2 ; Ordre Number 2 $ROrdre[1] = $String3 ; Ordre Number 3 $ROrdre[2] = $String4 ; Ordre Number 4 ElseIf $Read_Tab_F1_Customer1 = "" And $len > "168" Then $RCustomer[0] = "" ; Customer 2 $RCustomer[1] = "" ; Customer 3 $RCustomer[2] = "" ; Customer 4 $RCustomer[3] = "" ; Customer 5 $RCustomer[4] = "<b>--- Total ---</b>" ; Customer 6 $RCollieCount[0] = "" ; CollieCount 2 $RCollieCount[1] = "" ; CollieCount 3 $RCollieCount[2] = "" ; CollieCount 4 $RCollieCount[3] = "" ; CollieCount 4 $RCollieCount[4] = "<u><b>" & $Read_Info_CollieCount & "</u></b>" ; Collie Count 6 $RCollieType[0] = "" ; Collie Type 2 $RCollieType[1] = "" ; Collie Type 3 $RCollieType[2] = "" ; Collie Type 4 $RCollieType[3] = "" ; Collie Type 5 $RCollieType[4] = "" ; Collie Type 5 $RWeight[0] = "" ; Collie Weight 2 $RWeight[1] = "" ; Collie Weight 3 $RWeight[2] = "" ; Collie Weight 4 $RWeight[3] = "" ; Collie Weight 5 .... -> And it's keep on going like a Duracell Bunny The code is used in a large program i'm writing, and is a part of an freight letter generation where i have a html doc, that i do a Find and Replace in. the 30 inputs can be filed out with data about Customer, Collie Count, Type, weight and Our Order Numbers. Normally it wouldn't be a prob to writhe this but but but we could have up (over) 32 Order Numbers (224 Chars) and i neeed to get 'em all in the freigtL, but sins there's only room for 56 char's in the html i split it up and write it to the next line and next line.... but if the 2 input contains data i have to check if the 1 have more then 56 Chars and if so the move the data from input 2 x down and the same goes for 3,4,5.... My code for now only covers 1 input and all ready I'm on 225 lines of code So i hoped that one of U cool AutoIT guys/ladys could help me showing an easer way to do what i'm trying to do, if it's possible that is other wise a just have to put my fingers in a bucket of cold water ones a while while writing what must be > 2000 lines so they don't melt my keyboard . Cheers /Rex Edited August 22, 2010 by Rex
Bowmore Posted January 16, 2010 Posted January 16, 2010 I'm not sure exactly what you are trying to achieve, but this might help with splitting the output in chunks of 56 characters or less/ #include <array.au3> #include <string.au3> $sData = "adddsu2345dfhfn56679gjvf9jhfhfg95jhngfbjdieit9gghdo0t89t8vh87497hghghhe975ghsrgfhvhr85ghsrgu5r5hgsie587hgsie5ghgh5858585hg85hg8se5g858585ghh585oi59tr858gfh584985hg94785hg9487hfgheiduhgrlkdugfiygosigrhgoisurh9478957945hg98745hgo97hgo97g45o97gf0os98475gfos98475gfos75gfos975ghgfddssdffghf" $aTemp = StringRegExp($sData,"(.{0,56})",3) _ArrayDisplay($aTemp) "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
water Posted January 16, 2010 Posted January 16, 2010 (edited) If you have to repeat a task with different input data you usually write a function and call it with the variable data. You can define your GUI so that all input fields are in an array and you can call the function in a loop. Something like: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Input[3] = [2] ; Table with number of input fields+1 (here: 3), first element set to the number of input fields (here: 2) #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("Form1", 264, 113, 311, 186) GUICtrlCreateLabel("Input 1", 8, 11, 37, 17) GUICtrlCreateLabel("Input 2", 8, 42, 37, 17) $Input[1] = GUICtrlCreateInput("", 72, 8, 177, 21) $Input[2] = GUICtrlCreateInput("", 72, 40, 177, 21) $Button1 = GUICtrlCreateButton("Process Input", 8, 80, 89, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $Count = 1 To $Input[0] DisplayValue($Count, GUICtrlRead($Input[$Count])) Next EndSwitch WEnd Func DisplayValue($Number, $Value) ; The code to check an input field follows here MsgBox(0, "", "Value for Field " & $Number & " is '" & $Value & "'") EndFunc ;==>DisplayValue Edited January 16, 2010 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Â
Rex Posted January 16, 2010 Author Posted January 16, 2010 I'm not sure exactly what you are trying to achieve, but this might help with splitting the output in chunks of 56 characters or less/ #include <array.au3> #include <string.au3> $sData = "adddsu2345dfhfn56679gjvf9jhfhfg95jhngfbjdieit9gghdo0t89t8vh87497hghghhe975ghsrgfhvhr85ghsrgu5r5hgsie587hgsie5ghgh5858585hg85hg8se5g858585ghh585oi59tr858gfh584985hg94785hg9487hfgheiduhgrlkdugfiygosigrhgoisurh9478957945hg98745hgo97hgo97g45o97gf0os98475gfos98475gfos75gfos975ghgfddssdffghf" $aTemp = StringRegExp($sData,"(.{0,56})",3) _ArrayDisplay($aTemp) Hi Bowmore It's not the sting split there's my prob (not any more that is , that i posted in another thread ( String trim) I'm hope to get some help to not to write > 2000 lines of code to check my inputs. Cheers /Rex
Rex Posted January 16, 2010 Author Posted January 16, 2010 (edited) If you have to repeat a task with different input data you usually write a function and call it with the variable data. You can define your GUI so that all input fields are in an array and you can call the function in a loop. Something like: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Input[3] = [2] #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("Form1", 264, 113, 311, 186) GUICtrlCreateLabel("Input 1", 8, 11, 37, 17) GUICtrlCreateLabel("Input 2", 8, 42, 37, 17) $Input[1] = GUICtrlCreateInput("", 72, 8, 177, 21) $Input[2] = GUICtrlCreateInput("", 72, 40, 177, 21) $Button1 = GUICtrlCreateButton("Process Input", 8, 80, 89, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $Count = 1 To $Input[0] DisplayValue($Count, GUICtrlRead($Input[$Count])) Next EndSwitch WEnd Func DisplayValue($Number, $Value) MsgBox(0, "", "Value for Field " & $Number & " is '" & $Value & "'") EndFunc ;==>DisplayValue Hi Water I think that if i had to rewrite my gui it will take me even longer then to write the if /elseif thing, because i all ready have lots of code written to the gui as it is. and that array'er thing bugs me, i have newer learn to use it prober (and every time i write this in my thread some one says, you have been a member sins... and read the Wiki on arrays a.s.o, but hey i still don't get it - but in time ill learn). But thx for the suggestion Cheers /Rex Edited January 16, 2010 by Rex
jchd Posted January 16, 2010 Posted January 16, 2010 (edited) Indeed, you don't need that much code to do what [from what I understand] you need. For each customer you can have several orders. For each order, you can have several packets. For each packet you have a packet type and weight. Are you running some kind of e-shop business? What isn't very clear is what you need to do with his information. You seem to want to group it, but on which criterion and with which constraints BTW, leave the GUI design/coding alone for now. You probably need to clarify the processing you need first. When every aspect is crystal clear, then it will be time to apply a GUI on this. Edited January 16, 2010 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
water Posted January 16, 2010 Posted January 16, 2010 (edited) But wouldn't it be a good opportunity to start learning how arrays work?What are the names of your 30 input fields (just give me the name of the first 3).To change your script you only have todefine the Array in advancerename the input fields properlycall your data checking function in a loopI will be glad to help you understand arrays Edited January 16, 2010 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Â
Rex Posted January 16, 2010 Author Posted January 16, 2010 Indeed, you don't need that much code to do what [from what I understand] you need. For each customer you can have several orders. For each order, you can have several packets. For each packet you have a packet type and weight. Are you running some kind of e-shop business? What isn't very clear is what you need to do with his information. You seem to want to group it, but on which criterion and with which constraints BTW, leave the GUI design/coding alone for now. You probably need to clarify the processing you need first. When every aspect is crystal clear, then it will be time to apply a GUI on this. Hi jchd Nope I'm nut running a e-shop I'm writing a program for the company i work in. I'll try to clarify precise what i'm trying to do. -> well here goes. I'm a shipping manager and every day i use a webpage to tell the freight company how many car's we need and what type of goods we have, that webpage then generates a freight letter from the data i typed in eg. Customer, Number of colies, type, weight and our order numbers. 1. prob with the page is that i can only use it between 0500 and 0530 and then again some where around 0545. 2. prob is that i can't type in all our order numbers course the webpage only can handle apr. 20 chars. So my boos asked me to write a prog, that could handle up to 32 order numbers and be uses at any time (using ftp to uploade data to webserver). Now i have all in place execpt the generation of the freight letter, witch is a html file that i do a find and replace in but i have only room for 56 chars in field for order nr's so what i want to do is. 1 Check how many order nr's i have 2 Check if the next input is empty 3 calculate total numbers of collies and the total weight and write that one line below that last entry (leeving a blank line between the last entry and the total) If a have 32 order numbers and the 1 input is empty i have to replace the first line with collie, type, weight and the 1 56 chars of order numbers, then write 2 strings of order nr' to line 2, 3 to line 3 and 4 to line 4, then i creates a blank line (line 5), and then i do writes the total in line 6. But if input 1 is not empty and i still have 32 order nr's i have to check how many chars i have in the order nr' in input 1 and then replace like before but then i writes the data from input in line 5 and the total in x, course i input 1 have 8 order nr's i need 2 lines to put 'em on and then total will be written to line 8. and then i have to check for input 2 and 3 and Hope that i have clarified what I'm trying to do Cheers /Rex
Rex Posted January 16, 2010 Author Posted January 16, 2010 But wouldn't it be a good opportunity to start learning how arrays work?What are the names of your 30 input fields (just give me the name of the first 3).To change your script you only have todefine the Array in advancerename the input fields properlycall your data checking function in a loopI will be glad to help you understand arrays Hi WaterI now i now... and lots of U cool guy & lady 's would be happy to teach me arrays - and i would be happy to learn it, but 1'st thing 1'sti need to get this prog finished (have written on it for 3 months now and I'm of it now, just want it to be finished so i can get on with other things )Cheers/Rex
jchd Posted January 16, 2010 Posted January 16, 2010 1 Check how many order nr's i have2 Check if the next input is empty3 calculate total numbers of collies and the total weight and write that one line below that last entry (leeving a blank line between the last entry and the total)If a have 32 order numbers and the 1 input is empty i have to replace the first line with collie, type, weight and the 1 56 chars of order numbers, then write 2 strings of order nr' to line 2, 3 to line 3 and 4 to line 4, then i creates a blank line (line 5), and then i do writes the total in line 6.But if input 1 is not empty and i still have 32 order nr's i have to check how many chars i have in the order nr' in input 1 and then replace like before but then i writes the data from input in line 5 and the total in x, course i input 1 have 8 order nr's i need 2 lines to put 'em on and then total will be written to line 8.and then i have to check for input 2 and 3 and I don't honestly get exactly what you need and also what are the relationship between customer and order number, for instance.Let proceed otherwise.Tell me _precisely_ what's wrong in the presentation I make:You have a list of customers to ship goods to.For each customer, you have a number of collie to ship, each having a type and weight. These collie are the goods for a number of orders that each customer have placed with your company.Or are your order numbers in fact the collie reference with your shipper? Please clarify.You need to make a form (forget about the details)What I really don't get is what's the point of having several order numbers (up to 56 chars) on the line for _one_ collie?Please, correct what's wrong with what I understand.Then write what you expect as output, just in text.line 1 should contain:collie (what is that, a number, reference, ???) type weight order numbers (which ????)line n ---------- total weight for this pageother page ...Try to explain better the grouping you need and the relationship between information. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Rex Posted January 16, 2010 Author Posted January 16, 2010 (edited) I don't honestly get exactly what you need and also what are the relationship between customer and order number, for instance.Let proceed otherwise.Tell me _precisely_ what's wrong in the presentation I make:You have a list of customers to ship goods to.For each customer, you have a number of collie to ship, each having a type and weight. These collie are the goods for a number of orders that each customer have placed with your company.Or are your order numbers in fact the collie reference with your shipper? Please clarify.You need to make a form (forget about the details)What I really don't get is what's the point of having several order numbers (up to 56 chars) on the line for _one_ collie?Please, correct what's wrong with what I understand.Then write what you expect as output, just in text.line 1 should contain:collie (what is that, a number, reference, ???) type weight order numbers (which ????)line n ---------- total weight for this pageother page ...Try to explain better the grouping you need and the relationship between information.Hi JchdI will try to explain better 1 customer can have eg. 10 orders that contains 120 collies of 360 kg. on 10 pallets (1200 cl in total).written like this.Customer | number of Collies | Type | weight | Ordre Numbers| -> that would give some thing like thisCustomer | 10 | PLL | 3600 | 12346-123456-123456-12346-123456-123456-123456-123456Empty|Empyt|Empty|Empty| 123456-123456blank lineTOTAL | 10 |Empty| 3600 Kg|EmptyType can only be PLL or CLLNumber of Collie and weight can only NumbersOrder numbers can be anything, but normally numbers spitted by a "-"That part is quit simple Now the tricky part One of our customers have a storage where they store there goods for there customers.we produce orders for the customers customer, so i could have 3 different customers to the same address.and to keep track of witch customers goods we send to the storage address we write them on the same freight letter, that then could look like thisCustomer1 | 10 | PLL | 3600 | 12346-123456-123456-12346-123456-123456-123456-123456 | | | | 123456-123456Customer2 | 2 | PLL | 240 | 123456-123465Customer3 | 8 | CLL | 80 | 123465Blank lineTOTAL| 20 |Empty| 3920 Kg |EmptyBut if then customer 2 have > 8 and < 16 order numbers Customer3 and total would be dropped down a line. and if > 16 then...and that goes for all 30 inputsHope this helps.Cheers/Rexps. if any help i could compress my prog source and pm you a dl link. Edited January 16, 2010 by Rex
jchd Posted January 16, 2010 Posted January 16, 2010 (edited) Sorry for the delay but I had familly tasks keeping me off, like taxiing the kids (~160km total), meat and the like. Now that you expose more details, I see this as: You have wholesellers (at least one, but you could have many tomorow). Each of them (even if they exists only one today) has his own customers (for all except one currently, wholeseller number = customer number) Each wholeseller has up to n=10 orders (a day, I presume) which you group to ship them to. The shipment for each wholeseller corresponds to a number of physical packets (collie), having a type (CLL or PLL) and weight for each customer destination along with one or more order numbers. What you need to produce is a printing (html form is just a decoration for this) of the list of shipments grouped by wholeseller; then for each customer destination, there is a shipment type, a number of collies, a total weight for the destination shipment and the list (eventually broken down into several form lines --but this is to be handled later) of order numbers. The freight form you need to fill also needs a total number of collie and total weight per destination. Does this reflect your formulation of the given problem, or is there something that I miss? Edit: added the total weight per destination. Edited January 16, 2010 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Rex Posted January 16, 2010 Author Posted January 16, 2010 Sorry for the delay but I had familly tasks keeping me off, like taxiing the kids (~160km total), meat and the like.Now that you expose more details, I see this as:You have wholesellers (at least one, but you could have many tomorow).Each of them (even if they exists only one today) has his own customers (for all except one currently, wholeseller number = customer number)Each wholeseller has up to n=10 orders (a day, I presume) which you group to ship them to.The shipment for each wholeseller corresponds to a number of physical packets (collie), having a type (CLL or PLL) and weight for each customer destination along with one or more order numbers.What you need to produce is a printing (html form is just a decoration for this) of the list of shipments grouped by wholeseller; then for each customer destination, there is a shipment type, a number of collies, a total weight for the destination shipment and the list (eventually broken down into several form lines --but this is to be handled later) of order numbers. The freight form you need to fill also needs a total number of collie and total weight per destination.Does this reflect your formulation of the given problem, or is there something that I miss?Edit: added the total weight per destination.Hi jchdAll most there One customer can have up to xx orders (think that the record so far is 134 orders for one customer to send one day) but usually the big customers have 10-30 orders pr. dayWe only have one Customer that have a stock (wholesellers)--> We only fill out the "end" Customers name, Number of Cl, weight, type and order nr's on the freight letter, not there address.We only ship to one address pr. freight letterthe html doc is because i don't know how to generate a form with loge ect. in Autoit , and it's simple to edit if a new design is needed when i have generated the html file i convert it into pdf to ensure correct printout but other then that U got it right.Cheers/Rex
czardas Posted January 17, 2010 Posted January 17, 2010 (edited) This seems a little clearer now, after your discussion with jchd. Firstly, the problem is quite complicated, and usually solving such problems involves breaking the problem down into smaller chunks. If you can modify the information for one customer, then you can do it for them all. This can be done by creating a small array that deals with just one customer's details. After that, you can either transfer the information for that customer to a larger array, which holds all customer's details, or directly to the output file. So my suggestion is first to try and produce a working example for one customer and post it here. The method used can then be turned into a function. Each customer's details are then sent to that function, which returns a small modified array that you can handle more easily. Trying to do all this in one hit will just give you a headache. Edited January 17, 2010 by czardas operator64Â Â ArrayWorkshop
jchd Posted January 17, 2010 Posted January 17, 2010 One customer can have up to xx orders (think that the record so far is 134 orders for one customer to send one day) but usually the big customers have 10-30 orders pr. day We only have one Customer that have a stock (wholesellers) Since you have one, then all have one. That's why I said for all except one, wholeseller reference = customer reference You need that to automate the process in all cases. --> We only fill out the "end" Customers name, Number of Cl, weight, type and order nr's on the freight letter, not there address. We only ship to one address pr. freight letter Got that. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Rex Posted January 17, 2010 Author Posted January 17, 2010 Posting my code for the replace part (works for one customer9 It's huge expandcollapse popupFunc _WriteHTML() Sleep(1000) ProgressOn("Generere Fragtbrev", "Vent venligst") ; Check if Freight-Letter Dir exist FileCopy(@ScriptDir & "\String.Dll", $SaveIN & "\FragtBrev\" & $Read_Company_Strip & "_" & $NowDate & $NowTime & ".html") $filename = $SaveIN & "\FragtBrev\" & $Read_Company_Strip & "_" & $NowDate & $NowTime & ".html" Local $find[20], $replace[20] ; Creating an Array containing info to search for and the info to replace it with /-> Info Local $FOrdre[34], $ROrdre[34], $FCustomer[34], $RCustomer[34], $FCollieCount[34], $RCollieCount[34], $FCollieType[34], $RCollieType[34], $FWeight[34], $RWeight[34] ; Split/Next line after :-> 123456-123456-123456-123456-123456-123456-123456-123456- // 56 Char's and put it into seperat strings #cs -> Discounied got a new on from the forum $len = StringLen($String) If $len > "168" Then $String4 = StringRight(StringRight(StringRight(StringLeft($String, 224), 168),112),56) $String3 = StringRight(StringRight(StringLeft($String, 168), 112),56) $String2 = StringRight(StringLeft($String, 112), 56) $String1 = StringLeft($String, 56) ElseIf $len > "112" Then $String3 = StringRight(StringRight(StringLeft($String, 168), 112),56) $String2 = StringRight(StringLeft($String, 112), 56) $String1 = StringLeft($String, 56) ElseIf $len > "56" Then $TrimR = $len - 56 $String2 = StringRight($String, $TrimR) $String1 = StringLeft($String, 56) Else $String1 = $String EndIf #ce ; This one i got from the forum (http://www.autoitscript.com/forum/index.php?showtopic=108384). ; Thx jchd Local $String = $Read_Add_OrdreNr Local $len = StringLen($String) If $Read_Add_OrdreNr <> "" Then ; Some error check Local Const $limit = 56 Local $nbStr = Floor(($len + $limit - 1) / $limit) Local $aStrings[$nbStr] For $i = 0 To $nbStr - 1 $aStrings[$i] = StringLeft($String, $limit) $String = StringTrimLeft($String, $limit) Next EndIf ;_ArrayDisplay($aStrings) ; Show input ;$State_Tab_F1_Customer2 = GUICtrlGetState($Tab_F1_Customer_Input2) ;MsgBox(0, "State", $State_Tab_F1_Customer2) ; 144 is dissabled If $Read_Tab_F1_Customer1 = "" And $len > "224" Then $RCustomer[0] = "" ; Customer 2 $RCustomer[1] = "" ; Customer 3 $RCustomer[2] = "" ; Customer 4 $RCustomer[3] = "" ; Customer 5 $RCustomer[4] = "<b>--- Total ---</b>" ; Customer 6 $RCollieCount[0] = "" ; CollieCount 2 $RCollieCount[1] = "" ; CollieCount 3 $RCollieCount[2] = "" ; CollieCount 4 $RCollieCount[3] = "" ; CollieCount 5 $RCollieCount[4] = "<u><b>" & $Read_Info_CollieCount & "</u></b>" ; CollieCount 6 $RCollieType[0] = "" ; Collie Type 2 $RCollieType[1] = "" ; Collie Type 3 $RCollieType[2] = "" ; Collie Type 4 $RCollieType[3] = "" ; Collie Type 5 $RCollieType[4] = "" ; Collie Type 6 $RWeight[0] = "" ; Collie Weight 2 $RWeight[1] = "" ; Collie Weight 3 $RWeight[2] = "" ; Collie Weight 4 $RWeight[3] = "" ; Collie Weight 5 $RWeight[4] = "<u><b>" & $Read_Info_CollieWeight & " Kg</u></b>" ; Collie Weight 6 $ROrdre[0] = $aStrings[1] ; Ordre Number 2 $ROrdre[1] = $aStrings[2] ; Ordre Number 3 $ROrdre[2] = $aStrings[3] ; Ordre Number 4 ;_WriteFreight() ElseIf $Read_Tab_F1_Customer1 = "" And $len > "168" Then $RCustomer[0] = "" ; Customer 2 $RCustomer[1] = "" ; Customer 3 $RCustomer[2] = "" ; Customer 4 $RCustomer[3] = "" ; Customer 5 $RCustomer[4] = "<b>--- Total ---</b>" ; Customer 6 $RCollieCount[0] = "" ; CollieCount 2 $RCollieCount[1] = "" ; CollieCount 3 $RCollieCount[2] = "" ; CollieCount 4 $RCollieCount[3] = "" ; CollieCount 4 $RCollieCount[4] = "<u><b>" & $Read_Info_CollieCount & "</u></b>" ; Collie Count 6 $RCollieType[0] = "" ; Collie Type 2 $RCollieType[1] = "" ; Collie Type 3 $RCollieType[2] = "" ; Collie Type 4 $RCollieType[3] = "" ; Collie Type 5 $RCollieType[4] = "" ; Collie Type 5 $RWeight[0] = "" ; Collie Weight 2 $RWeight[1] = "" ; Collie Weight 3 $RWeight[2] = "" ; Collie Weight 4 $RWeight[3] = "" ; Collie Weight 5 $RWeight[4] = "<u><b>" & $Read_Info_CollieWeight & " Kg</u></b>" ; Collie Weight 6 $ROrdre[0] = $aStrings[1] ; Ordre Numbers 2 $ROrdre[1] = $aStrings[2] ; Ordre Numbers 3 $ROrdre[2] = $aStrings[3] ; Ordre Number 4 ElseIf $Read_Tab_F1_Customer1 = "" And $len > "112" Then $RCustomer[0] = "" ; Customer 2 $RCustomer[1] = "" ; Customer 3 $RCustomer[2] = "<b>--- Total ---</b>" ; Customer 4 $RCollieCount[0] = "" ; CollieCount 2 $RCollieCount[1] = "" ; CollieCount 3 $RCollieCount[2] = "<u><b>" & $Read_Info_CollieCount & "</u></b>" ; Collie Count 4 $RCollieType[0] = "" ; Collie Type 2 $RCollieType[1] = "" ; Collie Type 3 $RCollieType[2] = "" ; Collie Type 4 $RWeight[0] = "" ; Collie Weight 2 $RWeight[1] = "" ; Collie Weight 3 $RWeight[2] = "<u><b>" & $Read_Info_CollieWeight & " Kg</u></b>" ; Collie Weight 4 $ROrdre[0] = $aStrings[1] ; Ordre Numbers $ROrdre[1] = $aStrings[2] ; Ordre Numbers ElseIf $Read_Tab_F1_Customer1 = "" And $len > "56" Then $RCustomer[0] = "" ; Customer 2 $RCustomer[2] = "<b>--- Total ---</b>" ; Customer 3 $RCollieCount[0] = "" ; CollieCount 2 $RCollieCount[2] = "<u><b>" & $Read_Info_CollieCount & "</u></b>" ; Collie Count 3 $RCollieType[0] = "" ; Collie Type 2 $RCollieType[1] = "" ; Collie Type 3 $RWeight[1] = "" ; Collie Weight 2 $RWeight[2] = "<u><b>" & $Read_Info_CollieWeight & " Kg</u></b>" ; Collie Weight 3 $ROrdre[0] = $aStrings[1] ; Ordre Numbers ; /----><-----\ EndIf ; Read Sender info from ini file. $Account = IniRead($Settings, "INFO", "ACCOUNT", "") $Set = IniReadSection($Settings, $Account) $Sender_Account = _HexToString($Account) $Sender_CompanyName = _HexToString($Set[1][1]) $Sender_Address1 = _HexToString($set[2][1]) $Sender_Address2 = _HexToString($set[3][1]) $Sender_zip = _HexToString($set[4][1]) $Sender_City = _HexToString($set[5][1]) ; Search and Replace part ; Company and Sender /-> Search // $Find[] -> is an array contaioning 20 items ; Reciver $Find[0] = "COMPANY_NAME" $Find[1] = "ADDRESS" $Find[2] = "ADDRESS2" $Find[3] = "ZIP" $Find[4] = "CITY" ; Sender $Find[5] = "SENDER_NAME" $Find[6] = "SENDER_ADDRESS1" $Find[7] = "SENDER_ADDRESS2" $Find[8] = "SZIP" $Find[9] = "SENDER_CITY" $Find[10] = "DATE" $Find[11] = "ORDRENR" $Find[12] = "RECIVE_DATE" $Find[13] = "BEFORE_TIME" $Find[14] = "COMMENT" ; Goods Information $Find[15] = "CUSTOMER_1" $Find[16] = "CL_1" $Find[17] = "T_1" $Find[18] = "WEIGH_1" $Find[19] = "ORDRE_NUMBERS_1" ; Company and sender /-> Replace // $Replace[] -> is an array contaioning 20 items ; Reciver $replace[0] = $Read_Company $replace[1] = $Read_Address1 $replace[2] = $Read_Address2 $replace[3] = $Read_ZipCode $replace[4] = $Read_City ; Sender $replace[5] = $Sender_CompanyName ; Sender Name, DeHex'ed $replace[6] = $Sender_Address1 ; Sender Address 1 DeHex'ed $replace[7] = $Sender_Address2 ; Sender Address 2 DeHex'ed $replace[8] = $Sender_zip ; Sender Zip DeHex'ed $replace[9] = $Sender_City ; Sender City DeHex'ed $replace[10] = _NowDate() ; Replaces the DATE with today's date $replace[11] = $Read_OrdreNr $replace[12] = $Read_Info_Date_Picker $replace[13] = $Read_TimeDel $replace[14] = $Read_Comment ; Goods information if $Read_Info_Customer = "" Then $replace[15] = $Read_Company Else $replace[15] = $Read_Info_Customer EndIf $replace[16] = $Read_Info_CollieCount $replace[17] = $Read_Info_CollieType $replace[18] = $Read_Info_CollieWeight If $Read_Add_OrdreNr = "" Then $replace[19] = $Read_OrdreNr Else $replace[19] = $aStrings[0] EndIf ; Customer S&F $FCustomer[0] = "CUSTOMER_2" $FCustomer[1] = "CUSTOMER_3" $FCustomer[2] = "CUSTOMER_4" $FCustomer[3] = "CUSTOMER_5" $FCustomer[4] = "CUSTOMER_6" $FCustomer[5] = "CUSTOMER_7" $FCustomer[6] = "CUSTOMER_8" $FCustomer[7] = "CUSTOMER_9" $FCustomer[8] = "CUSTOMER_10" $FCustomer[9] = "CUSTOMER_11" $FCustomer[10] = "CUSTOMER_12" $FCustomer[11] = "CUSTOMER_13" $FCustomer[12] = "CUSTOMER_14" $FCustomer[13] = "CUSTOMER_15" $FCustomer[14] = "CUSTOMER_16" $FCustomer[15] = "CUSTOMER_17" $FCustomer[16] = "CUSTOMER_18" $FCustomer[17] = "CUSTOMER_19" $FCustomer[18] = "CUSTOMER_20" $FCustomer[19] = "CUSTOMER_21" $FCustomer[20] = "CUSTOMER_22" $FCustomer[21] = "CUSTOMER_23" $FCustomer[22] = "CUSTOMER_24" $FCustomer[23] = "CUSTOMER_25" $FCustomer[24] = "CUSTOMER_26" $FCustomer[25] = "CUSTOMER_27" $FCustomer[26] = "CUSTOMER_28" $FCustomer[27] = "CUSTOMER_29" $FCustomer[28] = "CUSTOMER_30" $FCustomer[29] = "CUSTOMER_31" $FCustomer[30] = "CUSTOMER_32" $FCustomer[31] = "CUSTOMER_33" $FCustomer[32] = "CUSTOMER_34" $FCustomer[33] = "CUSTOMER_35" ; Collie Count S&F $FCollieCount[0] = "CL_2" $FCollieCount[1] = "CL_3" $FCollieCount[2] = "CL_4" $FCollieCount[3] = "CL_5" $FCollieCount[4] = "CL_6" $FCollieCount[5] = "CL_7" $FCollieCount[6] = "CL_8" $FCollieCount[7] = "CL_9" $FCollieCount[8] = "CL_10" $FCollieCount[9] = "CL_11" $FCollieCount[10] = "CL_12" $FCollieCount[11] = "CL_13" $FCollieCount[12] = "CL_14" $FCollieCount[13] = "CL_15" $FCollieCount[14] = "CL_16" $FCollieCount[15] = "CL_17" $FCollieCount[16] = "CL_18" $FCollieCount[17] = "CL_19" $FCollieCount[18] = "CL_20" $FCollieCount[19] = "CL_21" $FCollieCount[20] = "CL_22" $FCollieCount[21] = "CL_23" $FCollieCount[22] = "CL_24" $FCollieCount[23] = "CL_25" $FCollieCount[24] = "CL_26" $FCollieCount[25] = "CL_27" $FCollieCount[26] = "CL_28" $FCollieCount[27] = "CL_29" $FCollieCount[28] = "CL_30" $FCollieCount[29] = "CL_31" $FCollieCount[30] = "CL_32" $FCollieCount[31] = "CL_33" $FCollieCount[32] = "CL_34" $FCollieCount[33] = "CL_35" ; Collie Type S&F $FCollieType[0] = "T_2" $FCollieType[1] = "T_3" $FCollieType[2] = "T_4" $FCollieType[3] = "T_5" $FCollieType[4] = "T_6" $FCollieType[5] = "T_7" $FCollieType[6] = "T_8" $FCollieType[7] = "T_9" $FCollieType[8] = "T_10" $FCollieType[9]= "T_11" $FCollieType[10] = "T_12" $FCollieType[11] = "T_13" $FCollieType[12] = "T_14" $FCollieType[13] = "T_15" $FCollieType[14] = "T_16" $FCollieType[15] = "T_17" $FCollieType[16] = "T_18" $FCollieType[17] = "T_19" $FCollieType[18] = "T_20" $FCollieType[19] = "T_21" $FCollieType[20] = "T_22" $FCollieType[21] = "T_23" $FCollieType[22] = "T_24" $FCollieType[23] = "T_25" $FCollieType[24] = "T_26" $FCollieType[25] = "T_27" $FCollieType[26] = "T_28" $FCollieType[27] = "T_29" $FCollieType[28] = "T_30" $FCollieType[29] = "T_31" $FCollieType[30] = "T_32" $FCollieType[31] = "T_33" $FCollieType[32] = "T_34" $FCollieType[33] = "T_35" ; Weight S&F $FWeight[0] = "WEIGH_2" $FWeight[1] = "WEIGH_3" $FWeight[2] = "WEIGH_4" $FWeight[3] = "WEIGH_5" $FWeight[4] = "WEIGH_6" $FWeight[5] = "WEIGH_7" $FWeight[6] = "WEIGH_8" $FWeight[7] = "WEIGH_9" $FWeight[8] = "WEIGH_10" $FWeight[9] = "WEIGH_11" $FWeight[10] = "WEIGH_12" $FWeight[11] = "WEIGH_13" $FWeight[12] = "WEIGH_14" $FWeight[13] = "WEIGH_15" $FWeight[14] = "WEIGH_16" $FWeight[15] = "WEIGH_17" $FWeight[16] = "WEIGH_18" $FWeight[17] = "WEIGH_19" $FWeight[18] = "WEIGH_20" $FWeight[19] = "WEIGH_21" $FWeight[20] = "WEIGH_22" $FWeight[21] = "WEIGH_23" $FWeight[22] = "WEIGH_24" $FWeight[23] = "WEIGH_25" $FWeight[24] = "WEIGH_26" $FWeight[25] = "WEIGH_27" $FWeight[26] = "WEIGH_28" $FWeight[27] = "WEIGH_29" $FWeight[28] = "WEIGH_30" $FWeight[29] = "WEIGH_31" $FWeight[30] = "WEIGH_32" $FWeight[31] = "WEIGH_33" $FWeight[32] = "WEIGH_34" $FWeight[33] = "WEIGH_35" ; Ordre Numbers S&F $FOrdre[0] = "ORDRE_NUMBERS_2" $FOrdre[1] = "ORDRE_NUMBERS_3" $FOrdre[2] = "ORDRE_NUMBERS_4" $FOrdre[3] = "ORDRE_NUMBERS_5" $FOrdre[4] = "ORDRE_NUMBERS_6" $FOrdre[5] = "ORDRE_NUMBERS_7" $FOrdre[6] = "ORDRE_NUMBERS_8" $FOrdre[7] = "ORDRE_NUMBERS_9" $FOrdre[8] = "ORDRE_NUMBERS_10" $FOrdre[9] = "ORDRE_NUMBERS_11" $FOrdre[10] = "ORDRE_NUMBERS_12" $FOrdre[11] = "ORDRE_NUMBERS_13" $FOrdre[12] = "ORDRE_NUMBERS_14" $FOrdre[13] = "ORDRE_NUMBERS_15" $FOrdre[14] = "ORDRE_NUMBERS_16" $FOrdre[15] = "ORDRE_NUMBERS_17" $FOrdre[16] = "ORDRE_NUMBERS_18" $FOrdre[17] = "ORDRE_NUMBERS_19" $FOrdre[18] = "ORDRE_NUMBERS_20" $FOrdre[19] = "ORDRE_NUMBERS_21" $FOrdre[20] = "ORDRE_NUMBERS_22" $FOrdre[21] = "ORDRE_NUMBERS_23" $FOrdre[22] = "ORDRE_NUMBERS_24" $FOrdre[23] = "ORDRE_NUMBERS_25" $FOrdre[24] = "ORDRE_NUMBERS_26" $FOrdre[25] = "ORDRE_NUMBERS_27" $FOrdre[26] = "ORDRE_NUMBERS_28" $FOrdre[27] = "ORDRE_NUMBERS_29" $FOrdre[28] = "ORDRE_NUMBERS_30" $FOrdre[29] = "ORDRE_NUMBERS_31" $FOrdre[30] = "ORDRE_NUMBERS_32" $FOrdre[31] = "ORDRE_NUMBERS_33" $FOrdre[32] = "ORDRE_NUMBERS_34" $FOrdre[33] = "ORDRE_NUMBERS_35" ;EndFunc ;Func _WriteFreight() ; Replace Part /-> Creating a loop to search and replace info in the html file $i = 0 Do ; Info Part ;MsgBox(0, "Find og udskift", "filen der skiftes i = " &$filename & " Find = " & $find[$i] & " Udskift med = " & $replace[$i], 2) $retval = _ReplaceStringInFile($filename,$find[$i],$replace[$i], 1, 0) $i = $i + 1 $Persent=($i/20)*100 ProgressSet($Persent, "Fragtbrevet genereres") Until $i = 20 $Read_TimeDel = "" ; /-> resetting Time Del. $Read_Comment = "" ; /-> resetting Comment. $i = 0 Do ; Info Customer part $retval = _ReplaceStringInFile($filename,$FCustomer[$i],$RCustomer[$i], 1, 0) $i = $i + 1 $Persent=($i/34)*100 ProgressSet($Persent, "Fragtbrevet genereres") Until $i = 34 $i = 0 Do ; Info CollieCount part $retval = _ReplaceStringInFile($filename,$FCollieCount[$i],$RCollieCount[$i], 1, 0) $i = $i + 1 $Persent=($i/34)*100 ProgressSet($Persent, "Fragtbrevet genereres") Until $i = 34 $i = 0 Do ; Info Collie Type part $retval = _ReplaceStringInFile($filename,$FCollieType[$i],$RCollieType[$i], 1, 0) $i = $i + 1 $Persent=($i/34)*100 ProgressSet($Persent, "Fragtbrevet genereres") Until $i = 34 $i = 0 Do ; Info Collie Weight part $retval = _ReplaceStringInFile($filename,$FWeight[$i],$RWeight[$i], 1, 0) $i = $i + 1 $Persent=($i/34)*100 ProgressSet($Persent, "Fragtbrevet genereres") Until $i = 34 $i = 0 Do ; Info Ordre Number part $retval = _ReplaceStringInFile($filename,$FOrdre[$i],$ROrdre[$i], 1, 0) $i = $i + 1 $Persent=($i/34)*100 ProgressSet($Persent, "Fragtbrevet genereres") Until $i = 34 ;~ RunWait($SaveIn & '\FragtBrev\2pdf.exe -s "' & $filename & '"', "", @SW_HIDE) ProgressSet(98, "Fragtbrevet genereres") RunWait(@ScriptDir & '\Lib\2pdf.exe "' & $filename & '"', "", @SW_HIDE) ProgressSet(100, "Fragtbrevet er blevet genereret") Sleep(1000) FileDelete($SaveIN & '\Fragtbrev\*.html') GUICtrlSetState($Button_Get_FreightLetter, $GUI_Show) ProgressOff() If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(266308,"Booking sendt","Bookingen er nu send." & @CRLF & @CRLF & "Print fragtbrev nu?") Select Case $iMsgBoxAnswer = 6 ;Yes ShellExecute(StringTrimRight($filename, 4) & "pdf") WinWaitActive("[CLASS:AcrobatSDIWindow]", "", 10) If WinActive("[CLASS:AcrobatSDIWindow]", "") Then Send("^p") EndIf Case $iMsgBoxAnswer = 7 ;No Return EndSelect ;GUISetState(@SW_MINIMIZE, $Booking) ; Freight-letter Search and Replace, Customer, Sender, And "Tab Info" EndFunc Ofcorse this is only the replace part but i hope that could help in some way. Cheers /Rex
czardas Posted January 17, 2010 Posted January 17, 2010 What is the difference between $FCustomer and $RCustomer? operator64Â Â ArrayWorkshop
jchd Posted January 17, 2010 Posted January 17, 2010 What is the difference between $FCustomer and $RCustomer?F = foundR = replace.Forget that, that a very bad idea anyway. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
jchd Posted January 17, 2010 Posted January 17, 2010 (edited) Of course this is only the replace part but i hope that could help in some way.OMG!PLEASE, don't take it bad, but your way is terribly wrong in that it makes things very complicated.First you need to get your input data (for one day) ready in a 2-D table, like this:One entry (row) per individual end_customer, each comprising (columns): o) the wholeseller ID o) the end_customer ID (identical to above, except for 1 genuine wholeseller) o) number of collie o) total weight for this customer o) collie type o) number of order (optional)In another 2-D table, for the same day:one entry (row) per customer, each grouping: o) end_customer o) order number o) order weight (?) o) order number of collie (?)Except the things that escape me rightnow, I think that when you have that ready, 90% of your task is done.The idea is to generate the html by concatenating its components as needed rather than replacing litteral strings in fixed format (html or whatever).Geez, organizing your data is a job for a database! It would bring us a long way to build that over the forum, but it definitely is the way to do it reliably and painlessly!My friend, I bet you'll learn to master 2-D arrays shortly and SQLite just after. After that, you'll see how easy that can be compared to :cough: another "solution". Again don't take it bad! Edited January 17, 2010 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
czardas Posted January 17, 2010 Posted January 17, 2010 (edited) Ok I can't solve all of the problems with this script in one go. You cannot easily do this without using a 2 dimensional array. Also you need to separate and create smaller functions. I have given an example of how this works. I run through each customer one at a time and call on each function to get the information I need. Once I have all the data held in one array, I can read any value from that array. I know that you will need to do some rethinking, but you will quickly get the hang of this approach, if you try. expandcollapse popup#include <Array.au3> Global $customerArray[34][5] ; Customer | number of Collies | Type | weight | Ordre Numbers For $i = 0 To 33 ; For each customer get the following information: _customerNumber() _collieCount() _collieType() _height() _order() Next Func _customerNumber() $count = 2 For $j = 0 To 33 ; Get details to modify the array $customerArray[$j][0] = "CUSTOMER_" & $count $count += 1 ; Keep tabs on customer number Next EndFunc Func _collieCount() $count = 2 For $j = 0 To 33 ; Get details to modify the array $customerArray[$j][1] = "CL_" & $count $count += 1 ; Keep tabs on customer number Next EndFunc Func _collieType() $count = 2 For $j = 0 To 33 ; Get details to modify the array $customerArray[$j][2] = "T_" & $count $count += 1 ; Keep tabs on customer number Next EndFunc Func _height() $count = 2 For $j = 0 To 33 ; Get details to modify the array $customerArray[$j][3] = "WEIGH_" & $count $count += 1 ; Keep tabs on customer number Next EndFunc Func _order() $count = 2 For $j = 0 To 33 ; Get details to modify the array $customerArray[$j][4] = "ORDRE_NUMBERS_" & $count $count += 1 ; Keep tabs on customer number Next EndFunc _ArrayDisplay($customerArray) The above code is wrong. See the next post for the correct version. Edited January 17, 2010 by czardas operator64Â Â ArrayWorkshop
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