[SOLVED] Can't get Create file() to work
Posted: Sun Sep 15, 2024 9:46 pm
If I cut the if CreateFile() section and paste it to the front of the file then it works, but just cannot get CreateFile() to work inside the procedure. Driving me nuts!!!!

You might notice I was also having issues with DeleteFile()
You might notice I was also having issues with DeleteFile()
Code: Select all
Procedure Ping()
url$="-n 1 test.rebex.net"
If InternetGetConnectedState_(0,0)=1 ; Only check further if modem is switched on.
p=RunProgram("ping.exe",url$,"",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
If p : While ProgramRunning(p) : o$+ReadProgramString(p) : Wend : CloseProgram(p) : EndIf
If o$<>"" And FindString(o$,"unreachable",1)=0 And FindString(o$,"could not find host",1)=0 : Status=1 : EndIf
EndIf
ProcedureReturn Status
EndProcedure
If Ping()
Debug "Live URL"
Else
MessageRequester("Ohh Pooh"," Cannot find internet." +Chr(10)+ "This FTP session will be aborted")
End
EndIf
#ALL = 3555
Global FTPassword$, Password$, FTPreturn$, HOME$
Global Dim FileList$(50)
Global Dim pick$(50)
HOME$ = "C:\TEMP\" ; set path to working directory
testfile$ = HOME$ + "test.dat"
FTPassword$ = "password"
Procedure FTPGetArchive()
If OpenFTP(0, "ftp.free.fr", "anonymous", "")
;If OpenFTP(0, "test.rebex.net", "demo", FTPassword$)
;SetFTPDirectory(0,"ARCHIVE")
If ExamineFTPDirectory(0)
While NextFTPDirectoryEntry(0)
check$ = FTPDirectoryEntryName(0)
If 1=1 ;LCase(Right(check$,9)) = "vital.arc"
s$ + check$ + " " + FTPDirectoryEntryDate(0) + Chr(13)
Debug check$
EndIf
Wend
EndIf
FinishFTPDirectory(0)
CloseFTP(0)
Else
Debug "Can't connect to ftp Server"
EndIf
FTPreturn$ = s$
EndProcedure
Procedure GetArchList()
;DeleteFile(testfile$,#PB_FileSystem_Force)
While FileSize(testfile$) > -1
DeleteFile(testfile$,#PB_FileSystem_Force)
Wend
FTPGetArchive()
Debug "Open the Damn file!!!"
If CreateFile(10,testfile$)
Debug "says success"
WriteStringN(10,FTPreturn$,#PB_Ascii)
CloseFile(10)
Else
Debug "FuuuQQ!!! FuuuQQ!!! FuuuQQ!!!"
EndIf
; Debug FTPreturn$
EndProcedure
;Debug testfile$
;Debug testfile$
;Debug testfile$
GetArchList()
If ReadFile(0,testfile$)
While Eof(0) = 0
n + 1
FileList$(n) = ReadString(0,#PB_Ascii)
If Len(FileList$(n)) > 10
;Debug Str(n) + " " + FileList$(n)
EndIf
Wend
CloseFile(0)
EndIf