Now we will learn how to do things with the address book. Especifically, we will learn how to print and how to sort the addressbook.





An addressbook is a fairly complex structure. It contains several contacts, and each one has an associated name, address and so on.





Hashes are a generalization of arrays. Instead of only permitting integer indices, as in array[3], hashes allow any object to be used as an "index". So, you can write hash["name"]





An iterator is a special kind of method. It is a method that lets you access items one at a time.





This is all very nice, but can I do anything cool with arrays? You sure can. Follow this tutorial and ou will find out how.





You are already familiar with a couple of Ruby classes (Integer and String). The class Array is used to represent a collection of items.





There are just a couple more things that we should do with our AddressBook class.





In this section we are going to add our very own iterators to the class AddressBook. We will create two iterators, AddressBook#each and AddressBook#each_address, which can be used as usual:





he first step is very simple. AddressBook has an array which contains all our contacts. We will not use attr_accessor because we don't want the user to access this array directly. We will write our own access methods.





Now we are ready to create our very own Address class. Let's start simple. Let's start with an address that only contains the "street" field.





Pick a cell, any cell. Ostensibly, this tutorial is about using code to select a cell of a string grid at run time. Along the way, some more generally important material arises concerning using references to Delphi created objects, e.g. the object in "sender" arising from Delphi created event handlers.





Tutorial written and tested in Delphi 2, on a Win98 machine, but the code should be pretty generally applicable. You can download the sourcecode and some other stuff.





Tutorial written and tested in Delphi 2, on a Win98 machine, but the code should be pretty generally applicable.





"DLL" stands for "dynamic link library". When a programmer has something of general usefulness to other programmers, he or she may choose to "package" the material in a dll. Users must have both the dll and the program that uses the things in it on their system, but, once they do, using the program which uses the things in the dll works just like using any other...





This tutorial is based on a newsgroups post from Mark Wilkinson... thank you, Mark! This tutorial will be short on explanation and not much longer on program... because Delphi makes things so easy!!













