OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Unnamed on 05 Feb 2004, 19:13:44

Title: PreprocessFile and Macros
Post by: Unnamed on 05 Feb 2004, 19:13:44
Quote
Return preprocessed content of given file. Preprocessor is C-like, supports comments using // or /* and */ and macros defined with #define
This is from the Comref. Anyone know how you use macros with #Define ?

Cheers
Title: Re:PreprocessFile and Macros
Post by: Dinger on 05 Feb 2004, 20:53:18
Yeah, for example:

#define private 0

private is the macro, and 0 is the value to replace it with.
so every time you use private in the processed file, it replaces it with zero.

Note that you cannot preprocess .sqfs inside of an addon.
Title: Re:PreprocessFile and Macros
Post by: Unnamed on 06 Feb 2004, 12:54:49
I did try this using PreProcessFile on a function in my mission editor directory:

#Define MyMacro "Hello";

Hint Format ["This Macro %1",MyMacro];

But it seems to invalidate the function, you can call it without any errors. It just wont execute the hint until I remove the #Define line.

Am I using it correctly?


Edit:

Scratch that, #define is case sensitive and you dont need a semicolon. This works without any problems:

Code: [Select]
#define MyMacro Count [1,2,3]

Hint Format ["This Macro %1",MyMacro];

Cheers

P.S I read in an earlier thread about Loadfile and Addons, that functions in an Addon are already processed. Is this correct, I did not think the PBO utils were that sophisticated?
Title: Re:PreprocessFile and Macros
Post by: Extreme Studios on 07 Feb 2004, 15:45:06
It's probably best that you don't go into that unless your good at c++ programming or something, i don't.