Clib.fwrite()
syntax: |
Clib.fwrite(srcVar, varDescription, filePointer) |
where: |
srcVar - variable to hold data to write to file.
varDescription - description of the data to write, that is, how and how much.
filePointer - pointer to file to use.
|
return: |
number - elements written on success, else 0 if a write error occurs.
|
description: |
This method writes the data in srcVar to the file indicated by filePointer and returns the number of elements written. 0 will be returned if a write error occurs. Use Clib.ferror() to get more information about the error. varDescription is a variable that describes the how and how much data is to be read. If srcVar is a buffer, it will be the length of the buffer. If srcVar is an object, varDescription must be an object descriptor. If srcVar is to hold a single datum then varDescription must be one of the values listed in the description for Clib.fread().
The ScriptEase version of Clib.fwrite() differs from the standard C version in that the standard C library is set up for writing arrays of numeric values or structures from consecutive bytes in memory. This is not necessarily the case in JavaScript.
|
see: |
|
example: |
// To write the 16_bit integer "i", // the 32_bit float "f", and // then 10_byte buffer "buf" into open file "fp", // use the following code.
if (!Clib.fwrite(i, SWORD16, fp) || !Clib.fwrite(f, FLOAT32, fp) || (10 != fwrite(buf, 10, fp))) { Clib.printf("Error writing to file.\n"); Clib.abort(); } |