Task

(Over)write a file so that it contains a string.



The reverse of Read entire file—for when you want to update or create a file which you would read in its entirety all at once.




 
EnableExplicit
 
Define fOutput$ = "output.txt" ; enter path of file to create or overwrite
Define str$ = "This string is to be written to the file"
 
If OpenConsole()
  If CreateFile(0, fOutput$)
    WriteString(0, str$) 
    CloseFile(0)   
  Else
    PrintN("Error creating or opening output file")
  EndIf
  PrintN("Press any key to close the console")
  Repeat: Delay(10) : Until Inkey() <> ""
  CloseConsole()
EndIf
 