Floppy Posted March 31, 2009 Posted March 31, 2009 HEllo! In this script #include <FTP_Ex.au3> #Include <Array.au3> $ftp_open=_FTPOpen('myftp') $ftp_con=_FTPConnect($ftp_open,'[website hidden]','[username hidden]','[password hidden]') $get_dirs=_FTPFilesListToArray($ftp_con,1) _ArrayDelete($get_dirs,0) $get_dirs_string=_ArrayToString($get_dirs,@CRLF) MsgBox(0,'Directories',$get_dirs_string) For $i1=1 To UBound($get_dirs) DirCreate(@ScriptDir&'\server\'&$get_dirs[$i1]) Next _FTPClose($ftp_open) I get this error >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\......\New project.au3" C:\Users\........\New project.au3 (12) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: DirCreate(@ScriptDir&'\server\'&$get_dirs[$i1]) DirCreate(@ScriptDir&'\server\'&^ ERROR >Exit code: 1 Time: 3.616 Why?FTP_Ex.au3
Monamo Posted March 31, 2009 Posted March 31, 2009 HEllo! In this script #include <FTP_Ex.au3> #Include <Array.au3> $ftp_open=_FTPOpen('myftp') $ftp_con=_FTPConnect($ftp_open,'[website hidden]','[username hidden]','[password hidden]') $get_dirs=_FTPFilesListToArray($ftp_con,1) _ArrayDelete($get_dirs,0) $get_dirs_string=_ArrayToString($get_dirs,@CRLF) MsgBox(0,'Directories',$get_dirs_string) For $i1=1 To UBound($get_dirs) DirCreate(@ScriptDir&'\server\'&$get_dirs[$i1]) Next _FTPClose($ftp_open) I get this error >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\......\New project.au3" C:\Users\........\New project.au3 (12) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: DirCreate(@ScriptDir&'\server\'&$get_dirs[$i1]) DirCreate(@ScriptDir&'\server\'&^ ERROR >Exit code: 1 Time: 3.616 Why?Looks like it's just going for one pass too many in your For... loop. Try changing that line to: For $i1=1 To (UBound($get_dirs)-1) - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]
GEOSoft Posted March 31, 2009 Posted March 31, 2009 HEllo! In this script #include <FTP_Ex.au3> #Include <Array.au3> $ftp_open=_FTPOpen('myftp') $ftp_con=_FTPConnect($ftp_open,'[website hidden]','[username hidden]','[password hidden]') $get_dirs=_FTPFilesListToArray($ftp_con,1) _ArrayDelete($get_dirs,0) $get_dirs_string=_ArrayToString($get_dirs,@CRLF) MsgBox(0,'Directories',$get_dirs_string) For $i1=1 To UBound($get_dirs) DirCreate(@ScriptDir&'\server\'&$get_dirs[$i1]) Next _FTPClose($ftp_open) I get this error >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\......\New project.au3" C:\Users\........\New project.au3 (12) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: DirCreate(@ScriptDir&'\server\'&$get_dirs[$i1]) DirCreate(@ScriptDir&'\server\'&^ ERROR >Exit code: 1 Time: 3.616 Why?For $i1=1 To UBound($get_dirs) Should be For $i1=1 To UBound($get_dirs) -1 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
GEOSoft Posted March 31, 2009 Posted March 31, 2009 Yeah, it works, but why -1?Because UBound() contains the number of elements, not an actual element George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
SpookMeister Posted March 31, 2009 Posted March 31, 2009 (edited) The first element of an array is element 0. This means that if you have an array with 3 elements they will be: $array[0] $array[1] $array[2] Ubound will tell you the total size (number of elements) of the array, but if you want the last item in an array it will be 1 less than then return from Ubound. Edited March 31, 2009 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
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