#!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP #!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP

3D
3D Photo Gallery (Part 1)
3D Photo Gallery (Part 2)

Audio
Poor Man's MIDI
Make A Metronome
iPod Tricks (Part 1)
iPod Tricks (Part 2)
iPod Tricks (Part 3)
Laugh Track Machine
Audio Player with Reverb
Shepard Melody
RB Phone Home
Build a Drum Machine

Custom Controls and Windows
Double Click Listbox
Draggable Metal Window
Double Click Canvas
Custom Buttons
Custom Buttons Part II
iTunes-style Listboxes
Custom Controls


General RB
Scrolling Windows
Using Mesage Dialogs
Case-Sensitive Word Finder
Introduction to Stacks
Wiggle Window
JPEG in PDF
Listbox Checkboxes
Background Applications
Listbox Auto-Find
Virtual Volumes
Time Tracker
Software Distribution (Part 1)
Software Distribution (Part 2)
Software Distribution (Part 3)
Software Distribution (Part 4)
Exceptions
Tips and Tricks
Text Clippings Made Easy

Graphics
Drawing a Simple Gradient
The SpriteSurface: Space Game
Image Spinner
Cropping Graphics (Part 1)
Cropping Graphics (Part 2)
Cropping Graphics (Part 3)
Cropping Graphics (Part 4)
Shimmer Graphics
Lissajous Figures
Simple Screen Capture
Vector Graphics
Kaleidoscope Images
Stegonography
Spirals!
Image Table
RB Magnifying Lens
Screen Capture
Color Picker Tutorial

Hacks
Ghost Grab
Speedy Mouse Extension
iTunes Plugins
iTunes Skinner

Mac OS X
Global Hot Key Event (Carbon Events)
Login Welcomer (Carbon Events)
Add/Remove Buttons
Resizable Sheets
Mac OS X Preferences Window
Using Sheets in REALbasic
Build a Bundle (Part 1)
Build a Bundle (Part 2)
Dock Your Passwords
Mac OS X Debugging
REALbasic Mac OS X Icon Tutorial
Animate Your Dock
RB and the Command Line

Menus
Window Menu
Templates Menu
Listbox Menu

Novelty
Guessing Game
Calendar Trivia
Tile Mixer
Zip Code Finder
Happy Valentine's Day
Merlin Simulator (Part 1)
Merlin Simulator (Part 2)
Merlin Simulator (Part 3)
Buzzword Machine
AppleSoft BASIC

Printing
Print to PDF

Registration
Registration Code Validation
Network Registration Codes

Resources
Picture Extractor (Part 1)
Picture Extractor (Part 2)

Serial
Caller ID (Part 1)
Caller ID (Part 2)
Caller ID (Part 3)

Speech
Speech Recognition

Socket Communication
Easy Peer-to-Peer File Sharing
MacPAD Version Checking
Display Web Image In Canvas
HTML IMG Tags
Version Tracking
Even Smarter Instant Messaging
Web Tiler
JavaScript and REALbasic
Stock Ticker (Part I)
Stock Ticker (Part 2)
AIM Mate

XML Manipulation
Simple XML Introduction

Video
Big Brother Video Capture

Note: All articles without a byline were written by Erick Tejkowski. When cleaning the site I removed them because the code differed from page to page, and I have yet to put them back in.

resexc2.gif (20k)




REALbasic for Dummies
by Erick Tejkowski

$19.99 @ Amazon





Files are in Stuffit 6.5 or earlier, or ZIP format.
Download Stuffit Expander

Tell us about a bad link.

Virtual Volumes
08-01-02




V DRIVE To continue our examinination of the new features in REALbasic 4.5, we'll look at Virtual Volumes this week. If you've ever needed to store different kinds of data in one file, REALbasic's Virtual Volumes are for you!


NOTE: This project requires REALbasic 4.5 or newer!

