thdman1511 4 Posted August 29, 2013 As I continue to learn scripting, I am just wondering whether there are guideline on when to use #include in a script. I have seen it used widely in init.sqf files, and would like to know, if there are any general guidelines on it use in scripting and when should a file be included in the init.sqf or config file. Share this post Link to post Share on other sites
kylania 567 Posted August 29, 2013 You never need to use it. But it helps if you want to keep things clean or to separate a lot of your code from other's code. There's probably some code optimizational reason for it too but 99.9% of what you'll be writing probably doesn't need it. heh Share this post Link to post Share on other sites
Coding 12 Posted August 29, 2013 if I am not wrong the effect of include is nothing else than copy all content of another file into the file where the include is. Nothing more and nothing less. I would recommend you to deny its usage if it is not needed. Some nice spots to use it would be in classes: class A { #include otheronesclass class yourclass { }; }; without the include you have to copypaste the other class into your description.ext (in addons you also can use another config.cpp...) Share this post Link to post Share on other sites
thdman1511 4 Posted August 29, 2013 Thanks for that, Guys much appreciated. Share this post Link to post Share on other sites
cuel 25 Posted August 29, 2013 It's useful if you use one or several macros defined as local variables Share this post Link to post Share on other sites
Desrat 0 Posted August 29, 2013 speaking of macros - is there a tutorial or reference on how to use macros in ArmA - seen em used but a lot (especially domination) and never really fully understood their purpose or the reason to use em over other methods. Share this post Link to post Share on other sites
Coding 12 Posted August 29, 2013 I dont know anything about macros but in C they also work like copypaste. That means if you would use a function at a point the function has to be called (needs time). often calling small functions (only a few lines) reduces speed! But macros increases the binary size and can fuck your program. No joke! I think macros in arma will work similar... Share this post Link to post Share on other sites
cuel 25 Posted August 29, 2013 http://community.bistudio.com/wiki/PreProcessor_Commands Using domi as an example; macros.sqf #define __cppfln(xdfunc,xfile2) xdfunc = call compile preprocessFileLineNumbers #xfile2 The macro is now set up so we only need to write __ccppfln(function_name,path_to_script). #xfile2 means that the path will be converted into a string #include "macros.sqf" // contents of macros.sqf now exists in this script __ccppfln(TAG_check_Score,scripts/functions/checkscore.sqf) // TAG_check_score is now compiled _value = [player] call TAG_check_score It allows you to keep commonly used commands in one file, allowing it to be easily edited etc. It's just another way of doing stuff :) Use whatever you prefer. 1 Share this post Link to post Share on other sites