V3.0.0 - Read Write Null Terminated String
Posted: Wed Feb 08, 2012 8:08 pm
Hello everyone,
This a small lib I need to read 3DS and MD3 files. I have not put it to extreme test but it seem to work with or without Unicode mode.
Have fun !
Edit : Commands simplifications
Best Regards.
Guimauve
This a small lib I need to read 3DS and MD3 files. I have not put it to extreme test but it seem to work with or without Unicode mode.
Have fun !
Edit : Commands simplifications
Best Regards.
Guimauve
Code: Select all
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : Read Write Null Terminated String
; File Name : ReadNullTerminatedString.pb
; File version: 2.0.0
; Programmation : OK
; Programmed by : Guimauve
; Date : 08-02-2012
; Last Update : 08-02-2012
; PureBasic code : 4.61
; Plateform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Macro WriteNullTerminatedString(FileID, String)
WriteString(FileID, String, #PB_Ascii)
WriteAsciiCharacter(FileID, 0)
EndMacro
Macro ReadNullTerminatedString(FileID)
ReadString(FileID, #PB_Ascii)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< !!! WARNING - YOU ARE NOW IN A TESTING ZONE - WARNING !!! <<<<<
; <<<<< !!! WARNING - THIS CODE SHOULD BE COMMENTED - WARNING !!! <<<<<
; <<<<< !!! WARNING - BEFORE THE FINAL COMPILATION. - WARNING !!! <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
NewList Texte.s()
AddElement(Texte())
Texte() = FormatDate("A=%yyyy, M= %mm, J=%dd - %hh:%ii:%ss", Date())
AddElement(Texte())
Texte() = "PureBasic 4.61 Beta 1"
AddElement(Texte())
Texte() = "FreeMat 4.0 (Similiaire à MatLab mais sans Simulink)"
AddElement(Texte())
Texte() = "PureBasic is the best programming language, period !"
AddElement(Texte())
Texte() = "Linux Mint 12 x64 + Gnome-Shell"
If CreateFile(0, "Test.bin")
ForEach Texte()
WriteNullTerminatedString(0, Texte())
Next
CloseFile(0)
EndIf
If ReadFile(1, "Test.bin")
While Eof(1) = 0
Debug ReadNullTerminatedString(1)
Wend
CloseFile(1)
DeleteFile("Test.bin")
EndIf
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<