The new VirtualVolume feature of REALbasic is easy to learn, quick to code, and is a pretty handy tool for your next REALbasic project. The VirtualVolume class lets you store multiple files in one file. This is somewhat like the disk images that you may have used in the Finder. Since REALbasic 4.5 gives you this feature across all of its target platforms (OS9, OSX, and Win32), we'll build today's example using the Classic Mac OS.

Build the Interface

Launch REALbasic and open Window1 from the Project window. To this window, add the following controls:

Control Type Control Name Other Properties
PushButton PushButton1  
PushButton PushButton2  
EditField EditField1 ReadOnly=TRUE
EditField EditField2 ReadOnly=TRUE

Arrange the interface however you want. It might look like this:

08-01-02_interface.jpg (20k)

Source Code

That's it for the interface, now it's time to add some code. The code we'll add goes in the Action event of PushButton1 and PushButton2. First, PushButton1:

  dim f,root,textfile,numberfile as folderItem 
  dim v as virtualVolume
  dim textout as textoutputStream
  dim numout as binaryStream
  dim d as date 
  
  f=DesktopFolder.Child("Resex Virtual Volume")
  v=f.createVirtualVolume
  
  if v<>nil then
    //we have a virtual volme, so let's find it's root
    root = v.Root
    
    //create folderitems for the items
    //we will add to the virtual volume
    textfile = root.child("My Text")
    numberfile = root.child("My Date")
    
    if textfile<>nil then
      //create a text file on the virtual volume
      textout = textfile.createTextFile
      //add some text to it
      textout.writeline "This is text on my virtual volume."
      textout.close
    end if
    
    if numberfile<>nil then
      d=new date 
      //using a generic binary file type here
      //that we didn't even have to define
      //in the file types dialog
      numout = numberfile.createbinaryFile("")
      //store the day, month, and year
      numout.writelong d.day 
      numout.writelong d.month 
      numout.writelong d.Year
      numout.close
    end if
    
  end if
  

Then, it's time for PushButton2

  dim f,root,textfile,numfile as folderItem 
  dim v as virtualVolume
  dim textin as textinputStream
  dim binin as binaryStream
  dim s as string 
  
  f=DesktopFolder.Child("Resex Virtual Volume")
  
  //now open the virtual volume
  v=f.OpenAsVirtualVolume
  
  if v<>nil then
    //we have a virtual volme, so let's find it's root
    root = v.Root
    
    //create folderitems for the items
    //we will retrieve from the virtual volume
    textfile = root.child("My Text")
    numfile = root.child("My Date")
    
    if textfile<>nil and textfile.exists then
      //create a text file on the virtual volume
      textin = textfile.openasTextFile
      //read the text from it
      editfield1.text=textin.readline
      textin.close
    end if
    
    if numfile<>nil and numfile.exists  then
      //get the date from the virtual volume
      binin = numfile.openasbinaryFile(FALSE)
      if binin<>nil then
        //day
        s = str(binin.readlong)+"."
        //month
        s = s + str(binin.readlong)+"."
        //year
        s = s + str(binin.readlong)
        editfield2.text=s 
        binin.close
      end if
      
    end if
    
  end if
  

As you can tell, there isn't much to learn here, but there is much to gain. Creating a VirtualVolume requires use of the new "CreateVirtualVolume" method of the FolderItem class. Once you have a VirtualVolume, you find it's root using the "Root" method. From there, it's standard REALbasic code.

Conclusion

To test the project, select the Debug-Run menu. The demo creates a VirtualVolume on the desktop and adds two files to it. Clicking the other PushButton will retrieve the data from the VirtualVolume. As usual you can download the completed project instead of creating it by hand. Use your imagination when playing with the new VirtualVolume features of REALbasic 4.5. There are many useful possibilities for using this feature:

  • As a kind of "virtual" resource fork
  • As a way to package your favorite skins in one file
  • As a database
  • As an archive for easy one-file backups
The cool part about the VirtualVolume is that you don't have to create your own weird file formats. You can put information together into one file using the standard text and binary file operations that you already know. Neat! Have fun and see you next week!






Please support ResExcellence by Visiting our Sponsors. One click makes a difference.


Download REALbasic and create your own software!

#!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP #!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP