Feedback Search Top Backward Forward
EDM/2

The Codesmith's Library

Written by Carsten Whimster

 

Introduction

The Codesmith's Library is a monthly column which focuses on development oriented books and materials. The column is from the point of view of an intermediate PM C programmer and intermediate REXX programmer. Pick up whichever book strikes your fancy, and join the growing group of people following our PM programming columns. I have reviewed a number of beginner's books, and will try to concentrate a bit more on intermediate techniques and special topics from now on.

Please send me your comments and thoughts so that I can make this column as good as possible. I read and respond to all mail.

OS/2 Programming is an introductory book to PM programming. It was released just around the same time as OS/2 2.1, so it is slightly out of date, like almost all PM books at the moment.

Errata

Well, I have now been working on my POVEd program (an editor tailored to POV-Ray) for some time, and have picked up a basic proficiency, and a few intermediate techniques, so I now consider myself an intermediate PM C programmer. I still have loads to learn, but I won't be stumbling over really basic concepts any more.

OS/2 Programming - Your Fast-Track Guide to OS/2

This book is aimed at the intermediate skill level, it says on the back. Does that mean intermediate programmers, intermediate C programmers, intermediate OS/2 users, or what? A little clarification would be helpful for the buyer. In any case, I would rank it as a beginning OS/2 PM C programmer book. Here are the chapters:

Part One: Introduction to OS/2 Programming
1. OS/2: An Overview
2. Fundamentals of OS/2 Programming

Part Two: Programming the Presentation Manager
3. Presentation Manager Programming Overview
4. Processing Messages
5. Message Boxes and Menus
6. Dialog Boxes
7. Control Windows
8. Icons and Graphics

Part Three: Exploring the API
9. An Introduction to Multitasking
10. Serialization and Inter-Process Communication
11. File I/O
12. Creating and Using Dynamic Link Libraries

Index

The layout of the book is quite good, although I think that I prefer the non-PM stuff at the beginning, not at the end. That way, the sample programs can include these features where appropriate. Having said that, this layout works too.

Chapters 1 and 2 are fairly straight forward, and there really isn't much to say, other than the fact that the introduction is fairly comprehensive in explaining what a PC is, what OS/2 is, and a bit about the history of both. The OS/2 fundamentals chapter goes through the OS/2 C programming environment a bit, and explains how the header files work, what a DEF file is, what C prototypes are, how the OS/2 API is broken down, and a few other minor background issues. There is no real detail here, just a brief overview.

Section two moves into actual programming, and this is done in the classical way of explaining mouse, windows, message queue, and so on, and then giving a skeleton program. This book concentrates on CSet++, by the way, so Watcom and Borland users are on their own here. Unfortunately, I am not crazy about the variable naming style that the authors use (e.g. hand_ab for the application's HAB), but that is a question of taste. The skeleton is explained, and so it goes. A plus here is the explanation of the DEF file, and what it does for you. This explanation is concise and clear, and I now know what a DEF file is for <grin> The next chapter deals with messages, and the macros are presented for converting MPARAMs. The device context and the presentation space are loosely explained, and a few GPI functions and constants are introduced to allow colored text to be used. Key presses are explained, and how to catch them in the message loop. Mouse messages are briefly introduced as well. Finally, a custom message is shown implemented. All fairly brief, and well written.

Chapter five concentrates on message boxes and menus. It is nice to see the message box covered well, because as you get better, they are excellent for quick-and-dirty debugging, and they are also very useful when you are just beginning to flesh out the interface of a larger application. At least, if you attach message boxes to everything, you know that the gears of the interface are working. Menus are, of course, the most used part of the PM interface, and deserve a good treatment. They get a good treatment here, including how to make accelerator keys work with them.

Chapter 6 introduces dialog boxes. They are presented mainly as an information gathering tool, in accordance with the CUA guidelines. Some fairly predictable examples are given, but no great amount of writing is spent on this.

Control windows are next. Unfortunately, and in accordance with the apparently pervasive OS/2 programming book authors' philosophy, only a few are shown in detail, and the rest are skipped over lightly. The two that are given more than just a cursory example are list boxes and sliders. Whether they represent all the others well is up to the reader to decide.

Icons and graphics form the next stop along the bumpy route of learning the PM API. How to use the system defined icons and pointers is shown, followed by how to define your own, and use them instead. Again, good programs, but a little short.

The final section is called "Exploring the API", but perhaps this section might be called "Kernel Programming" more accurately, since only non-PM calls are demonstrated in this section. Threads and sessions are each given a decent introduction, along with how to wait for something the right way.

It is only natural to introduce concurrency issues after waiting has been mentioned, and so the next chapter discusses semaphores, and critical sections. The explanations are lucid, and good, but again the programs are a little on the skinny and functionally challenged side. IPC is also introduced in this chapter, with explanations and examples of shared memory and pipes.

File input and output is briefly treated in chapter eleven, along with a brief introduction to system information, and how to obtain it.

The last chapter is on DLLs, and as you must expect by now, it is merely an introduction. It shows how to put a function into a DLL, and not much more.

Summary

This book is quite nice, and a good introduction to PM programming. Its main difficulty is the fact that it is slimmer than the competition. There are several other good books out there, which cover more, or cover the same in more detail, and which cost about the same. If this book were priced around the US$20-25 mark, it would be a good bargain. In spite of this, I quite like it. The code and commenting style isn't quite what I prefer, but the code examples are good, and are built up well. The choice of material is good, and the sequence of the material is good. It is a nice, easy introduction to the PM API, and has some nice tips and tricks. The motivation of the material is better than average.

I would like to see better coverage of the various control windows, but this accusation could be leveled at most introductory PM books.

I must say that I was a bit shocked to find that the book had no disk, and that the disk would cost US$24.95! For this price, a book should include a disk, and most do.

Overall, quite a nice book, but I have a feeling that most people will skip it, and pick up one of the other, larger books for about the same price. That is a shame, because this book has a lot to offer in the way of explanations. It really does need to come with the disk for free, though.

OS/2 Programming, Schildt and Goosey

  • Osborne, McGraw-Hill. ISBN 0-07-881910-5. US$30, CAN$40
  • Intended audience: Introductory PM C programmers
  • Mark: B+

Reviewed Books

Our Bookstore has reviews and links to Amazon for all books we have reviewed in the past, as well as several books waiting to be reviewed, and others which we recommend.