GSAK (Geocaching Swiss Army Knife)
Contents - Index

Code binary file (Macro=>Code binary file)


This option is for use in combination with the macro function MimeDecode. It allows you to "embed" and then extract any binary file inside the macro language. It may not immediately be obvious why you would want to do this, but it adds a whole new dimension to the macro language.

Some of the more advanced macro users are wanting to distribute binary files (icons, bitmaps, etc - for example the GoogleEarth macro) in the macro. How best to do this? A zip file perhaps, but an installer would be better. However, not all macro writers would have access to an installer (and catering for all end users could be a challenge) so wouldn't it be great if we could "embed" binary files in a macro. This would allow macros to do a full install from start to finish placing any required binary files on the target computer - all using a single distributable macro.

Using the Macro option "Code a binary file" will allow you to select any file or group of files from a standard Windows dialog. When you click on OK, GSAK will generate the required macro code to store those files to the clipboard, then all you need to do is paste that code into your macro.

A simple example should illustrate this. We will embed a png graphic in the following macro, and if you run it should put the file test.png to the root folder of your c: drive and display it (you may want to delete this file after testing). If all works correctly the picture displayed should be the "house" icon from the tool bar:

$image = MimeDecode($test)
$result = PutFile("c:\test.png",$image)
fileopen file=c:\test.png
cancel
<data> VarName=$test
iVBORw0KGgoAAAANSUhEUgAAAB8AAAAcCAIAAAAWWPPAAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJ
TUUH1gEKACM1snQvBAAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAK
dEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJl
AF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3Vy
Y2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAAAw0lEQVR4nO2WwQ3C
MAxF/VFHiJQVMjAnNuDADMAW7QhFZYbPwVKJCk0cNUiNxD85l+fEP7aMaezlZwJJACQrcwER6S7nk56f
j6EW+na9a3CoRfyqP70FuvPB+aDxMYor0J0PpJCShRbTFQ0IUJCgK0JrSwPQY1b5uy/QIkJSX7CV/ole
JEiXKEVfQ9sTpOjT2K+h4wSJGW5yVYXIR+PELusm/e927WkS7IuedzU2cw5h6dQsfePG0HLdW6a/XZ1X
nIp6AYOQWQ12VbomAAAAAElFTkSuQmCC
<enddata> 


Copyright 2004-2019 CWE Computer Services  
Privacy Policy Contact