loadFile: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (formatted notes + formatted examples)
No edit summary
Line 42: Line 42:
<dd class="notedate">Posted on 02 December 2012 - 11:17 (ZULU)
<dd class="notedate">Posted on 02 December 2012 - 11:17 (ZULU)
<dt class="note">'''[[neokika]]'''<dd class="note">Please note that any comment you have within the file you load will be included, to get around that use preprocessFile instead.
<dt class="note">'''[[neokika]]'''<dd class="note">Please note that any comment you have within the file you load will be included, to get around that use preprocessFile instead.
<dd class="notedate">Posted on 11 July 2007 - 01:10 (CEST)
<dt class="note">'''[[User:Tactii|Tactii]]'''<dd class="note">The note by [[User:Pennywise|Pennywise]] is not entirely accurate. [[loadFile]] only needs to be preceded with [[compile]] when loading [[Code|code]] (for example, a [[Function|function]] contained in an [[Script (File)|.sqf file]]). Using [[loadFile]] without [[compile]] will return a [[String|string]], which, in some cases, is exactly what you want.
<dd class="notedate">Posted on 25 January 2016 - 12:13
<dt class="note">'''[[User:James|James]]'''<dd class="note">Notice that you will have to activate file patching via -filePatching  [[https://community.bistudio.com/wiki/Arma_3_Startup_Parameters|-filePatching]]. Otherwise, execVM and loadFile will *not* load any files outside your mission folder (like the global scripts). For more info see CMA:DevelopmentSetup (since Arma 3 1.49+).


<!-- Note Section END -->
<!-- Note Section END -->

Revision as of 13:19, 25 January 2017

Hover & click on the images for description

Description

Description:
Return content of given filename.
Groups:
Uncategorised

Syntax

Syntax:
String = loadFile filename
Parameters:
filename: String
Return Value:
String

Examples

Example 1:
_contents = loadFile "myFunction.sqf"

Additional Information

See also:
preprocessFileLineNumberspreprocessFile

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 28 November 2006 - 01:37
Pennywise
In Armed Assault, the 'loadfile' command must be preceded by the 'compile' command to work.
Ex OFP 1.96: _falarmEvent = loadfile ("syswarn\falarmEvent.sqf")
Ex ArmA 1.0: _falarmEvent = compile loadfile ("syswarn\falarmEvent.sqf")
Posted on 11 July 2007 - 01:10 (CEST)
Tactii
The note by Pennywise is not entirely accurate. loadFile only needs to be preceded with compile when loading code (for example, a function contained in an .sqf file). Using loadFile without compile will return a string, which, in some cases, is exactly what you want.
Posted on 02 December 2012 - 11:17 (ZULU)
neokika
Please note that any comment you have within the file you load will be included, to get around that use preprocessFile instead.
Posted on 11 July 2007 - 01:10 (CEST)
Tactii
The note by Pennywise is not entirely accurate. loadFile only needs to be preceded with compile when loading code (for example, a function contained in an .sqf file). Using loadFile without compile will return a string, which, in some cases, is exactly what you want.
Posted on 25 January 2016 - 12:13
James
Notice that you will have to activate file patching via -filePatching [[1]]. Otherwise, execVM and loadFile will *not* load any files outside your mission folder (like the global scripts). For more info see CMA:DevelopmentSetup (since Arma 3 1.49+).

Bottom Section