ManDay 0 Posted July 6, 2007 ^ Nuff said. Compile will produce an error when comments are in the string. Share this post Link to post Share on other sites
raedor 8 Posted July 6, 2007 Can you show an example? For me it does not bring up an error on comments Share this post Link to post Share on other sites
ManDay 0 Posted July 6, 2007 0 spawn( compile loadFile "test.sqf" ); test.sqf: while{ true } { //Again and Again... sleep 1; }; --- Should bring you up an error. Share this post Link to post Share on other sites
raedor 8 Posted July 6, 2007 Sure. Use preprocessFile if you want to have C-like comments. Share this post Link to post Share on other sites
Taurus 20 Posted July 6, 2007 Anyone knows why "loadFile" exist at all? The only reason for it as I see it is for "hardcore"-scripters* who doesn't bother to add comments? There might be some performance gains too? the preprocessFileLineNumbers-command is pretty nice if you have a huge script it'll return the line-number which you have an error at. *stupid IMHO Share this post Link to post Share on other sites
Maddmatt 1 Posted July 6, 2007 Anyone knows why "loadFile" exist at all?The only reason for it as I see it is for "hardcore"-scripters* who doesn't bother to add comments? There might be some performance gains too? the preprocessFileLineNumbers-command is pretty nice if you have a huge script it'll return the line-number which you have an error at. *stupid IMHO It does support comments, just not C-like ones. Use them like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">comment "insert comment here"; I doubt there are any performance improvements with loadfile. Maybe preprocessfile will have slightly better performance? Are there any real differences between preprocessfile and loadfile? Share this post Link to post Share on other sites
crashdome 3 Posted July 6, 2007 IIRC, preprocessfile loads into memory and loadfile discards it when completed [EDit] I believe I am right, because back in SOW v2.0 we used it to load big init functions at mission start and I preferred that over preprocessfile because I knew it would be discarded. Share this post Link to post Share on other sites
UNN 0 Posted July 6, 2007 Quote[/b] ]loadfile discards it when completed How can you tell? In my experience, once you Loadfile it, it's there for the duration. Share this post Link to post Share on other sites
kegetys 2 Posted July 6, 2007 preprocessFile just does C like preprocessing (Comments, macros, etc.). It should be a bit slower than loadFile, but I doubt it makes a difference in any well designed 'real life' scenario. loadFile is needed if you do not want preprocessing, for example if you do this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> hint loadFile "message.txt" If you used preprocessfile instead of loadfile here, and message.txt would contain, for example "// hello world \\" then the result would not be what you'd expect as preprocessFile would remove the message as it would think it's a comment. Share this post Link to post Share on other sites
Nutty_101 0 Posted July 6, 2007 Now if we could have the comments work on spawn and call. That would be even better for people like me who don't always pull the scripts down from files. Share this post Link to post Share on other sites
raedor 8 Posted July 6, 2007 Additonally, it was not possible in OFP (or only certain versions?) to use preprocessFile from addon scripts, so you had to use loadFile there. So it's also still there for compatibility uses. Share this post Link to post Share on other sites
crashdome 3 Posted July 7, 2007 preprocessFile just does C like preprocessing (Comments, macros, etc.). It should be a bit slower than loadFile, but I doubt it makes a difference in any well designed 'real life' scenario. loadFile is needed if you do not want preprocessing, OK, I correct myself... THAT is more of what i remember. Share this post Link to post Share on other sites