# _FileListToArray, then error

## Recommended Posts

Hi everyone,

I've got a bit of code that gets the file name of a zip file in a particular directory and tried to unzip it.  _FileListToArray should create an array and define $aArray[1] as the first file returned by the search. But when I try to use$aArray[1] for anything, I get the error: "==> Array variable has incorrect number of subscripts or subscript dimension range exceeded."

Any thoughts?

If $osbit = "32" Then Local$aFileList = _FileListToArray($extract_dir, "*win32*") _ExtractZip($extract_dir & $aArray[1],$extract_dir)
ElseIf $osbit = "64" Then Local$aFileList = _FileListToArray($extract_dir, "*amd*") _ExtractZip($extract_dir & $aArray[1],$extract_dir)
EndIf

Thanks.

How about doing an _ArrayDisplay to see what value sits at $aArray[1]? Or posting your entire code, along with the _ExtractZIp function, so we can test? √-1 2^3 ∑ π, and it was delicious! #### Share this post ##### Link to post ##### Share on other sites _ArrayDisplay does seem to work fine. Here's the entire script (obviously file paths will mean nothing): #include <GuiEdit.au3> #include <GuiListBox.au3> #include <GuiComboBox.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <FileConstants.au3> #include <Array.au3> AutoItSetOption ( "SendKeyDelay" , 30 ) AutoItSetOption ( "TrayIconDebug", 1 ) Opt("WinTitleMatchMode", 2) ; GET BITNESS OF OS (CRUDE METHOD) If FileExists("C:\Program Files (x86)") Then Local$osbit = "64"
Else
Local $osbit = "32" EndIf Local$aArray[0], $aArray[1] Sleep(1000) ; COPY PATCH ZIP FILE FileCopy("\\chi413071\Ship\HSF11.1.2.4\11_1_2_4_000_3031\BuildPatch.zip", "C:\Oracle\Middleware\EPMSystem11R1\opatch\",$FC_OVERWRITE)

MsgBox(0, "", "")
Sleep(1000)
Local $opatch_dir = "C:\Oracle\Middleware\EPMSystem11R1\opatch\" Local$extract_dir = "C:\Oracle\Middleware\EPMSystem11R1\opatch\Extracted"
DirCreate($extract_dir) ; to extract to _ExtractZip($opatch_dir & "BuildPatch.zip", $extract_dir) If$osbit = "32" Then
Local $aFileList = _FileListToArray($extract_dir, "*win32*")
_ExtractZip($extract_dir &$aArray[1], $extract_dir) ElseIf$osbit = "64" Then
Local $aFileList = _FileListToArray($extract_dir, "*amd*")
_ExtractZip($extract_dir &$aArray[1], $extract_dir) EndIf Sleep(5000) Exit ; #FUNCTION# ;=============================================================================== ; ; Name...........: _ExtractZip ; Description ...: Extracts file/folder from ZIP compressed file ; Syntax.........: _ExtractZip($sZipFile, $sDestinationFolder) ; Parameters ....:$sZipFile - full path to the ZIP file to process
;                  $sDestinationFolder - folder to extract to. Will be created if it does not exsist exist. ; Return values .: Success - Returns 1 ; - Sets @error to 0 ; Failure - Returns 0 sets @error: ; |1 - Shell Object creation failure ; |2 - Destination folder is unavailable ; |3 - Structure within ZIP file is wrong ; |4 - Specified file/folder to extract not existing ; Author ........: trancexx, modifyed by corgano ; ;========================================================================================== Func _ExtractZip($sZipFile, $sDestinationFolder,$sFolderStructure = "")

Local $i Do$i += 1
$sTempZipFolder = @TempDir & "\Temporary Directory " &$i & " for " & StringRegExpReplace($sZipFile, ".*\\", "") Until Not FileExists($sTempZipFolder) ; this folder will be created during extraction

Local $oShell = ObjCreate("Shell.Application") If Not IsObj($oShell) Then
Return SetError(1, 0, 0) ; highly unlikely but could happen
EndIf

Local $oDestinationFolder =$oShell.NameSpace($sDestinationFolder) If Not IsObj($oDestinationFolder) Then
DirCreate($sDestinationFolder) ;~ Return SetError(2, 0, 0) ; unavailable destionation location EndIf Local$oOriginFolder = $oShell.NameSpace($sZipFile & "\" & $sFolderStructure) ; FolderStructure is overstatement because of the available depth If Not IsObj($oOriginFolder) Then
Return SetError(3, 0, 0) ; unavailable location
EndIf

Local $oOriginFile =$oOriginFolder.Items();get all items
If Not IsObj($oOriginFile) Then Return SetError(4, 0, 0) ; no such file in ZIP file EndIf ; copy content of origin to destination$oDestinationFolder.CopyHere($oOriginFile, 20) ; 20 means 4 and 16, replaces files if asked DirRemove($sTempZipFolder, 1) ; clean temp dir

Return 1 ; All OK!

EndFunc

##### Share on other sites

In your code, something is strange :

Local $aArray[0],$aArray[1]  => you are declaring an array two times, and you don't use it after, so you can delete this line

Local $aFileList = _FileListToArray($extract_dir, "*win32*")
_ExtractZip($extract_dir &$aArray[1], $extract_dir) =>$aArray[1] does not exists, because you have declared $aArray with just one element (row 0). You may want to use$aFileList, which is the result of _FileListToArray

Replace $aArray[1] by$aFileList[1], but I don't understand which file you want to extract. Instead of $aFileList[1], you should use the file name (if you know if, of course) #### Share this post ##### Link to post ##### Share on other sites Universalist, I was in the process of updating this thread when you posted. Yes, I need to use$aFileList since that is what is capturing the return of _FileListToArray!  I was just relying too much on examples, and this was my first time using an array.  Thank you.

The reason I need to do this is that the name of the zip file to extract will never be the same, as it contains a build number that increments with each build.

##### Share on other sites

OK.

Universalist is a "level" title. jguinch is my name

##### Share on other sites

Duh...my apologies.  And thanks again.

## 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 account

• ### Similar Content

• By sksbir
Hi
Trying this from autoit v3.3.14.5 and SCITE 3.19.102.1901.0 :
help file , page "Language Reference - Variables" , sample autoit script about maps:

Maps must be declared before use by defining their scope using the 'Global/Local/Static' keywords. Local $mControls[] So is my test script : only with this local declation. -check syntax is OK - running script : test.au3" (13) : ==> Variable subscript badly formatted.: Local$mControls[] Local $mControls[^ ERROR ->14:51:49 AutoIt3.exe ended.rc:1 any clue ? • By Blitzkid Hello, i want to search several directories for files with the largest numbers behind them (Like "video123") . They dont have a datatype. But there are also files with longer names and datatypes in these folders (Like "video778.mp4"). Is it possible to filter the _FileListToArray Syntax from to smth. like Here is my Code #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> #include <File.au3>$filedir = @ScriptDir & "\" _checkfile() Func _checkfile() ConsoleWrite("______________________" & @CRLF) Local $arr[3] = ["music", "picture", "video"] For$i = 0 To UBound($arr) - 1 Local$arrayfiles = _FileListToArray($filedir &$arr[$i],$arr[$i] & "*", 1) If @error = 1 Then ConsoleWrite($arr[$i] & "Error 1") EndIf If @error = 4 Then ConsoleWrite($arr[$i] & "Error 2") ;Exit EndIf$arrayfilter = _ArrayMax($arrayfiles, 0, 1) Global$stringfiles = StringReplace($arrayfilter,$arr[$i], "") ConsoleWrite($arrayfilter & @CRLF) Next EndFunc ;==>_checkfile
• By jmp
Script running good but error in line 7.
When i run this script :
#include <IE.au3> #include <Array.au3> $oIE = _IEAttach ("Shop")$oTable = _IETableGetCollection ($oIE, 1)$aTableData = _IETableWriteToArray ($oTable) For$inumber = 1 To UBound($aTableData) -1$table = $aTableData[4][$inumber] MsgBox(0, "", $table) Next I got Error: array variable has incorrect number of subscripts or subscript dimension range exceeded • Good morning guys, i hope that you're all well. guys, i have a problem and i hope that you can help me i've created an 3d array the array Contain a Categories info as folow$array[n][0][0] = Categorie name
$array[n][0][1] = Categorie file path$array[n][0][2] = Categorie contents number
$array[n][m][0] = link name$array[n][m][1] = link url
\$array[n][m][2] = link section name
in my tool i want to add an option to delete a Category
as you know the Categorie mean that must delete a region from the array
when i tried to use _arrayDelete
with the 2d array it work well
but here i couldn't find any way to do that, can any one help me please?
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...