OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Tyger on 14 Nov 2005, 01:58:38
-
BTW, if you are going to be displaying lots of text (which it looks like you are), then you might find it easiest to put that text in an external .txt file, and then use the 'loadfile' command to put its contents into the dialog. Again, just speaking from experience.
This intrigued me, and i'm curious as to how this works. I checked the comref, and it's a little wanting of examples. ::)
loadFile filename
Operand types:
filename: String
Type of returned value:
String
Description:
Return content of given file.
Example:
loadFile "myFunction.sqf"
Do i just store that to a variable, like a global var? i.e.
TYG_MYVAR = loadFile "myText.txt"?
-
The loadfile command returns a string. This string contains whatever was in the file that you loaded. Normally the command is used to load a function into a variable, but it could come in handy any time you need to load any text into OFP.
Keep in mind that functions are just strings, no different from any other. The only difference between the 'loadfile' and 'preprocessfile' commands is that 'preprocessfile' will NOT load the comments from the file (indicated by // or /* */).
So, let's say you have a dialog. You could use the ctrlsettext + loadfile commands, and display a text file to a control:
ctrlsettext [1, loadfile "stuff.txt"]
Or you could store "stuff.txt" into a variable, in case you needed to use it more than once:
_text = loadfile "stuff.txt"
-
Thank you kind sir, for the helpful information. If you could also add that to the comref that would be excellent. ;)
I'll solve this in a day or two.