L3DT users' wiki
Large 3D terrain generator

fopen

Description

Open a file for reading or writing.

Function prototype

voidptr fopen <string:FileName> <string:Mode>

Arguments

Name Type Comment
FileName string A string containing the name of the file to be opened.
Mode string A string containing the file access mode. Please see the fopen C/C++ documentation for more information.

Return value

NULL if an error occurred, or a non-NULL handle to an opaque file object.

Example

voidptr fp // create a file handle
set fp <zs:fopen "C:\\test.txt" "w"> // open the file, and assign the value to 'fp'
assert fp "Cannot open file!" // exit if file can't be opened

string s
set string "Hello!"
fwrite fp s // write text to file

fclose fp // close file

… the output of which is written to the 'C:\test.txt' file:

Hello!

Comments

None.

See also

 
plugins/general/zeoscript/reference/functions/fopen.txt · Last modified: 2017/08/31 04:53 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki