Requires FM 1.0 Beta 8.5 (Nov 2007) or newer
bool copyResToArray(string restype, string resname, int arraynr)
Returns true if copying the resource into the array succeeded, false otherwise.
Copies a file that has been embedded as a resource in the plugin DLL into a built-in FM array.
You can embed any kind of file into a plugin using the Other embed type, e.g. Embed: Other="Test.txt". The file will be embedded as an "FMDATA" resource type in the plugin 8BF DLL file, and can be verified with third-party programs like Resource Hacker.
From FM 1.0 Beta 9.1 (Feb 2009) onwards, if copyResToArray can't find a resource with the given name, it will also try looking for a file with the same name as the resource.
%fml Title: "Test copyResToArray" Category: "FM Example Code" Embed: Other="test.txt" // Make a control to display text on the interface ctl[10]: STATICTEXT, Size=(100, 40), Text="This text will be replaced" OnFilterStart: { bool loaded = false; // Load the test.txt file embedded in the plugin into Array #0 loaded = copyResToArray("FMDATA", "test.txt", 0); // If the resource loaded, copy the (max) first 255 characters // into an internal string variable, so it correctly ends // with a zero byte to mark the end of string if (loaded) { strncpy(str1, getArrayAddress(0), 255); } else { strncpy(str1, "Could not find test.txt file", 255); } // Set control #10 to be labelled with the contents of str1 setCtlText(10, str1); return true; }