; WriteTextAtomic Example ; ----------------------- ; Requires Extended mode. ; A message-of-the-day file for our game launcher motd$="Welcome to Dragon Keep!"+Chr(10)+"Double XP all weekend." ; WriteTextAtomic writes the exact UTF-8 bytes to a hidden sibling ; file, then atomically replaces the destination - readers see the ; old file or the new file, never a half-written mixture. If WriteTextAtomic("motd_example.txt",motd)=0 Then RuntimeError FilesystemError() Print "Wrote motd_example.txt ("+FileSize("motd_example.txt")+" bytes)" Print "No BOM and no newline conversion - the bytes are exact." Print "" ; Read the file back to show what landed on disk file=ReadFile("motd_example.txt") Print "File contents:" While Not Eof(file) Print " "+ReadLine(file) Wend CloseFile file ; Clean up the file this example created DeleteFile "motd_example.txt" Print "" Print "Press any key to close the example" WaitKey End