First of all I would like to express my gratitude to Matthew for his continuous support. Now I also know who he is :) . Thanks mate, you are the best!

Ok. This new extension is not meant to be used on a game server or client because of security issues with writing files, it is merely a tool so that those of you who want to save some data to a file from Arma can do so. And to make sure no harm is done if someone uses it as not intended, I added safety feature – you cannot overwrite existing files, and hence you cannot append to existing files, sorry about that. You will be able to create new files in existing folders and this should be enough for variety of applications.

I was mainly thinking of the ability for Arma enthusiasts to dump some useful data in a file, like objects composition in mission.sqm like format or other format, or saving inventory setup as a ready to go script or… well you get the idea. It just writes a string of text into a file. The only feature I added was to interpret \n in strings as a new line. So “line1\nline2″ will be written as:

line1 line2

The extension will always return with a text message. If everything is alright it will return with “OK”. If for some reason it could not make file, it will return with error message. So it is up to you how you would want to check the success of the operation.

The extension accepts the following format: <filepath>|<data>, for example:

"make_file" callExtension format ["%1|%2", _path, _data];

However if you are dumping large strings of data, you might want to avoid using format command as it has a limit. It is safer to use string addition:

"make_file" callExtension (_path + "|" + _data);

So in the rawest form the use of extension will look like this:

"make_file" callExtension "myFile.txt|line1\nline2\nline3";

This will create myFile.txt in the same folder as the extension and write into it:

line1 line2 line3

Instead of relative path you can also use absolute path to your file, for example “C:\Users\KK\Desktop\myFile.txt“.

I have also written a function, which I think should make it a little bit more convenient to temporary stack lines in a variable and then write them in one go. Here is the code:

KK_fnc_makeFile = { switch (typeName _this) do { case "STRING" : { _this = _this + "|" + (missionNamespace getVariable ["__temp", ""]); missionNamespace setVariable ["__temp", nil]; "make_file" callExtension _this; }; case "TEXT" : { missionNamespace setVariable [ "__temp", (missionNamespace getVariable ["__temp", ""]) + str _this + "\n" ]; }; }; };

Basically if you send TEXT to the function it treats it as a line and makes a stack. If you send it a STRING it will interpret it as filepath and will call extension with the data stored in the stack, after which it will empty the stack. Here is an example of the use, should give you some ideas:

text " * line1" call KK_fnc_makeFile; //add line text " * line2" call KK_fnc_makeFile; text "" call KK_fnc_makeFile; //add empty line text " * line4" call KK_fnc_makeFile; text "\n\n" call KK_fnc_makeFile; //add 3 empty lines for "_i" from 8 to 10 do { formatText [" * line%1", _i] call KK_fnc_makeFile; }; hint ("C:\Users\KK\Desktop\myFile.txt" call KK_fnc_makeFile);

Resulting file would look like this:

* line1 * line2 * line4 * line8 * line9 * line10

Download v1.0

Enjoy,
KK

EDIT: I reviewed security arrangements with file making and added ability to overwrite the last file you wrote in successfully. This is available in v1.1. The version can be found by using ABOUT command:

hint (“make_file” callExtension “ABOUT”);

Download v1.1

EDIT: Well, I have reviewed security arrangements even further and upgraded the .dll to v1.5. In case someone would like to permanently keep the .dll in Arma 3 directory, any call to make_file with new filepath will trigger a modal message box prompting user to confirm the file write operation. If user cancels the request he will have a choice to further block all file write requests if necessary. I added this so that if in an unfortunate case of someone trying to abuse this in multiplayer this will stop possible griefing. Once blocked, the only way to reenable .dll functionality would be by restarting the game.

Because of this 2 more error messages are added:

  • “USER CANCELLED” – when user presses “Cancel” button
  • “USER BLOCKED” – when .dll is blocked

Download v1.5