preprocessFileLineNumbers: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
(#line explained)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Returns the preprocessed content of the given file. The preprocessor is C-like, it supports comments using // or /* and */ and macros defined with #define. |= Description
| Returns the preprocessed content of the given file. The preprocessor is C-like, it supports comments using // or /* and */ and macros defined with #define. The return is  file content starting with <tt>#line 1 "aFilename"</tt><br><br>
 
<u>This is how mysterious '''#line''' keyword works:</u><br><br>
The keyword can be used in any script, even the one made on-the-fly and executed in debug console for example. The format is:<br>
<tt>'''#line''' <number> "<name>"</tt><br>
followed by new line. <number> could be any positive integer and <name> could be any name. This will be used only if an error occurs in the script. The error will contain the line:
<tt>File <filename>, line <linenumber></tt><br>
where <filename> will be the <name> you set and <linenumber> will be <number> + how many lines it is from the '''#line''' line. If the error happened on the line right under '''#line''' it will add 0 to <number>, if on second line, it will add 1 etc.<br><br>
It is possible to use more than one '''#line''' keywords, but it seems having just one at the top of the script is enough to pinpoint position of the error easily.  |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[String]] <nowiki>=</nowiki> '''preprocessFileLineNumbers''' fileName |= Syntax
| '''preprocessFileLineNumbers''' fileName |= Syntax


|p1= fileName: [[String]] |= Parameter 1
|p1= fileName: [[String]] - path to the file |= Parameter 1


| [[String]] |= Return value
| [[String]] - file content containing <tt>#line 1 "aFilename"</tt> |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <br><code>_string <nowiki>=</nowiki> '''preprocessFileLineNumbers''' "myFunction.sqf"</code>  
|x1= <code>_string = [[preprocessFileLineNumbers]] "A3\ui_f\scripts\IGUI\RscUnitInfo.sqf"</code>  


Result is "[[if]] a>b [[then]] {a} [[else]] {b}" |= Example 1
Result is: <br>
#line 1 "A3\ui_f\scripts\IGUI\RscUnitInfo.sqf"<br>
disableserialization;<br>
........ |= Example 1
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 31: Line 42:
<dd class="notedate">Posted on December 17, 2013
<dd class="notedate">Posted on December 17, 2013
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''
<dd class="note">The main difference between [[preprocessFile]] and [[preprocessFileLineNumbers]] is that the latter adds #line directive to the target file, which allows to log the __LINE__ error happened at and the __FILE__ error happened in.
<dd class="note">The main difference between [[preprocessFile]] and [[preprocessFileLineNumbers]] is that the latter adds #line keyword to the target file, which allows to log the __LINE__ error happened at and the __FILE__ error happened in.


[[Image:PreprocessFile.jpg]]
[[Image:PreprocessFile.jpg]]

Revision as of 20:55, 17 February 2017

-wrong parameter ("Arma") defined!-1.00
Hover & click on the images for description

Description

Description:
Returns the preprocessed content of the given file. The preprocessor is C-like, it supports comments using // or /* and */ and macros defined with #define. The return is file content starting with #line 1 "aFilename"

This is how mysterious #line keyword works:

The keyword can be used in any script, even the one made on-the-fly and executed in debug console for example. The format is:
#line <number> "<name>"
followed by new line. <number> could be any positive integer and <name> could be any name. This will be used only if an error occurs in the script. The error will contain the line: File <filename>, line <linenumber>
where <filename> will be the <name> you set and <linenumber> will be <number> + how many lines it is from the #line line. If the error happened on the line right under #line it will add 0 to <number>, if on second line, it will add 1 etc.

It is possible to use more than one #line keywords, but it seems having just one at the top of the script is enough to pinpoint position of the error easily.
Groups:
Uncategorised

Syntax

Syntax:
preprocessFileLineNumbers fileName
Parameters:
fileName: String - path to the file
Return Value:
String - file content containing #line 1 "aFilename"

Examples

Example 1:
_string = preprocessFileLineNumbers "A3\ui_f\scripts\IGUI\RscUnitInfo.sqf" Result is:
#line 1 "A3\ui_f\scripts\IGUI\RscUnitInfo.sqf"
disableserialization;
........

Additional Information

See also:
preprocessFileloadFileFunctionSQF syntaxcallspawnexecVMPreProcessor Commands

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 December 17, 2013
Killzone_Kid
The main difference between preprocessFile and preprocessFileLineNumbers is that the latter adds #line keyword to the target file, which allows to log the __LINE__ error happened at and the __FILE__ error happened in. PreprocessFile.jpg

Bottom Section