jerem488 Posted May 30, 2009 Posted May 30, 2009 Hello, I am doing a program which is on a USB key. The programm work when this usb key is on the computer, but when she isn't connected, I have this error : Subscript used with non-Array variable.: For $iIndex = 1 To $aFolders[0] For $iIndex = 1 To $aFolders^ ERROR The code of my program is : expandcollapse popup#include <File.au3> #include <Array.au3> #include <GUIConstants.au3> #NoTrayIcon Opt("TrayIconHide", 1) ; Masque l'icône Dim $Lecteur, $Serial, $Lettre $Var = DriveGetDrive("REMOVABLE") If Not @error Then For $i = 1 To $Var[0] If DriveStatus($var[$i] & "\") = "READY" Then If DriveGetSerial($Var[$i] & "\") = "1410682159" Then $Lettre = $Var[$i] $Lecteur &= DriveGetLabel($Var[$i] & "\") $Serial &= DriveGetSerial($Var[$i]) EndIf EndIf Next Else $Lecteur = "" $Serial = "" $Lettre = "" Exit EndIf Global $sRet Local $sPath = $Lettre Local $sFindFile = "rpm_435_V4.exe" $aRetArray = _FindPathName($sPath, $sFindFile) $ArrayToString = _ArrayToString($aRetArray,@CRLF,1) If FileExists($Lettre & "\Chemins.txt") Then FileDelete($Lettre & "\Chemins.txt") EndIf FileWriteLine($Lettre & "\Chemins.txt",$ArrayToString) $Line = FileReadLine($Lettre & "\Chemins.txt",1) If @error = -1 Then Exit $Prog = $Line $PathKey = StringRegExpReplace($Prog, "(^.*\\)(.*)", "\1") Run($Prog, "") $Attrib = FileGetAttrib($PathKey & "\ps.txt") If @error Then Exit Else If Not StringInStr($Attrib, "H") Then FileSetAttrib($Attrib, "+H") EndIf EndIf ; Searches all subfolders of $sPath for $sFindFile (* and ? wildcards accepted) ; Returns an array containing full path and name of all matches. ; Number of matches is in zero index of array Func _FindPathName($sPath, $sFindFile) Local $sSubFolderPath, $iIndex, $aFolders $search = FileFindFirstFile($sPath & "\" & $sFindFile) $aFolders = _FileListToArray($sPath, "*", 2) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop Else $sRet &= $sPath & "\" & $file & "|" EndIf WEnd FileClose($search) For $iIndex = 1 To $aFolders[0] $sSubFolderPath = $sPath & "\" & $aFolders[$iIndex] $aFoldersSubs = _FileListToArray($sSubFolderPath, "*", 2) If IsArray($aFoldersSubs) Then _FindPathName($sSubFolderPath, $sFindFile) Next Return StringSplit(StringTrimRight($sRet,1), "|") EndFunc ;==>_FindPathName Qui ose gagneWho Dares Win[left]CyberExploit[/left]
martin Posted May 30, 2009 Posted May 30, 2009 (edited) jerem488 said: Hello, I am doing a program which is on a USB key. The programm work when this usb key is on the computer, but when she isn't connected, I have this error : Subscript used with non-Array variable.: For $iIndex = 1 To $aFolders[0] For $iIndex = 1 To $aFolders^ ERROR Presumably @error is 1 or 4 Edited May 30, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
exodius Posted May 30, 2009 Posted May 30, 2009 Yeah, if $aFolders[0] is what's erroring out, then whatever was supposed to assign a value to it (the code that follows) must have failed. $aFolders = _FileListToArray($sPath, "*", 2)
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