CreateFile()

Syntax

Result = CreateFile(#File, FileName$)
Description
Create an empty file. If the file was existing, it opens it and replace it by a blank one ! Be careful.

If #PB_Any is used as '#File' parameter, the new file identifier will be returned as 'Result'.

If 'Result' is not 0, the file is effectively created, else the creation has failed. It must be always tested, as performing operations on a non created file will cause severe crashs.

If the #File was already used, the previous file is automatically closed.
  If CreateFile(0,"Text.txt")       ; we create a new text file...
    For a=1 To 10
      WriteStringN("Line "+Str(a))  ; we write 10 lines (each with 'end of line' character)
    Next
    For a=1 To 10
      WriteString("String"+Str(a))  ; and now we add 10 more strings on the same line (because there is no 'end of line' character)
    Next
    CloseFile(0)                    ; close the previously opened file and store the written data this way
  Else
    MessageRequester("Information","Can't create the file!")
  EndIf

Supported OS

All

<- CloseFile() - File Index - Eof() ->