Zombie1982 Posted August 26, 2008 Share Posted August 26, 2008 Good afternoon, I have recently gotten my head around arrays. Yet I am unable to actually spit the information out to anything besides MsgBox. Below is the script I'm using, any advise on spitting out this info would be awesome, thanks. $ExcelGrab = _ExcelReadArray($oExcel, 14, 4, 8, 0) MsgBox(48, "Huzzah!", $ExcelGrab[1]) MsgBox(48, "Huzzah!", $ExcelGrab[2]) MsgBox(48, "Huzzah!", $ExcelGrab[3]) MsgBox(48, "Huzzah!", $ExcelGrab[4]) Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 26, 2008 Share Posted August 26, 2008 Hi, _ArrayDisplay ??? Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
dbzfanatic Posted August 26, 2008 Share Posted August 26, 2008 You just need to use the same syntax you do for MsgBox. You can use _ArrayDisplay() or use the variable in any function you need. If you want to go through them all you can try: For $n = 0 To UBound($ExcelGrab) - 1 MsgBox(48,"Data",$ExcelGrab[$n]) Next Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Zombie1982 Posted August 26, 2008 Author Share Posted August 26, 2008 (edited) Hi,_ArrayDisplay ???MegaThanks for the suggestion Mega... the problem with _ArrayDisplay is that if I use the Copy Selected button, it will copy the row as well where I only want the colum data. I dont think I explained myself to well, I basically want to be able to paste each Col 0 into another application.EDIT: It may be as simple as _ArrayToClip, I'll let you know how it turns out! Edited August 26, 2008 by Zombie1982 Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 26, 2008 Share Posted August 26, 2008 Thanks for the suggestion Mega... the problem with _ArrayDisplay is that if I use the Copy Selected button, it will copy the row as well where I only want the colum data. I dont think I explained myself to well, I basically want to be able to paste each Col 0 into another application. EDIT: It may be as simple as _ArrayToClip, I'll let you know how it turns out! Columns implies a 2D array, so you just need to change the For/Next loop a little: Global $avArray[3][3] = [[1, 2, 3],[4, 5, 6],[7, 8, 9]] Global $sMsg = "" For $c = 0 To UBound($avArray, 2) - 1 $sMsg &= "Col. " & $c & " = " For $r = 0 To UBound($avArray) - 1 $sMsg &= $avArray[$r][$c] & ", " Next $sMsg = StringTrimRight($sMsg, 2) & @CRLF & @CRLF Next MsgBox(64, "Results", $sMsg) 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...
Zombie1982 Posted August 27, 2008 Author Share Posted August 27, 2008 Columns implies a 2D array, so you just need to change the For/Next loop a little: Global $avArray[3][3] = [[1, 2, 3],[4, 5, 6],[7, 8, 9]] Global $sMsg = "" For $c = 0 To UBound($avArray, 2) - 1 $sMsg &= "Col. " & $c & " = " For $r = 0 To UBound($avArray) - 1 $sMsg &= $avArray[$r][$c] & ", " Next $sMsg = StringTrimRight($sMsg, 2) & @CRLF & @CRLF Next MsgBox(64, "Results", $sMsg) Wow, thanks PsaltsyDS. Though I think I may be in a little over my head. At the moment I've got: Global $ExcelGrab[100][100]; Sets the ExcelGrab array ;Dim $oExcel Sleep(500); waits 1/2 a second WinActivate("Microsoft Excel"); Selects the excel window If WinActive("Microsoft Excel") = 0 Then; Checks to see if sheet is there or not (0 means NO) MsgBox(48, "Massive Error", "Sheet failed to open"); Shows the error Exit; Stops the script EndIf; Ends the if statment Send("^{HOME}"); sets the excel cell to A1 again $ExcelGrab = _ExcelReadSheetToArray($oExcel, 14, 4, 20, 9); row, colum, number of rows, number of colums to be read ;$ExcelGrab = _ExcelReadArray($oExcel, 15, 4, 8, 0); row, colum, number of cells, direction(0=right) _ArrayDisplay($ExcelGrab); Displays array for testing _ArrayToClip($ExcelGrab,1) And after that runs I seem to break array.au3 horribly... I get an AutoIt error of: Line 1130 (File "C:\Program Files\AutoIt3\Include\Array.au3"): $sResult &=$avArray[$i] & $sDelim $sResult &=$^ERROR Error: Array variable has inncorect number of subscripts or subscript dimenstions range exceeded. Any advice? Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 27, 2008 Share Posted August 27, 2008 Wow, thanks PsaltsyDS. Though I think I may be in a little over my head. At the moment I've got: Global $ExcelGrab[100][100]; Sets the ExcelGrab array ;Dim $oExcel Sleep(500); waits 1/2 a second WinActivate("Microsoft Excel"); Selects the excel window If WinActive("Microsoft Excel") = 0 Then; Checks to see if sheet is there or not (0 means NO) MsgBox(48, "Massive Error", "Sheet failed to open"); Shows the error Exit; Stops the script EndIf; Ends the if statment Send("^{HOME}"); sets the excel cell to A1 again $ExcelGrab = _ExcelReadSheetToArray($oExcel, 14, 4, 20, 9); row, colum, number of rows, number of colums to be read ;$ExcelGrab = _ExcelReadArray($oExcel, 15, 4, 8, 0); row, colum, number of cells, direction(0=right) _ArrayDisplay($ExcelGrab); Displays array for testing _ArrayToClip($ExcelGrab,1) And after that runs I seem to break array.au3 horribly... I get an AutoIt error of: Line 1130 (File "C:\Program Files\AutoIt3\Include\Array.au3"): $sResult &=$avArray[$i] & $sDelim $sResult &=$^ERROR Error: Array variable has inncorect number of subscripts or subscript dimenstions range exceeded. Any advice? Well, first simplify your life by making use of the _Excel* functions and avoiding the awkward Send() stuff: #include <Excel.au3> #include <Array.au3> Global $ExcelGrab, $sExcelFile = "C:\temp\Test.xls" $oExcel = _ExcelBookAttach($sExcelFile); If it's already open, _ExcelBookOpen() if not $ExcelGrab = _ExcelReadSheetToArray($oExcel, 14, 4, 20, 9) _ArrayDisplay($ExcelGrab); Displays array for testing Next, that looks like a really old bug in the Array.au3 UDF when displaying 2D arrays, and that bug was fixed a long time ago. I don't understand how you could have a new enough version of AutoIt to have the included Excel.au3 UDF (which was recently added) and still have an old broken Array.au3 UDF. Check the version and date in the header of your Array.au3 file. 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...
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