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 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.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 1.1

COLUMN

Using the Declare statement

Issue: 1.1 (August/September 2002)
Author: Thomas Reed
Author Bio: Thomas Reed has been programming as a hobbyist for more than 20 years, and fell in love with the Mac in 1984.
Article Description: Accessing OS routines with declare statements
Article Length (in bytes): 12,165
Starting Page Number: 30
Article Number: 1007
Resource File(s):

Download Icon 1007.zip Updated: 2013-03-11 19:07:55

Related Web Link(s):

http://developer.apple.com/techpubs/
http://developer.apple.com/sdk/index.html
http://homepage.mac.com/everyday/code/downloads/TBFinder.sit

Excerpt of article text...

The Mac OS has always been nice to look at, but many folks don't know about the power under the hood. REALbasic sometimes suffers from the same misconceptions, but like the Mac OS, the power is there. In this column I'm going to talk about one way to get "under the hood" in REALbasic: using Declare statements.

A Declare statement allows you to call system routines, enabling you to do things for which REALbasic doesn't have built-in support. For example, a Declare statement can call Process Manager routines from the Mac Toolbox to get information about currently running applications. This information is not available through any native REALbasic classes or methods.

Instead of repeating the information found in the REALbasic documentation regarding Declare statements, I'll assume throughout this article that you're familiar with it. The discussion will also be limited to accessing Mac Toolbox routines; using Declare statements to access system routines under Windows is beyond the scope of this article.

Building a Declare statement is the first step in calling a Toolbox routine. To do this you first need to know which system routine you want to call and how it's called. You can find documentation for the various Toolbox routines on Apple's web site at http://developer.apple.com/techpubs/. Raw C function declarations can be found in the "CIncludes" folder of the Universal Interfaces. The Universal Interfaces can be found at http://developer.apple.com/sdk/index.html.

Once you have decided which routine to call, you need to translate the C function declaration into a REALbasic Declare statement. Let's start with a fairly simple example: suppose you want to call the GetSysBeepVolume function. Its C function declaration is:

OSErr GetSysBeepVolume(long *level)

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