Articles 3D Audio Custom Controls General RB Graphics Hacks Mac OS X Menus Novelty Printing REALbasic 2005 REALbasic 2006 Registration Resources Reviews Serial Speech Sockets XML Video Resource Links News Current News February 2006 January 2006 December 2005 November 2005 October 2005 September 2005 August 2005 July 2005 June 2005 May 2005 April 2005 March 2005 ![]() REALbasic for Dummies by Erick Tejkowski ![]() Learning REALbasic through Applications REALbasic for Macintosh REALbasic Cross-Platform Application Development
Older files are in Stuffit 5 or greater format. Newer files are ".Zip". Download StuffIt Expander |
|
Of all the great technologies available to Mac users, perhaps the most overlooked is that of the Clipping file. Clipping files permit you to store data in a file that can be viewed from the Finder. Furthermore, they are especially nifty, thanks to drag-and-drop. Text clippings are handy for quick storage of text data such as:
Of course, clippings can hold other kinds of data, but for now we will limit the discussion to text. Creating Text Clippings To create a text clipping, open your favorite text editor (even Simple Text will work here). Type a few letters, select the text, and drag that text to the desktop. The text becomes its own miniature file. Double click the clipping file in the Finder and it opens to reveal the text in a Finder window. While the text clipping is open, you may also copy the text to the clipboard. Resource Information Text clippings usually consist of two or three resources. The important one here, though, is the 'TEXT' resource. As you probably guessed, this is where the text of the clipping resides. So, what on Earth does this have to do with REALbasic? Armed with REALbasic and your knowledge of text clippings, you can create a miniature "database". REALbasic makes it easy to work with resources. Text clippings are already very versatile, but sometimes it is a nuisance to constantly open the clipping to view its contents. This example shows you how to keep tabs on your text clippings and make them even more useful than ever. Build the Interface To create the interface for this project, fire up REALbasic and open the Window1 Window Editor. From the toolbar drag the following into the window:
Add the Code To make the interface do something, double click Window1 to open its Code Editor. In the Open Event of the window, add this code: dim n,i as integer This code first looks for a folder named "Clippings" in the same directory as your application. If you haven't yet, create this folder now. This folder will be your storage place for text clippings. Next, the code loops through the items in the "Clippings" folder, looking for clipping files. When it encounters one, the file's name is added to the Listbox. Next, open the Code Editor to the Change Event of the Listbox and add this code: This code will fire each time a row is selected in the Listbox. When a row is selected, the code creates a FolderItem representing the particular Clipping file. This FolderItem's resource fork is then opened and the 'TEXT' resource is retrieved (resource # 256) and displayed in the Editfield. The code concludes by closing the resource fork. Finally, add code to the PushButton's Action Event : This code copies the text from the EditField to the Clipboard. Of course, you can also select the text manually and copy it using the traditional Edit->Copy menu. You gain this functionality for free with the EditField. Test and Build The last step is to test and build the project. Test it by selecting Debug->Run. When you are sure that everything works as expteced, select File->Build Application. Once you have finished building your application, add a bunch of text clippings to your "Clippings" folder and you gain instant access to the contents of each. The project is also compatible with Mac OS X, so you can create an Aqua version as well. If you are having troubles getting the code to work, you can |
||||
|
||||||||||||||||||||||||||||||||
Maintained by the Staff of ResExcellence. This entire site ©1997-2006 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement.
[an error occurred while processing this directive]