fopen


opens a file following a similar syntaxe as C language.

following the same syntaxe as the C language.

fopen

fopen("fff mode")

Returns f=identifier (between 0 and 255) of the file fff reading mode.
mode="r": character reading mode
mode="rb": binary reading mode
mode="w": character writing mode (the file will be overwritten)
mode="wb": binary writing mode (the file will be overwritten)
mode=a item wille be added to the file.
Note:
If f <0: error.

Examples

CHARACTERS OVERWRITING MODE
Writing
f=fopen("tmp w");fwrite(f,"A BC");fclose(f);
Reading
f=fopen(\"tmp r\");$fread(f,1000);fclose(f);
       prints A BC

WRITING CHARACTERS IN APPEND MODE
Adding
f=fopen("tmp a");fwrite(f," DEF")";fclose(f);
Reading
f=fopen(\"tmp r\");$fread(f,1000);";fclose(f);
       prints A BC DEF

FLOATS OVERWRITING MODE
Writing
f=fopen("tmp wb");fwrite(f,[1,3])format("float");fclose(f);
Reading
f=fopen(\"tmp rb\");$fread(f,1000)format("float");fclose(f);
       prints 1.0,2.0,3.0

WRITING FLOATS IN APPEND MODE
Adding
f=fopen("tmp a");fwrite(f,[4,6])format("float");fclose(f);
Reading
f=fopen(\"tmp rb");$fread(f,1000)format("float");fclose(f);
       prints 1.0,2.0,3.0,4.0,5.0,6.0

FORMATED WRITE AND READ
f=fopen("tmp wb");fwrite(f,1,2,3)format("long");fclose(f);
       writes the three longs 1,2,3 in file tmp.
f=fopen("tmp rb");$fread(f,3)format("long");fclose(f);
       prints 1,2,3.

See also:

fread
edit fopen
fclose
getline
getword
fwrite
message