Core Function FileSave
From Sputnik Wiki
(Difference between revisions)
m (1 revision) |
|||
(6 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
− | FileSave( <file>, <expression> ) | + | FileSave( <file>, <expression>, <useAscii> ) |
</pre> | </pre> | ||
Line 16: | Line 16: | ||
Text to save to the file. | Text to save to the file. | ||
+ | |||
+ | ==== useAscii ==== | ||
+ | |||
+ | Optional: Flag to decide if ASCII encoding should be used | ||
+ | |||
+ | True = Save using ASCII encoding | ||
+ | |||
+ | False = Save using UNICODE encoding | ||
+ | |||
+ | Default: false (All strings in Sputnik are Unicode to save them to file you must specifically request ASCII encoding) | ||
=== Return Value === | === Return Value === | ||
− | Success: Returns | + | Success: Returns true. |
− | Failure: Returns | + | Failure: Returns false if error occurs. |
=== Remarks === | === Remarks === | ||
Line 30: | Line 40: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | $TextSave = "Hello World!" | + | $TextSave = "Hello World!"; |
− | FileSave("Hello.txt", $TextSave) | + | FileSave("Hello.txt", $TextSave); |
− | $Text = FileLoad("Hello.txt") | + | $Text = FileLoad("Hello.txt"); |
− | println( "File text: " . $Text ) | + | println( "File text: " . $Text ); |
+ | </syntaxhighlight> | ||
+ | |||
+ | ASCII encoding | ||
+ | |||
+ | <syntaxhighlight lang="sputnik"> | ||
+ | FileSave("A.txt", "mooÓ,♠▬♣²qa↓¹", true); | ||
+ | // Check the file and note the special characters | ||
+ | // are now displayed as ? | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Latest revision as of 12:38, 14 June 2015
FileSave( <file>, <expression>, <useAscii> )
Contents |
Description
Save all text to a file.
Parameters
file
File name.
expression
Text to save to the file.
useAscii
Optional: Flag to decide if ASCII encoding should be used
True = Save using ASCII encoding
False = Save using UNICODE encoding
Default: false (All strings in Sputnik are Unicode to save them to file you must specifically request ASCII encoding)
Return Value
Success: Returns true.
Failure: Returns false if error occurs.
Remarks
You cannot use a FileHandle with this.
Example
$TextSave = "Hello World!"; FileSave("Hello.txt", $TextSave); $Text = FileLoad("Hello.txt"); println( "File text: " . $Text );
ASCII encoding
FileSave("A.txt", "mooÓ,♠▬♣²qa↓¹", true); // Check the file and note the special characters // are now displayed as ?