I cant get my ftp program to work properly. After you define what directory you want ot use, it says "cannot set ftp directory", and it is frustrating.
rem start up the program
hide mouse
rem set screen color
ink rgb(0,150,0),rgb(0,0,0) : cls
rem a little title thing
logo_image=1
load image "logo.bmp",logo_image
paste image 1,250,100
wait 2500
rem connect to site
input "URL>";address$
input "USER>";username$
input "PASSWORD>";pass$
url$=address$ : user$=username$ : password$=pass$
print "Connecting to ";url
ftp connect url$,user$,password$
if get ftp failure()=1 then goto failure
print : sleep 100
rem scan main directory
gosub ftp_scan
rem input a directory
input "DIRECTORY>";dir$
dirname$=dir$
print "Entering FTP Directory...";dirname$
ftp set dir dirname$
if get ftp failure()=1 then goto failure
print : sleep 100
rem ask User
print "d : Download a file"
print "u : Upload a file"
input "Enter D or U to perform an FTP action>";a$
user$=lower$(a$) : cls
if user$="d"
rem scan new directory
gosub ftp_scan
rem download files
print "Downloading file in one go (please wait)...";filename$; : sync
if file exist(filename$)=1 then delete file filename$
ftp get file filename$,filename$
if get ftp failure()=1 then goto failure
print "...SUCCESS!"
print : sleep 100
rem now delete it and download another way
filesize=file size(filename$)
if file exist(filename$)=1 then delete file filename$
rem download with progress
print "Downloading with progress...";
if file exist(filename$)=1 then delete file filename$
ftp get file filename$,filename$,filesize
if get ftp failure()=1 then goto failure
while get ftp progress()<>-1 and get ftp status()=1
print get ftp progress();"...";
if spacekey()=1 then ftp terminate
ftp proceed
endwhile
print : print : sleep 100
endif
if user$="u"
rem upload (fails silently if FTP does not have write access)
localfile$="text.txt"
print "BE AWARE RUNTIME WARNING STILL ALLOWS CONTINUANCE - JUST HIT ESCAPE!"
print "Uploading...";localfile$
ftp put file localfile$
if get ftp failure()=1 then goto failure
print : sleep 100
endif
rem success
goto success
rem show error if user does not have write access
failure:
ln=1
dim line$(10)
error$=get ftp error$()
for n=1 to len(error$)
n$=mid$(error$,n)
if asc(n$)=13
print line$(ln)
inc ln : n=n+1
if ln=9 then exit
else
line$(ln)=line$(ln)+n$
endif
next n
undim line$(0)
print
rem sump here if ok
success:
rem disconnect
print "Disconnecting from ";url$
ftp disconnect
print : sleep 100
rem end program
print "Program End"
end
rem scan current ftp directory and print out contents
ftp_scan:
ftp find first
while get ftp file type()<>-1
print get ftp file name$();" (";
print get ftp file size();" bytes)"
if get ftp file type()=0 then filename$=get ftp file name$()
if get ftp file type()=1 then dirname$=get ftp file name$()
ftp find next
endwhile
print : sleep 100
return
If you can help, I would greatly appreciate it.
It does'nt matter what side of the road you drive on, you'll still crash...