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

Create a Stock Ticker Part I
08-30-01




This week we'll begin the process of creating a stock ticker. There are already many stock tickers and stock quote web sites out there, but hopefully this project will give you some other ideas for what you can do with REALbasic. This project will appear in two parts. This week (Part 1), we will build a project to retrieve a single quote. Next week, we'll integrate the stock information into a fancy display.

For this project, I am going to try something new for the RB section of ResExcellence. In the past, I listed all tutorial code as text. Starting today, I am going to begin using graphics to display the code. My original intent was that you could copy and paste the code as you worked through the tutorial. Since you can download the completed code anyway (which I suspect most of you do), screenshots of the code offer some advantages. First, the source code will more closely match the REALbasic you use (correct colors, spacing, etc...). Secondly, it saves me a lot time, which can only mean more time for tutorials and REALbasic news for you. Now, on to the tutorial!

Preparation

Before you get started coding, download Dan Vanderkam's HTTPSocket Class. We'll use it to handle the transfer of stock data from the internet. Once you have it downloaded and unstuffed, launch REALbasic and drag the file named "httpSocket (complete)" from the Finder into the Project Window, like so:

08_30_prj.jpg (7k)

Don't worry that the name changes to "httpSocket" in the Project window; this is normal behavior.

Build the Interface

Open the Window Editor by double-clicking Window1 in the Project Window. Drag httpSocket from the Project Window into Window1. Next, add the controls listed below, making sure to change any Properties listed in the "Settings" column.

Control Settings
Chasing Arrows Visible : Unchecked
EditField Name : HTMLField
MultiLine : Checked
EditField Name : StockHTMLField
MultiLine : Checked
EditField Name : SymbolField
LimitText : 4
StaticText Name : quoteDisplay
Color : Red
PushButton Name : PushButton1

You may rearrange the interface however you see fit, but it might look something like this:

08_30_interfaces.jpg (14k)

Add the Code

The idea behind this tutorial is that we will download a web page using the httpSocket and then retrieve the information we want from the page. For our example, we will use Yahoo's stock lookup. For an example, check Apple's stock (AAPL). Look closely at the URL. The stock symbol is embedded in it. Once you have looked at the web page, save it as an HTML file and open it in a text editor. If you are HTML-literate, scroll down and find the table where the stock quote is located. This is the data we want to retrieve from the page.

The code this week will:

  • Download a file from Yahoo (using Dan Vanderkam's httpSocket)
  • Display it in an EditField (HTMLField)
  • Display the chunk of text we want from HTMLField in another EditField (StockHTMLField)
  • Parse the text in StockHTMLField to retrieve the stock quote

Before you add any code, create a new Property in Window1, like so:

08_30_newproperty.jpg (9k)

Now, the code. To begin, open the Code Editor for Window1 and navigate to its Open event. Add the following code:

08_30_window1open.jpg (4593bytes)

Next, navigate to the Action event of PushButton1 and enter this code:

08_30_pushbtn.jpg (31k)

Finally, open the DLFinished event of httpSocket1 and finish off the project with this code:

8-30_code2.jpg (120k)

Conclusion

That's it! Test the project and when you're happy with the results, build the final application. To spruce things up, feel free to resize Window1 to conceal the EditFields. As usual, you can download the application and completed project.






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