Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 19 in printed book and digital formats -- plus a one-year subscription (beginning with 20.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 2.3

COLUMN

From Scratch: Using StocksSocket in an Application

Issue: 2.3 (December/January 2003)
Author: William Leshner
Author Bio: William Leshner has been programming for twenty years and programming Macs for ten. He has spent a good deal of the last several years building REALbasic applications, including KidzMail, ResPloder, and several plugins and utilities.
Article Description: No description available.
Article Length (in bytes): 10,309
Starting Page Number: 40
Article Number: 2319
Resource File(s):

Download Icon 2319.zip Updated: 2013-03-11 19:07:57

Related Link(s): None

Excerpt of article text...

This is the third article in a series of three articles in which we are creating StocksSocket, a subclass of HTTPSocket that fetches stock information from a NASDAQ XML feed. In the first article we looked at how to subclass HTTPSocket to create StocksSocket and how to use StocksSocket to get stock information. In the second article we talked about how to parse the XML information we get back from the server. In this article we are going to see how to put StocksSocket to use in a simple application.

Stocks, The Project

"Stocks" is the name of the application that we will build on top of StocksSocket. Stocks is pretty simple; it consists of an EditField to enter comma-delimited stock symbols, a "Get" button to initiate a stock fetch, and a ListBox to display the results. We will only display the symbol, last price, and price change of each stock in the ListBox. We will add two simple enhancements to Stocks. The first enhancement is the ability to fetch stock information automatically every five minutes. The second enhancement is the ability to display each row in the ListBox in either red or green, depending on whether a stock is up or down.

We will begin Stocks with a blank REALbasic project. At the top of the blank window place an EditField, a PushButton, and a ChasingArrows control. Directly below those three controls place a ListBox. I like to name my controls as soon as possible so I don't forget and end up with a bunch of controls with similar names. I've named the main window "StocksWindow". I've named the EditField "QueryField", the PushButton "GetStocksButton", the ListBox "StocksListBox", and the ChasingArrows (yes, name that too) "ActivityIndicator".

The ListBox needs a bit of setup in the properties window. It will have three columns, so set its ColumnCount to 3. To set the column headings, enter "Symbol", "Last Price", and "Change" into the InitialValue property, each separated by a tab.

...End of Excerpt. Please purchase the magazine to read the full article.


Errata (2004-03-15)

Unfortunately, it appears that NASDAQ has shut down the stock feed that StocksSocket queries for stock information. I have yet to find a suitable replacement. The examples and code in these articles are still valuable, but they will no longer work to fetch stocks information. If I discover a replacement for the NASDAQ feed, I will update this page with the new information.