loadTextFile: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
No edit summary
(co)
 
Line 10: Line 10:
|returnInfo = the text fetched, as a string, which could be an empty string if the file is blank, or null if a failure occurred (e.g. if the file was not found, or the file can't be opened)
|returnInfo = the text fetched, as a string, which could be an empty string if the file is blank, or null if a failure occurred (e.g. if the file was not found, or the file can't be opened)
|returnFail1 = null n/a
|returnFail1 = null n/a
|example = <code>
let data = loadTextFile(filePath);
if(data === null)
console.log('Failed to load text file.');
else
console.log('File data: '+data);
</code>
}}
}}

Latest revision as of 18:49, 14 May 2023

Function Server and Client icon-iii.png icon-vc.png icon-sa.png icon-iv.png Online and Offline

Available since Server 1.2.1, Client 1.2.1

string loadTextFile(string filePath)

The loadTextFile function is used to fetch all text inside a file as a string, or null if there was a failure.

Parameters

1) string filePath The path to the file.

Return

string The text fetched, as a string, which could be an empty string if the file is blank, or null if a failure occurred (e.g. if the file was not found, or the file can't be opened).

Notes

There aren't any notes for this function.

Examples

Example 1 - :

let data = loadTextFile(filePath); if(data === null) console.log('Failed to load text file.'); else console.log('File data: '+data);

Compatibility

There isn't any compatibility information for this function.

Related

Server Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png createFile
icon-iii.png icon-vc.png icon-sa.png icon-iv.png fileExists
icon-iii.png icon-vc.png icon-sa.png icon-iv.png loadTextFile
icon-iii.png icon-vc.png icon-sa.png icon-iv.png openFile
icon-iii.png icon-vc.png icon-sa.png icon-iv.png saveTextFile


Client Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png createFile
icon-iii.png icon-vc.png icon-sa.png icon-iv.png fileExists
icon-iii.png icon-vc.png icon-sa.png icon-iv.png loadTextFile
icon-iii.png icon-vc.png icon-sa.png icon-iv.png openFile
icon-iii.png icon-vc.png icon-sa.png icon-iv.png saveTextFile