Home   Help Search Login Register  

Author Topic: #include paths (in mission scripts)  (Read 1181 times)

0 Members and 1 Guest are viewing this topic.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
#include paths (in mission scripts)
« on: 01 Aug 2007, 17:25:08 »
If I use #include in an SQF script, then it includes the included file path relative to the file that has the #include in it. This seems to mean I can only include files below the including file path, which is what is causing me problems. My question is, is there any way to #include a file in a parent directory, from an SQF file? (I'm really hoping I'm missing something obvious!)

e.g.
I want to include "test.Intro\scripts\macros.sqf" in "test.Intro\scripts\fish\frog.sqf"

If I have tried several methods:
Code: [Select]
#include "scripts\macros.sqf"If I was using loadFile or similar, then this path would be correct, but with #include, ArmA CTDs and then it says it could not find file "C:\<full path>\test.Intro\scripts\fish\scripts\macros.sqf"

Code: [Select]
#include "..\macros.sqf"ArmA CTDs and tells me that it cannot find "C:\<full path>\test.Intro\scripts\fish\..\macros.sqf".

Code: [Select]
#include "\scripts\macros.sqf"ArmA CTDs and then it says it could not find file "scripts\macros.sqf". I assume that it is actually looking at the root directory of the drive, rather than of the mission, based on the response to the previous attempt.

Code: [Select]
#include "C:\<full path>\test.Intro\scripts\macros.sqf"ArmA CTDs without giving a reason, but even if it did work, I obviously couldn't use this method in a mission that I've given to anyone else!

I've tried all those include statements with <...>, instead of "...", but it seems to have identical behaviour.

My current solution is to have all my mission scripts (about 40 at last count) in the same directory, "test.Intro\scripts\", so that they can all #include my macros file. This is already more files than is managable and I intend to write at least another 50 scripts! I'd really like to be able to sort them out into sub-directories while still being able to include common files.

I even considered creating a master macros file and making a batch file to copy it into every sub-directory, but that method has too many ways to go wrong (editing wrong version, forgetting to run the batch file, multiple copies of a (large) file in every mission, etc.) ;(
« Last Edit: 01 Aug 2007, 17:26:47 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)