OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Fragorl on 07 Sep 2005, 10:17:12

Title: loadfile works, preprocessFile doesnt
Post by: Fragorl on 07 Sep 2005, 10:17:12
Maybe I'm doing something stupid, maybe not. Either way, I'm getting this error message:

"script FRG_Addon\functions\myFunction.sqf not found"

This is when I have the following in my addon's initialisation script:

_function = preprocessFile "\FRG_Addon\functions\myFunction.sqf"

However, if I change it to read

_function = loadFile "\FRG_Addon\functions\myFunction.sqf"

(ie exactly the same but with loadfile) then it works fine. The function itself has no comments, neither the // and /**/ variety, nor the comment{}; variety. I had a brief check of the comref to see if this was a known problem, but nothing at all could I see.

Any help appreciated.
Title: Re:loadfile works, preprocessFile doesnt
Post by: h- on 07 Sep 2005, 16:15:09
OFP 'feature' (another BISd function)

preprocessFile does not support 'paths' to external pbos/locations (in lack of better terminology which Mikero will correct later on :) :P )...

It only works in missions when the sqf to be preprocessed is in the same pbo (haven't tried subfolders in mission pbo)...
preprocessFile also works if the sqf is located in the dta\scripts.pbo and in a subfolder in it (scripts.pbo)...

Sometimes when you use
_function = preprocessFile "..\FRG_Addon\functions\myFunction.sqf"
may work, I have not had the luxury but others have...

EDIT:
Afaik you don't 'lose a thing' when you use loadFile instead of preprocessFile...
Title: Re:loadfile works, preprocessFile doesnt
Post by: Fragorl on 08 Sep 2005, 00:46:43
Cheers HateR :D

Yes, this is part of an addon, which explains why I was so confused that it worked in a test mission but not in the other situation ... :P the only reason I was using preprocess is to remove \\ and \* comments.

I will give the double dots "..\" a go. This normally means 'down directory' in dos-speak, doesn't it?

Anyhow, if nothing else works, I will simply switch over to loadfile and do away with comments ... which is a bugger, but if I have to then I will.

Btw, this would have been in the bugged/bis'd commands thread, wouldn't it? I didn't think to look there. Anyhow, will post a comment in the comref about this once I test it tonight. Thanks for the help.
Title: Re:loadfile works, preprocessFile doesnt
Post by: h- on 08 Sep 2005, 17:49:01
Quote
I will give the double dots "..\" a go. This normally means 'down directory' in dos-speak, doesn't it?
I have no clue :P
Seen it used in C++ #include etc. though...

This thing was revealed to me by the 'great MP mastah' Killswitch, btw, so it's not my find... :)

Quote
Btw, this would have been in the bugged/bis'd commands thread, wouldn't it?
I don't think this particular thing is actually mentioned there..
But me memory can fail me... :)
Title: Re:loadfile works, preprocessFile doesnt
Post by: Killswitch on 08 Sep 2005, 20:20:26
Yep, one can use preprocessFile in an addon. Just remember this:
If you don't understand the second point there and the implications it has with regards to documenting and supporting your addon properly, please use loadFile instead.

(*) It's due to a path separator parsing bug - the person responsible for the Linux code was inconsistent in remembering to accomodate for the fact that in Unix, the path separator is the forward slash and in Windows the backward one.

Title: Re:loadfile works, preprocessFile doesnt
Post by: Fragorl on 11 Sep 2005, 03:35:20
Unfortunately I'm having no luck with this approach, perhaps because I have the function in question in a further directory:

\MyAddon\Functions\Function.sqf

I've tried every possible approach (I think) to get it to work, short of dumping the functions straight into the addon folder, which I'm not prepared to do. Looks like I'll have to settle for removing all comments and using loadfile  :-\
Title: Re:loadfile works, preprocessFile doesnt
Post by: h- on 11 Sep 2005, 07:52:00
Well, you don't lose much if you are not using comments...

It seems that not many open up the script parts of AddOns, they're more interested in the textures/models... ::)

You can always include a text version (.txt, not .sqf) which has the comments in  case someone happens to be interested...