MattX Posted January 3, 2012 Posted January 3, 2012 I have a loop which is checking for the number of files - [ this is just a chunk of code from the wider script ] - it will however fail with the 'Subscript used with non-Array Variable' error message if there are no files in the folder - can someone guide me as to where I should be putting @error so this does not happen ? While 1 Sleep(5000) $FileList = _FileListToArray($filefolder, $fileextension);only list files with given extension If $FileList[0] > 10 Then ;MsgBox(0, "number of files:", $FileList[0]) $Body = $FileList[0] & " .EML Files are stuck on the DMZ, please investigate ASAP" $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) Sleep(600000) ;10 mins If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf EndIf WEnd
Moderators Melba23 Posted January 3, 2012 Moderators Posted January 3, 2012 MattX,Check for @error or use IsArray immediately after the _FileListToArray line to check you got some files returned. M23 MattX 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
MattX Posted January 3, 2012 Author Posted January 3, 2012 Thanks - I'll give this a go this evening when back at home - I'll let you know when I get stuck.....
MattX Posted January 3, 2012 Author Posted January 3, 2012 I think I may have fixed this by adding:If @error=4 Then ContinueLoopAfter the _FileListToArrayLine.....
Moderators Melba23 Posted January 3, 2012 Moderators Posted January 3, 2012 MattX,I would not limit it to just that error - better to use If @error Then ContinueLoop to catch them all. M23 MattX 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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