Restored from previous forum. Originally posted by momo.
Hi!
How could i save some textdata from my program with SaveFileRequester???
Don't Look so stupid
I've got no Signature!!
How to save data with SaveFileRequester??
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
SaveFileRequester returns a String with the name of the file the user has choosen to save the file in. It does not save anything.
With this filename, you can use 'CreateFile()' or 'OpenFile()' to open a file, and then
use 'WriteStringN()', 'WriteString()' to write text to that file.
Use 'CloseFile()' to close the file after you've done writing.
Example:
SaveFileRequester returns a String with the name of the file the user has choosen to save the file in. It does not save anything.
With this filename, you can use 'CreateFile()' or 'OpenFile()' to open a file, and then
use 'WriteStringN()', 'WriteString()' to write text to that file.
Use 'CloseFile()' to close the file after you've done writing.
Example:
Code: Select all
Filename.s = SaveFileRequester("Save File...","C:\File.txt","Text Files|*.txt|All Files|*.*", 1)
If FileName = "" ; this means the user pressed abort
MessageRequester("","No file specified!",0)
End
EndIf
If CreateFile(0, FileName) ; if it returns true, the file is opened correctly
WriteStringN("Line1") ; write some text
WriteStringN("Line2") ; each on a new line
WriteString("This will be ") ; all on the same line
WriteString("on the same Line")
CloseFile(0) ; done writing
Else ; if CreateFile doesn't return true, the file could not be created
MessageRequester("","Cannot open file!",0)
End
EndIf
MessageRequester("","file written",0)
End
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm