Home   Help Search Login Register  

Author Topic: loadfile works, preprocessFile doesnt  (Read 1126 times)

0 Members and 1 Guest are viewing this topic.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
loadfile works, preprocessFile doesnt
« 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.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:loadfile works, preprocessFile doesnt
« Reply #1 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...
« Last Edit: 07 Sep 2005, 16:17:15 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:loadfile works, preprocessFile doesnt
« Reply #2 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.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:loadfile works, preprocessFile doesnt
« Reply #3 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... :)
« Last Edit: 08 Sep 2005, 17:49:42 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:loadfile works, preprocessFile doesnt
« Reply #4 on: 08 Sep 2005, 20:20:26 »
Yep, one can use preprocessFile in an addon. Just remember this:
  • As mentioned, the filename must be  "..\MyAddon\something.sqf" instead of just "\MyAddon\something.sqf"
  • Due to yet another bug in the dedicated Linux server software, such an addon will not work there unless you create an empty folder named "scripts" in your Linux ofp server installation folder.(*)
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.

« Last Edit: 08 Sep 2005, 20:29:32 by Killswitch »

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:loadfile works, preprocessFile doesnt
« Reply #5 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  :-\

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:loadfile works, preprocessFile doesnt
« Reply #6 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...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.