Inspired by this new feature introduced in PB5.40b3 I thought a similar new "intuitive" option that automatically reads/writes the default string format would be handy.Fred wrote:Code: Select all
- Added: #PB_Ascii, #PB_UTF8 and #PB_Unicode support to Create/Open/ReadFile() to set the default write/read mode
Example for ReadFile() (or OpenFile()):
Code: Select all
; Normal way:
If ReadFile(0, File)
Format = ReadStringFormat(0)
String = ReadString(0, Format)
EndIf
; More intuitive:
If ReadFile(0, File, #PB_File_AutoStringFormat)
String = ReadString(0)
EndIf
Code: Select all
; Old way:
Format = #PB_UTF8
If CreateFile(0, File)
WriteStringFormat(0, Format)
WriteStringN(0, String, Format)
EndIf
; New way (PB5.40b3):
Format = #PB_UTF8
If CreateFile(0, File, Format)
WriteStringFormat(0, Format)
WriteStringN(0, String)
EndIf
; Even better:
If CreateFile(0, File, #PB_UTF8 | #PB_File_AutoStringFormat)
WriteStringN(0, String)
EndIf
#PB_File_AutoStringFormat isn't official. It's my proposal for a new flag.