Readline

BlitzPlus Forums/BlitzPlus Programming/Readline

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here's some code that might get it accross.

fileout=WriteFile("lol.txt");Creates or Recreates a file for writing
WriteLine(fileout,"Hello World!") ;Writes one line of text
WriteString(fileout,"ABCDEFGHIJKLM");Stores a standard string variable, the characters are ended with four bytes
WriteInt(fileout,131);Integer, the standard numeric variable. Max of 2147483647 Minimum of -2147483648
WriteShort(fileout,100);Two bytes, max of 65535
WriteByte(fileout,10);Single byte, max of 256
CloseFile(fileout);Moves the file from memmory to the hard drive

filein=ReadFile("lol.txt")
Print ReadLine(filein)
Print ReadString(filein)
Print ReadInt(filein)
Print ReadShort(filein)
Print ReadByte(filein)
CloseFile(filein)
WaitKey()

Just remember not to mix up the order that you read or write from/to the file. If you do, then the data will appear corrupted. Also, if you open a file for both reading and writing at once, without closing the file first, the file's data will be lost.