Article Preview
Buy Now
FEATURE
Using the VirtualVolume Class
Saving Styled Text and Graphics
Issue: 7.3 (March/April 2009)
Author: Tom Baumgartner
Author Bio: Tom is retired and enjoys programming in REALbasic, especially during the Canadian winter when he can't golf, fish, or play tennis.
Article Description: No description available.
Article Length (in bytes): 13,327
Starting Page Number: 18
Article Number: 7309
Resource File(s):
7309.zip Updated: 2009-03-02 13:36:57
Related Web Link(s):
http://www.freaksw.com/development/REALbasic/rb-classes.php
Excerpt of article text...
To save a document containing both text and graphics I like to save the text to a file and then save the graphics to the resource fork of the same file. The code to do this is relatively easy, but there are issues with using the resource fork (which is Mac-only and being deprecated by Apple). One alternative is the often-overlooked VirtualVolume class.
Why use VirtualVolume (VV) when using the ResourceFork class is easy? First, resource forks are not supported in Windows files. Second, Apple now recommends that resources be stored in the data fork of a separate resource file. Probably for that reason the ResourceFork class has been deprecated and may not be supported in future versions of REALbasic. Therefore using VV will make your code cross-platform ready and more future-proof.
What are the problems when using VV? To quote the
REALbasic Language Reference , "The SaveAsPicture and SaveStyledEditField methods of the FolderItem class do not work for virtual volumes." But those are exactly the methods we want to use to save documents with both styled text and graphics. After a short introduction to VV we will cover some easy workarounds for these limitations.Structure and Use of Virtual Volumes
A virtual volume is a group of "virtual" files within one single file. Think of the VV file as a folder that you can't open to display what is inside, but the folder can contain a number of files that your application can create, save, and retrieve.
...End of Excerpt. Please purchase the magazine to read the full article.