L3DT users' wiki
Large 3D terrain generator

fwrite

Description

Write an object to a file.

Function prototype

bool fwrite <voidptr:hFile> <varref:Data>

Arguments

Name Type Comment
hFile voidptr A handle to a file created by fopen or fopen_s.
Data varref A reference to an initialised variable, the value of which is to be written to the file. The type of the variable determines the number of bytes to be written.

Return value

True if success, false otherwise.

Example

//
// ask user for filename
//

string FileName
set FileName <zs:file.SaveDlg "txt" NULL "Text files (*.txt)|*.txt|All files (*.*)|*.*|">
if <zs:iseq 0 <zs:strlen FileName>>
  return 0
endif

//
// Ask user for text to write to file
//

string s
if <zs:not <zs:EditUI s "Enter file text">>
  return 0
endif

//
// Open file
//

voidptr fp
assert <zs:fopen_s fp FileName "w"> "Cannot open file!"

//
// Write text to file using fwrite
//

fwrite fp s

//
// Close file
//

fclose fp
  

Comments

None.

See also

 
plugins/general/zeoscript/reference/functions/fwrite.txt · Last modified: 2017/08/31 05:44 (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