Sign in to follow this  
Followers 0
jerem488

non-Array variable

3 posts in this topic

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 :

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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 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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0