L3DT users' wiki
Large 3D terrain generator

 

Scripts > fwrite test

Description An example script to demonstrate how to use the fopen, fwrite and fclose script functions.
Author Aaron
Created 2010/05/24
Requires L3DT v2.9 beta 2 or later.
Download fwrite test.zs

Script contents

//
// ask user for filename
//

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

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

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

//
// Open file
//

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

//
// Write text to file
//

fwrite fp s

//
// Close file
//

fclose fp

Comments

None.

 
scripts/fwrite_test.txt · Last modified: 2017/08/31 04:19 (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