loadFile: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Add example and comments cleanup)
m (template:command argument fix)
Line 8: Line 8:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Return content of given filename as string. If you plan to [[compile]] said string, be aware that the file shouldn't contain comments or [[compile]] will throw an error. If there are comments, use [[preprocessFile]]/[[preprocessFileLineNumbers]] instead. |= Description
| Return content of given filename as string. If you plan to [[compile]] said string, be aware that the file shouldn't contain comments or [[compile]] will throw an error. If there are comments, use [[preprocessFile]]/[[preprocessFileLineNumbers]] instead. |DESCRIPTION=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[loadFile]] fileName |= Syntax
| [[loadFile]] fileName |SYNTAX=


|p1= fileName: [[String]] |= Parameter 1
|p1= fileName: [[String]] |PARAMETER1=


| [[String]] |= Return value
| [[String]] |RETURNVALUE=
____________________________________________________________________________________________
____________________________________________________________________________________________


|x1= <code>_contents = [[loadFile]] "wantedString.txt";</code> |= Example 1
|x1= <code>_contents = [[loadFile]] "wantedString.txt";</code> |EXAMPLE1=


|x2= <code>_contents = [[compile]] [[loadFile]] "myFunction.sqf"; {{codecomment|// will compile string into code}}</code> |= Example 2
|x2= <code>_contents = [[compile]] [[loadFile]] "myFunction.sqf"; {{codecomment|// will compile string into code}}</code> |EXAMPLE2=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[preprocessFile]], [[preprocessFileLineNumbers]] |= See also
| [[preprocessFile]], [[preprocessFileLineNumbers]] |SEEALSO=


}}
}}

Revision as of 14:43, 7 April 2019

Hover & click on the images for description

Description

Description:
Return content of given filename as string. If you plan to compile said string, be aware that the file shouldn't contain comments or compile will throw an error. If there are comments, use preprocessFile/preprocessFileLineNumbers instead.
Groups:
Uncategorised

Syntax

Syntax:
loadFile fileName
Parameters:
fileName: String
Return Value:
String

Examples

Example 1:
_contents = loadFile "wantedString.txt";
Example 2:
_contents = compile loadFile "myFunction.sqf"; // will compile string into code

Additional Information

See also:
preprocessFilepreprocessFileLineNumbers

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Posted on 25 January 2016 - 12:13
James
Notice that you will have to activate file patching via -filePatching. Otherwise, execVM and loadFile will *not* load any files outside your mission folder (like the global scripts).

Bottom Section