preprocessFileLineNumbers: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<dl class="command_description"> <dd class="notedate">" to "<dl class="command_description"> <dt></dt> <dd class="notedate">")
m (Text replacement - "<br><br> {{Feature" to "{{Feature")
Line 15: Line 15:
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>
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 for little script is enough to pinpoint position of the error easily.  
It is possible to use more than one '''#line''' keywords, but it seems having just one at the top for little script is enough to pinpoint position of the error easily.  
<br><br>
{{Feature | Warning | If the file you are loading is not prepared using UTF-8 encoding and contains some characters [[toArray | with codes]] > 127, they might convert incorrectly}}
{{Feature | Warning | If the file you are loading is not prepared using UTF-8 encoding and contains some characters [[toArray | with codes]] > 127, they might convert incorrectly}}



Revision as of 21:35, 9 June 2021

Hover & click on the images for description

Description

Description:
Description needed
Groups:
System

Syntax

Syntax:
Syntax needed
Parameters:
fileName: String - path to the file
Return Value:
Return value needed

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:
fileExists 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
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
Posted on November 4, 2017 - 10:16 (UTC)
code34
The #line directive get's removed from the output.
So to add a custom #line directive before while using preprocessFileLineNumbers, you have to use a preprocessor macro like this:
#define DEBUG(sharp,name) sharp##line 0 name
and add this at the right place in your code
DEBUG(#,"your filename"); This way you can have custom filenames in error messages.