SRL Archive - Help and Support

Reading a .txt?


Sir Ducksworthy

2012-06-18 19:50:58

I'm really not sure how to use the file functions to read the text written inside on a .txt for Player data reading, storing the last location etc?

http://docs.villavu.com/simba/scriptref/files.html#readfilestring

Their is WriteINI and ReadINI but read INI writes as well?
 
ReadINI

function ReadINI(const Section, KeyName, FileName: string): string;

The following example writes to a specific Line in a Specified INI File then Reads that line and prints it’s findings.

program WriteINIReference;

Var Section, Keyname, NewString, FileName: String;

begin
Section := 'What subsection in the INI it is being Writen.';
KeyName := 'Space in the specified Subsection in which you string is writen.';
NewString := 'What your Writing into the INI file.';
FileName := 'The Name of the INI File you are writing too.';
WriteINI(Section, KeyName, NewString, ScriptPath + FileName);
Writeln(ReadINI(Section, KeyName, ScriptPath + FileName);
end.

Brandon

2012-06-18 19:53:52

ReadINI will read from a section and key only. The data returned is Read-Only Internal.

This means that Modifying the data outside directly will have create no changes on the data in the file. Inorder to change the data in a file, you can combine ReadINI with WriteINI or just use WriteINI alone.

String meh = ReadINI(……);

Meh can be modified and the data inside the INI file will stay the same.

WriteINI(…..); The data passed to write ini will not change but the data in the file definitely will.

These don't read from text files. They read from specialized text files called INI-Files usually called Initialization files or Data holders. Think of them like an XML file.

The functions to read/write text or binary file is ReadFile and WriteFile.

Sir Ducksworthy

2012-06-18 23:08:18

Ah ok, Ty man <3