meatsack Posted February 25, 2010 Posted February 25, 2010 How do I get my array conversion loop to process more date(ie 80 cells, or approximately 1 sheet of Excel data) Thanks in advanced for any help. It seems to only process 20 cells and if I feed it more it returns blank. I couldn't figure it out from the AutoIt Help file, nor from reading AutoIt book http://oreilly.com/catalog/9780596515126 . This is like web2mail. Anyone have any intro books that would help me understand these concepts. Would it matter if it was a programming book instead of a book about scripting? [autoit];################################## ; Include ;################################## #Include<file.au3> #include <Excel.au3> #include <Array.au3> #include <String.au3> ;################################## ; Variables ;################################## Dim $aArray2d Dim $Body Dim $zString $sFilePath1 = @ScriptDir & "\test.xls" ;This file should already exist $oExcel = _ExcelBookOpen($sFilePath1) $aArray2d = _ExcelReadSheetToArray($oExcel, 2, 2, 3, 3) Local $aArray1D = _Array2DTo1D($aArray2d) _ArrayDisplay($aArray1D) Func _Array2DTo1D($aTwo_d) If UBound($aTwo_d, 0) <> 2 Then MsgBox(0, "Error", "Array not 2 dimensional") Return EndIf Local $iRow = UBound($aTwo_d) Local $iCol = UBound($aTwo_d, 2) Local $aOne_d[$iRow * $iCol] For $i = 0 To $iRow - 1 For $j = 0 To $iCol - 1 $aOne_d[$i * $iCol + $j] = $aTwo_d[$i][$j] Next Next Return $aOne_d EndFunc ;==>_Array2DTo1D ; $zString = _ArrayToString($aArray1D) [autoit]
enaiman Posted February 26, 2010 Posted February 26, 2010 You are working with arrays for quite some times - do you still have problems understanding what arrays are?? ! THINK ! If you "believe" that _Array2DTo1D($aArray2d) doesn't work (which I really doubt) why don't you build your own function? It's nothing complicated: 2 For/Next loops to read the 2D array is all you need. You should have been able to put such a script together; I'll give you an example: #include <array.au3> Dim $Array1D[10000] Dim $Arr2d[3][2] = [["a00","a01"],["a10", "a11"],["a20", "a21"]] _ArrayDisplay($Arr2d) $1D_counter = 0 For $i=0 To UBound($Arr2d, 1)-1 For $j=0 To UBound($Arr2d, 2)-1 $Array1D[$1D_counter] = $Arr2d[$i][$j] $1D_counter +=1 Next Next ReDim $Array1D[$1D_counter] _ArrayDisplay($Array1D) Understand what I did and build your own function. Also - merged cells are a no-no. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
meatsack Posted February 26, 2010 Author Posted February 26, 2010 You are working with arrays for quite some times - do you still have problems understanding what arrays are?? ! THINK ! If you "believe" that _Array2DTo1D($aArray2d) doesn't work (which I really doubt) why don't you build your own function? It's nothing complicated: 2 For/Next loops to read the 2D array is all you need. You should have been able to put such a script together; I'll give you an example: #include <array.au3> Dim $Array1D[10000] Dim $Arr2d[3][2] = [["a00","a01"],["a10", "a11"],["a20", "a21"]] _ArrayDisplay($Arr2d) $1D_counter = 0 For $i=0 To UBound($Arr2d, 1)-1 For $j=0 To UBound($Arr2d, 2)-1 $Array1D[$1D_counter] = $Arr2d[$i][$j] $1D_counter +=1 Next Next ReDim $Array1D[$1D_counter] _ArrayDisplay($Array1D) Understand what I did and build your own function. Also - merged cells are a no-no. All right I will try and play around with that. What about my book recommendation? Something from here http://www.amazon.com/s/qid=1267152935/ref=sr_st?keywords=introduction+to+programming&rs=465600&page=1&bbn=465600&rh=n%3A283155%2Cn%3A!44258011%2Cn%3A!251254011%2Cn%3A465600%2Ck%3Aintroduction+to+programming&sort=salesrank My sons and I are going to start on NXT-G soon from National Instruments LabVIEW. Isn't their some industry standard text that many colleges use so people can gain some familiarity with the principles and basics beyond just learning by trial and error?
enaiman Posted February 26, 2010 Posted February 26, 2010 I can see you really want to learn something. From my experience - I have never been able to learn any programming from books; they looks nice, have examples but it's only books.You can learn to use AutoIt very easy and considering this forum, chances are that you'll get plenty of help.I think you've got the wrong example to start learning, Excel and data and array manipulations is not something recommended for a beginner.Try to do something else, try easier scripts just to get familiar with all this. Keep always open the AutoIt help (after 4 years, I still do) and keep an eye on Forums.Try: http://www.autoitscript.com/forum/index.php?showtopic=21048, do a search (I remember there were a couple more docs written).Use plenty of MessageBoxes, ConsoleWrite, ToolTips, ArrayDisplays - this are priceless for debug.Trial and error is something everybody does at a moment and it is something everybody learns from.My opinion: you learn better when you are writing scripts, testing them and debugging them.Good luck, SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
meatsack Posted February 26, 2010 Author Posted February 26, 2010 Keep always open the AutoIt help (after 4 years, I still do) and keep an eye on Forums.Use plenty of MessageBoxes, ConsoleWrite, ToolTips, ArrayDisplays - this are priceless for debug.Trial and error is something everybody does at a moment and it is something everybody learns fromGood luck,Ok, thanks that will give us a good start. Still I think it would be cool if programming had a textbook similiar to what Artificial Intelligence: A Modern Approach (3rd Edition) is for AI. Thanks for the tips.
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