MMF2 has a neat new feature that allows users and extensions
to embed data files within MMF applications. This feature is
known as Binary Data. It may not be obvious at first, but this
new feature lends itself to a neat little capability. It allows
extensions to retrieve data embedded within the MMF application.
Unfortunately, right now, it is not very user-friendly. All
embedded data files are referenced by their original paths (when
they were embedded), which can be a problem if the path of the
file changes. This would require the user to modify his code. The
other drawback is that embedded files cannot be referenced
directly. MMF only allows extensions to copy the files to disk to
use them, which is somewhat unfortunate. But I suppose no one
should be embedding large files anyway, so the overhead should be
minimal. As you can see, it's a good feature, but with a few
tweaks, it could be a great feature.
How to Take Advantage of Binary
There are three ways that extensions can take advantage of
this new feature:
- Treat all file paths as if they were references to
embedded files (current method): The extension uses MMF's
mvGetFile method which does the following:
- If the path appears in the Binary Data, the file
is extracted to disk and the new path of the file
- If the path is not in the Binary Data and if the
application is Vitalized, it will try to download
the file from the server and return the new path.
- Otherwise, it returns the path.
- Have the user use a special prefix to indicate that they
want to reference an embedded data file: When passing
data to an extension, the user could use a special prefix
(like a ?) to tell the extension that what follows is a
reference to an embedded data file. It could recognize
the prefix and act accordingly.
- Have an MMF expression that extracts an embedded data
file and returns the new path (personal favorite method):
This path could then be passed to any extension as a
regular file path, requiring no specail action by the
No changes to MMF are actually required for
extensions to make use of this new feature, but some changes
could be made to help improve the feature.
- Allow the user to assign an optional alias to each
embedded data file. This does two things. First, it makes
it easier for the user to reference the embedded data
file. Second, if the path of the file changes, the user
will not need to modify his code.
- Create a new MMF expression: ExtractBinaryDatFile$(szFile,
Extracts the specified embedded data file to a
temp directory and returns the path to it.
Optionally, it can delete the file at the end of
the event in which the expression is used.
- Returns: The path of
the extracted file.
- szFile: The
reference to the embedded data file (path or
- nDeleteFast: 0 to
leave the file or anything else to have MMF
delete the file at the end of the event.