Onetastic Macro Documentation >
>
Using binary data Using binary data
OneNote pages can contain external files in the form of Images and EmbeddedFiles.
These objects store the actual data for the image or the embedded file in their data
properties. You can duplicate an image by copying the data property:
$page = GetCurrentPage()
$existingImage = $page.images[0]
$newImage = InsertObject($page, "Image", -1)
$newImage.data = $existingImage.data
This macro will create a second image on the same page and copy the existing image data to it,
creating a copy of the image.
Binary Store
In order to create new images or embedded files, the data property must be set to a valid binary
data. While macros can copy such data from existing content, as seen above, they can also
store such data and use it to create new content. Binary store is where macros can store files
to be used to create images and embedded files.
To access binary store for a macro you can go to Storage > Edit
Binary Storage on the menu. This will display the Binary Store window:
You can use Add Files button to choose one or more files to add
to the binary store. After adding files, you can rename them or remove any files you don't need:
Using files from Binary Store
You can use files from binary store via the BinaryStore_Read function. Pass the name of the
file in the binary store to access it:
$page = GetCurrentPage()
$newImage = InsertObject($page, "Image", -1)
$newImage.data = BinaryStore_Read("flower.png")
This will create a new image using the flower.png file in the binary store. Binary store is per
macro. You cannot access files from binary store of one macro from another macro. If you need to
use the same files, simply add them to each macro.
|