preprocessFileLineNumbers: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "_{10,} " to "") |
Lou Montana (talk | contribs) m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame|Game [Vv]ersion|Game Version \(number surrounded by NO SPACES\)|Multiplayer Arguments( \("local" or "global"\))?|Effects|Multiplayer Effects( \("local" or "global"\))?|Multiplayer Exe...) |
||
Line 1: | Line 1: | ||
{{Command | {{Command | ||
| arma1 | | arma1 | ||
|1.00 | |1.00 | ||
|gr1= System | |gr1= System | ||
| Returns the preprocessed content of the given file. The preprocessor is C-like, it supports comments using /* */ and [[PreProcessor Commands]]. The preprocessor also adds a default debug entrypoint for compiler at the begining of script: <tt>#line 1 "aFilename"</tt><br><br> | | Returns the preprocessed content of the given file. The preprocessor is C-like, it supports comments using /* */ and [[PreProcessor Commands]]. The preprocessor also adds a default debug entrypoint for compiler at the begining of script: <tt>#line 1 "aFilename"</tt><br><br> | ||
Line 16: | Line 16: | ||
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> | <br><br> | ||
{{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}} | {{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}} | ||
| '''preprocessFileLineNumbers''' fileName | | '''preprocessFileLineNumbers''' fileName | ||
|p1= fileName: [[String]] - path to the file | |p1= fileName: [[String]] - path to the file | ||
| [[String]] - file content containing <tt>#line 1 "aFilename"</tt> | | [[String]] - file content containing <tt>#line 1 "aFilename"</tt> | ||
|x1= <code>_string = [[preprocessFileLineNumbers]] "A3\ui_f\scripts\IGUI\RscUnitInfo.sqf"</code> | |x1= <code>_string = [[preprocessFileLineNumbers]] "A3\ui_f\scripts\IGUI\RscUnitInfo.sqf"</code> | ||
Line 30: | Line 30: | ||
#line 1 "A3\ui_f\scripts\IGUI\RscUnitInfo.sqf"<br> | #line 1 "A3\ui_f\scripts\IGUI\RscUnitInfo.sqf"<br> | ||
disableserialization;<br> | disableserialization;<br> | ||
........ | ........ | ||
| [[fileExists ]] [[preprocessFile]], [[loadFile]], [[Function]], [[SQF syntax]], [[call]], [[spawn]], [[execVM]], [[PreProcessor Commands]] | | [[fileExists ]] [[preprocessFile]], [[loadFile]], [[Function]], [[SQF syntax]], [[call]], [[spawn]], [[execVM]], [[PreProcessor Commands]] | ||
}} | }} |
Revision as of 01:25, 18 January 2021
Description
- Description:
- Returns the preprocessed content of the given file. The preprocessor is C-like, it supports comments using /* */ and PreProcessor Commands. The preprocessor also adds a default debug entrypoint for compiler at the begining of script: #line 1 "aFilename"
The #line keyword can be used in any script that are not preprocess, or with preprocess script with extra macro to protect reserverd sharp character. The format is:
#line <number> "<name>"
followed by new line. <number> could be only 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 for little script is enough to pinpoint position of the error easily.
- Groups:
- System
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
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.
Bottom Section
- 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.
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Command Group: System
- Operation Flashpoint: Elite: Scripting Commands
- Arma 2: Scripting Commands
- Arma 3: Scripting Commands
- Take On Helicopters: Scripting Commands