To order Alpha Four or Alpha Five, click above to go directly to Alpha, or call 800.451.1018 or 781.229.4500

             
Alpha Newsletter

Monday, July 1, 2002 Issue 5   VOLUME 1 ISSUE 5  
HOME
TOPICS
News & Notes
Tips & Tricks
Tech Corner
Xbasic CliniX
CONTENTS
Version 5 is REALLY Close!!
Alpha Plans Integration between Alpha Five and QuickBooks
Xbasic CliniX
Get a Handle on Alpha Five's Files
Understanding Referential Integrity
Bubble Help in Alpha Five version 5
Define a Starting Position for Labels
Auto-Increment Improved Again
Custom Toolbars
Barcoding in Alpha Five - Part 1
Solving a Word Processor Challenge
Pass the Objects Please
Pass the Objects Please
TC069
by Jim Chapman

An object in Alpha Five, is a software module that resides in memory. In the Alpha Five environment just about everything is an object; Alpha Five itself is an object; tables are objects, fields, forms, and controls are objects. This may seem just a matter of semantics, but it goes deeper. Think of an object as a small self contained software unit embedded within the larger program. Many objects are also containers in that they can contain other objects, such as a form object that contains a button object. These software modules (objects) have built in tools called methods. An objects methods are very much like functions, the difference being that these object methods are available only within the context of an object. Objects also have built in information about themselves, called properties. Object properties are basically variables, internal to the object, that hold values that tell us about the attributes of the object. Attributes such as the objects name, color, placement on the screen, etc. An objects methods usually perform work on or return information about the object. Within the context of an Alpha Five script, we can call on this embedded object, via its properties and methods, to retrieve information about the object or perform work upon the object. Many of these objects are created automatically when Alpha Five loads. Others are created based on a users actions, and still others can be created only by the Xbasic programmer. It is important to remember that these object may or may not be visible on the screen. Many objects reside only in the memory of the computer and are never displayed on the screen. These invisible objects can only be manipulated via the Xbasic scripting language.

If you navigate to the Xbasic script editor you can view the Xbasic explorer. If you expand the 'Objects' level, you will find two sub-levels of objects displayed, system objects and windows (which are the objects created by a users actions or by an Xbasic command). The system objects shown are those objects automatically created whenever Alpha Five is started. These system or build-in objects are always available to the Xbasic programmer. One of the issues I struggled with when I first began working with Xbasic was the Xbasic manual's references to the built in table object. The built in table object isn't a 'real' table in the sense of being a repository of data. It is a software object that's created when Alpha Five starts, and remains available to us though out the time Alpha Five is running. This software object exposes (provides) it's methods to us to do such things as open real data tables in the computers memory that are only assessable via Xbasic. One of the most often used methods of the built in table object is the 'Table.open()' method. It's important that you understand the concept of objects, but in a practical sense you could view the Xbasic syntax 'Table.open()' as just a function that was always available to you to open a new instance of a table.

Different types of objects will have different types of properties and methods. Think about two objects that we are familiar with in everyday life, vehicles and buildings. These two different types of objects would have some properties in common, but they would also have properties that are distinct. A property (attribute) of vehicles would be color. A building would also have a color property. However a building would have a levels property: it could be a one story, two story, or more. A vehicle wouldn't have a levels property, but it would have a wheels property. The value of a motorcycle, (a type of vehicle), wheels property would be '2', while a passenger cars wheels property would be '4'. A building on the other hand would not have a wheels property.

Alpha Five will allow you to see the methods and properties of both the built in Table object, and a user defined Table object. Open up the Xbasic code editor. Click on the Interactive tab of the code editor. As the built-in table object is always available while Alpha Five is running, we will take a peek at it first. Type the following into the Interactive tab of the code editor and then press the enter key to execute the code:

?table.this

Alpha Five presents a list of the methods and properties of the built-in table object.

To view a user defined table object, first clear the Interactive pane by selecting all the contents with the mouse and then press the delete key. You will need to know the name of an existing table you have created within the database you are working with. I'll assume the name of this table is "MyTable". Type the following into the Interactive pane of the code editor, substituting your real table name in place of "MyTable" and pressing the enter key after each line:

T = table.open("MyTable")
?T

Alpha Five gives you a behind the scenes look at a user created table object. After you've inspected this, it is appropriate that we close this table object, otherwise it will exist in memory, in essence our own little memory leak, until the database is closed. Close the table by issuing the following command in the Interactive window:

T.close()

If you are new to Xbasic, I hope this short introduction to Alpha Five objects has peaked your interest in the most powerful and flexible tool Alpha Five has to offer - Xbasic. Try it, you'll like it.
[PRINTER FRIENDLY VERSION]

LETTERS

There are no letters for this article. To post your own letter, click Post Letter.

Powered by iMakeNews.com