colobot-data/help/cbot/E/file.txt

19 lines
1019 B
Plaintext

\b;Type \c;file\n;
This type is used for accessing files in the files/ folder.
\c;
\s; file handle();
\n;
Use the syntax above for declaring a file handle. You must use () to create an instance of the \c;file\n; class. Without the () the handle would have the value \c;\l;null\u cbot\null;\n;.
Files can only be created and opened in the files/ folder which is located in the folder where Colobot has been installed. You cannot not create or open files elsewhere than in the files/ folder.
\b;For specialists
\c;file\n; is actually not a simple type but a class. \c;open\n;, \c;close\n;, \c;writeln\n; etc. are methods of the \c;file\n; class. This is the reason why we always write \c;handle.method()\n;¦:
\c;
\s; handle.open("test.txt", "w");
\s; handle.close();
\n;
\t;See also
\c;\l;open\u cbot\open;\n;, \c;\l;close\u cbot\close;\n;, \c;\l;readln\u cbot\readln;\n;, \c;\l;writeln\u cbot\writeln;\n; and \c;\l;eof\u cbot\eof;\n;.
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.