Jump to content
Sign in to follow this  
Fuzzy Bandit

Dynamic #includes

Recommended Posts

I'm looking into a way of including content from a variable number of files in my description.ext. In this particular case, let's say I want to include some CfgSounds classes.

If I have two folders, somethingA and somethingB, I want to, essentially, do a forEach command within the description.ext and grab the contents of both somethingA\CfgSounds.hpp and somethingB\CfgSounds.hpp.

Already played around with feeble attempts like the one below, but that (obviously) didn't work. :) In the below example, "config.sqf" is a file that defines and returns a list containing somethingA and somethingB.

__EXEC( _folders = [] call "config.sqf"; { path = format["%1\CfgSounds.hpp", _x]; #include path } forEach _folders; )

Is there any way to achieve this?

Share this post


Link to post
Share on other sites

So there's no way get this working at all? I'm aware it'd be a small convenience, really, but it would still be a lovely thing to get working! :D

Share this post


Link to post
Share on other sites
You can try using defines and then check to see if it is defined.

#ifdef ENABLE_DEBUG
#include "debug.sqf"
#endif

http://community.bistudio.com/wiki/PreProcessor_Commands

he has:

missionFolder/someName1/cfgSounds.ext

missionFolder/someName2/cfgSounds.ext

missionFolder/someName3/cfgSounds.ext

missionFolder/someName4/cfgSounds.ext

he want to do something like:

#includeAllCfgSounds

how this should help him ?

Share this post


Link to post
Share on other sites

I'm note really sure why you would wanna do this.

Not sure buy maybe something like this would work, create a sqf for each include:

sound1.sqf

#include \1\CfgSounds.hpp

Then your script can call all the includes needed.

{
bla[] = compileFinal preprocessFileLineNumbers format["sound%1.sqf", _x];
} foreach scriptNo;

Not sure if possible but if you could check if a script exists you could just increase an integer, check if it exists and if so compileFinal. That is assuming including configs this way even works.

Share this post


Link to post
Share on other sites

My idea would be: Use Powershell or VBScript to combine the content of the files.

The Content of the includefile should the combined content of the .ext files (generated by your vbscript or powershell script - powershell would be easier)

In this case: You would be able to generate your .ext with a doubleclick. After a restart the content would work.

The VBScript or the Powershell would enable the dynamic file operations.

Maybe the pro's could have a look on this idea. I am not sure if that would work with arma.

I am learning atm the Arma Preprocessor commands and the forum search pointed to this interesting topic.

Dont want to hijack this thread and will make a new one, after reading some other threads.

Edit:

Was in the market with the opened editor !!!!needed beer!!!! :) So i was not able to read mindstorms post.

mindstorms idea sounds really good.

Share this post


Link to post
Share on other sites
how this should help him ?

I told you how to help him, you define a variable using the #define preprocessor command....

in description.ext you put something to this nature at the bottom of it

class CfgSounds
{
 sounds[] = {};
#include "subfolder\somefilea.hpp";
#include "subfolder\somefileb.hpp";
#include "subfolder\somefilec.hpp";
};

in somefilea.hpp

#ifdef ENABLE_SOUNDFILEA
class wolf1
{
	// how the sound is referred to in the editor (e.g. trigger effects)
	name = "my_wolf_sound";
	// filename, volume, pitch
	sound[] = {"fx\wolf1.ogg", 1, 1};
	titles[] = {};
};
#endif

somefileb.hpp would be slightly diffrent at the top but mostly the same

#ifdef ENABLE_SOUNDFILEB

at the top of init.sqf you put:

#DEFINE ENABLE_SOUNDFILEA
#DEFINE ENABLE_SOUNDFILEB
#DEFINE ENABLE_SOUNDFILEC

If your curious to see a working implementation of this download R3F logistics system

http://www.armaholic.com/page.php?id=9285

Edited by xyberviri

Share this post


Link to post
Share on other sites

I think he was trying to be lazyefficient and simply have any cfgSound files in any/specificed folder automatically get added to the description.ext without having to edit that file.

Share this post


Link to post
Share on other sites

Thanks for all the suggestions, everyone. mindstorm's idea is probably closest to what I had in mind for the final result but, alas, I've already tried that method and failed.

I'll resign myself to just putting includes in the description.ext; this was really a look at making things more modular in a mission I'm creating, meaning adding/removing certain elements didn't mean you'd have to edit a number of files.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×