#!/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.

Build an iTunes Skinner
07-26-01




A popular new addition to the ResExcellence site is the iTunes Skins section. To install any of these skins within iTunes, you must:

  • Open the skin and the iTunes application using ResEdit
  • Copy the resources from the skin to the iTunes application.

Although this is pretty much a no-brainer, we can make it even easier using REALbasic.

This week we'll whip up a quick hack that makes this process a little more streamlined. It's not the flashiest project, but maybe it will give you some ideas for other useful hacks you can create with REALbasic.

Building the Interface

Launch REALbasic and open the default window, entitled Window1. Add a Listbox to the window. We will display the resources types from the skin file here. Feel free to spruce up the interface any other way you see fit. A sample interface might look like this:

07-26_interface.jpg (14k)

Define the File Types

Since we want to work with two kinds of files (the skin file and the iTunes application itself), we need to describe them to REALbasic. Select Edit->File Types... and define two types of files:

07-26_filetypes.jpg (13k)

For the ResEditFile file type, enter the following infortmation:

07-26_reseditfiletype.jpg (18k)

For the iTunes file type, enter this data:

07-26_itunesfiletype.jpg (18k)

Add the Code

Now that we have built the interface and defined the file types our project will use, it's time to add the code. The main idea behind this project is to copy all of the resources from the resource fork of a ResEdit skin file to the resource fork of iTunes. Right now would be a good time to make a backup copy of iTunes, since you will be modifying the iTunes application.

To simplify matters, we will permit a user to drag a skin file into thw interface window. To make the window drag and drop aware, add this code to the Open event of Window1:

me.acceptfileDrop("ResEditFile")

Finally, add this code to the DropObject event of Window1:

dim i, j, rcount, thisresourcenumber as integer
dim fSkin, fiTunes as folderItem
dim rfiTunes, rfSkin as resourceFork
dim rtype, junk, s, thisresourcetype as string

//is "obj" a FolderItem?
if obj.folderItemavailable then
  //the folderitem of the skin file
  fSkin = obj.FolderItem
  junk = chr(0)+chr(0)+chr(0)+chr(0)
  fiTunes = GetOpenFolderItem("iTunes")

  //first loop through all resource types in the
  if fiTunes<>nil and fiTunes.exists then
    if fSkin.exists then
      //open the skin's resource fork
      rfSkin = fSkin.openresourcefork
      //open the iTunes resourcefork
      rfiTunes = fiTunes.openresourcefork
      
      //clear listbox
      listBox1.deleteAllRows
      
      //we don't know how many types
      //of resources there are

      //we will assume that there are no more
      //than 10,000 resource types

      for i=1 to 10000
        rtype = rfSkin.ResourceType(i-1)
        if rfSkin.ResourceType(i-1)<>junk then
          //we found a resource type,
          //so add it to the list

          listBox1.addrow rfSkin.ResourceType(i-1)
        end if
      next
    end if
    
    if listBox1.listcount>0 then
      //loop through all resource types
      for i=1 to listBox1.listcount
        thisresourcetype = listBox1.list(i-1)
        rcount = rfSkin.resourcecount(thisresourcetype)
        //loop through all resources of this type
        for j=1 to rcount
          //find resource number for this resource
          thisresourcenumber = rfSkin.resourceid(thisresourcetype,j-1)
          //retrieve the resource
//from the skin source file

          s = rfSkin.getresource(thisresourcetype, thisresourcenumber)
          //copy the resource to iTunes
          rfiTunes.AddResource(s, thisresourcetype, thisresourcenumber, "")
        next//j
      next//i
    end if
    
    //close the resource fork of the skin and iTunes
    rfiTunes.close
    rfSkin.close
    
  end if//fiTunes<>nil and fiTunes.exists
end if//obj.folderItemavailable then

Conclusion

As usual, you can download the project and completed application. If you are an astute ResExer, you may realize that this project could be easily modified to work with a number of ResExcellence hacks and improvements. This project lends itself well to any instance where you need to copy resources from one file to another. Happy experimenting!






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