norjms Posted December 9, 2009 Share Posted December 9, 2009 I'm back with another issue. I have a function that looks in a folder and makes a list of the folders. The only problem is if there are no folders the program crashes with this exit code "Error: Subscript used with non-Array variable" I know there is error code for _FileListToArray. What I can't figure out is how to exit the function if I get errors instead of proceeding and crashing out. expandcollapse popupFunc GetFolders($String_SourceDirectory) If $String_SourceDirectory <> "default" Then $ArrayFolders =_FileListToArray($String_SourceDirectory, "*", 2) #cs If @Error=4 Then MsgBox (0,"","No Files\Folders Found.") ?exit the function to avoid array errors? #CE For $Count = 1 To $ArrayFolders[0] If $String_TargetDirectory <> "default" Then If FileExists($String_TargetDirectory & $ArrayFolders[$Count] & ".m4v") OR FileExists($String_TargetDirectory & $ArrayFolders[$Count] & ".mkv") OR FileExists($String_TargetDirectory & $ArrayFolders[$Count] & ".mp4") OR FileExists($String_TargetDirectory & $ArrayFolders[$Count] & ".avi") OR FileExists($String_TargetDirectory & $ArrayFolders[$Count] & ".ogm") Then $String_Status = "Encoded" Else If FileExists($String_TargetDirectory & "Preview - " & $ArrayFolders[$Count] & ".m4v") OR FileExists($String_TargetDirectory & "Preview - " & $ArrayFolders[$Count] & ".mkv") OR FileExists($String_TargetDirectory & "Preview - " & $ArrayFolders[$Count] & ".mp4") OR FileExists($String_TargetDirectory & "Preview - " & $ArrayFolders[$Count] & ".avi") OR FileExists($String_TargetDirectory & "Preview - " & $ArrayFolders[$Count] & ".ogm") Then $String_Status = "Previewed" Else $String_Status = "Not Encoded" EndIf EndIf Else $String_Status = "" $String_CropValues = "" EndIf GUICtrlCreateListViewItem($ArrayFolders[$Count] & "|" & $SelectedTransType & "|" & $String_Status, $Control_FilmList) Next EndIf EndFunc Thanks for taking a look. Link to comment Share on other sites More sharing options...
spudw2k Posted December 9, 2009 Share Posted December 9, 2009 (edited) You could use IsArray before your For Loop. edit: I see you are checking fore @error, Why not simply return 0 there? Edited December 9, 2009 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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