I've looked into it once more and now got FILE-Input/Output in Small running! Since some people said they have trouble too, here a little tutorial, the SMALL code should be self explaining.
How to write into a file
First open the text file, the second param defines the modus it should be opened:
- "w" = write the file complete new, means replace what is inside
- "a" = only add at the file end
new file = file_open("small-scripts/file-example.txt","w");
Now write some lines into the new file "file" we have opened. ^n means the following stuff is written at a new line.
file_write(file,"This is line 1.^nLine 2 stands here.^n");
file_write(file,"Line 3 follows directly! :)^n");
Now lets close the file again (important!)
file_close(file);
To read from a file
Open the file for reading ("r" for read)
new file_r = file_open("small-scripts/file-example.txt","r");
Create a text buffer with 100 letters to put the read line into, the line content is only read untill the letter number is reached!
new line[100];
Now read the file as long as the file is not at the end.
while(!file_eof(file_r))
{
file_read(file_r, line);
// put the line content into the message log files
log_message(line);
}
Now close the file once more.
file_close(file_r);