sonicxtacy02 Posted July 26, 2007 Share Posted July 26, 2007 i cant seem to understand why _filelisttoarray is creating an array successfully in my script yet i cant access one of the arrays elements. The below script errors out with "Subscript used with non-array variable". However if i skip trying to define $trackfilename the script writes from the array as intended. Any help? if fileexists($folder&"*.mp3") or fileexists($folder&"*.wma") or FileExists($folder&"*.flac") Then if fileexists($folder&"album.m3u") then filedelete($folder&"album.m3u") $listarray=_FileListToArray($folder,"*.mp3") $trackfilename=$listarray[1] $trackfilesplit=stringsplit($trackfilename, "-") $artist=$trackfilesplit[1] _FileWriteFromArray($folder&"album.m3u", $listarray) Else $artist="Unknown" EndIf Link to comment Share on other sites More sharing options...
DW1 Posted July 26, 2007 Share Posted July 26, 2007 are you sure its not stored in $listarray[0] instead of $listarray[1] ??? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 26, 2007 Share Posted July 26, 2007 i cant seem to understand why _filelisttoarray is creating an array successfully in my script yet i cant access one of the arrays elements. The below script errors out with "Subscript used with non-array variable". However if i skip trying to define $trackfilename the script writes from the array as intended. Any help? Put in some error handling: if fileexists($folder&"*.mp3") or fileexists($folder&"*.wma") or FileExists($folder&"*.flac") Then if fileexists($folder&"album.m3u") then filedelete($folder&"album.m3u") $listarray=_FileListToArray($folder,"*.mp3") If @error or $listarray[0] = 0 Then MsgBox(16, "Error", "Error listing files: " & $folder & "*.mp3, @error = " & @error) Else $trackfilename=$listarray[1] $trackfilesplit=stringsplit($trackfilename, "-") $artist=$trackfilesplit[1] _FileWriteFromArray($folder&"album.m3u", $listarray) EndIf Else $artist="Unknown" EndIf That will at least give you some info on the error. 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...
PsaltyDS Posted July 26, 2007 Share Posted July 26, 2007 are you sure its not stored in $listarray[0] instead of $listarray[1] ??? The [0] element is always the count in the array returned from _FileListToArray(). However, if no matching files are found, [0] = 0, and there is no [1]. 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...
sonicxtacy02 Posted July 26, 2007 Author Share Posted July 26, 2007 The [0] element is always the count in the array returned from _FileListToArray(). However, if no matching files are found, [0] = 0, and there is no [1]. i found the issue with some suggested error checking.. the problem wasnt that the variable wasnt an array... it was in my loop the test condition failed which caused the array to not be created.. hence the reason for the subscript error. thanks for the assist guys 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