Carbonized Port of THINK Pascal TCL
Vik Rubenfeld, Pascal Developer
Ken Beath, Pascal Developer




Carbonized Port of
THINK Pascal TCL

by Vik Rubenfeld

UPDATE (10/27/02)

There is now an updated "TP TCL->CW Carbon TCL v1_3_1" package. This version contains an update, courtesy of Ken Beath, to the file cDocument.p, fixing a bug in support for default filenames.

NOTE: You will not find the file cDocument.p in the folder. The file appears when you run MultiDiff on the included patch file. Basically, this is an update to the patch file so that when you run MultiDiff on it, the new cDocument.p appears (along with the rest of Carbon TCL).

What is it?

This is a version of TCL that works with CodeWarrior's Pascal compiler for PPC. It is Carbonized to produce Carbon Applications for Mac OS X. For other information on TCL, check out the TCL at Pascal Central page.

The vast majority of the Carbonizing of TCL was done by Ken Beath. Ken, thanks for your great work on this.

Navigation Services

By permission of Bob Williams, this release of TCL includes Bob's excellent REWNavigationServices unit. REWNavServices has been modified to support TCL's SFNumTypes and SFTypeLists. TCL now uses it for support of Navigation Services. This unit is very well-designed and documented. Refer to the comments in the REWNavServices.p file for instructions on how to use it to access Navigation Services.

Requirements

This update requires TCL v1.1, or TCL v1.1.2, from your master disks which you received with Think Pascal.

Download

Click this link to download the Carbonized TCL Package.

Installing this Version of TCL

Start with a fresh copy of TCL version 1.1, or version 1.1.2, from your master disks. Put this copy in a folder by itself - you can name this folder whatever you want.

Launch the enclosed application, MultiDiff. Select Apply Diff from the File menu. Select the enclosed file called "Patch File for TCL 1_1" or "Patch File for TCL 1_1_2" in the Open File dialog. Next you will get a dialog that permits you to select a folder. Select the folder containing your copy of TCL 1.1, or 1.1.2.

MultiDiff will crunch away, updating your copy of TCL.

In my original copy of TCL 1.1.2, the file TCL.p is not a text file - it is in the internal Think Pascal QPED format. For this reason MultiDiff can't convert it, so I have enclosed the updated version of TCL.p with this package. Move it into the Core Classes folder after MultiDiff is finished.

That's it, you're ready to rock and roll.

Enclosed Project File

Enclosed is a project file, "TCL Carbon.mpc" which you can use to get started. It has all the preferences set properly for use with TCL. Use this project files to compile the TCL library. Then include the TCL library in your application's project file. A starter application project file is also enclosed.

The "CompilerVars.prefix" File

This file declares a number of compiler variables used in this version of TCL. Use it as the prefix file. You set the prefix file in the Pascal Language preferences dialog.

Please note in particular the following compiler variable statement contained in CompilerVars.prefix:

{$SETC OptimizeHierarchyIsOff = FALSE}

OptimizeHierarchyIsOff corresponds to the Optimize Hierarchy checkbox in the Pascal Language preferences. Set this variable FALSE if that checkbox is unchecked. Set it TRUE if that checkbox is checked.

Make sure to use this prefix file or to update your own prefix file with the compiler directives from "TCL Carbon.prefix".

Resource File

Revised the following lines to CPrinter.GetPrintRecord:

if (PrError <> noErr) & (gApplication.phase = appInitializing) then
Failure(PrError, CannotInitPrinterMessage);


On startup (when gApplication.phase = appInitializing) if the printer is not correctly installed, the application would quit with a mystifying error message. This puts up a message that clearly says the printer needs to be reinstalled.

A resource was added to the TCL resource file to include the string for this message. (STR# 1025, string #1). The revised resource file ("TCL Resources") is included.

Using Universal Interfaces

This version of TCL requires the Universal Interfaces, so if you are porting a TCL application from Think to CW, you will need to update your code to use the Universal Interfaces. The Universal Interfaces come with your CodeWarrior CDs. See the enclosed file, Porting to UPI FAQ v1.0, for information on preparing your application to use the Universal Interfaces.

Sane2FP.p

Many people using the Universal Interfaces for the first time have questions about what to use in place of familiar SANE calls such as Str2Num, Num2Str, etc., which are no longer supported. Sane2FP reimplements a number of commonly used SANE calls under the Universal Interfaces.

TCL UPDATE NOTES

Updated Object Names
--------------------
Some object names were changed to avoid conflicts with items named in the UPI's:

Cobject -> cTCL_Object
CWindow -> cTCL_Window
CTable -> cTCL_Table
CApplication -> cTCL_Application
CDocument -> cTCL_Document
CFile -> cTCL_File


File Access Variables
---------------------
cTCL_File now includes the following variable:

itsFileSpec: FSSpec;

in addition to the older variables:

name: Str255;
volNum: Integer;
dirID: Longint;


My largest contribution to this version of TCL was to integrate REWNavigationServices into TCL, and to update these cTCL_File procedures:

procedure Specify (aName: Str255; aVolNum: Integer);
procedure SpecifyHFS (aName: Str255;
aVolNum: Integer;
aDirID: Longint);
procedure SpecifyFSSpec (aFileSpec: FSSpec);
procedure SFSpecify (macSFReply: SFReply);

to use itsFileSpec if it is available, and the older vars if it isn't. When using the older vars, the methods now also fill in itsFileSpec.

cTCL_File.IFile now initializes itsFileSpec -- useful for checking if a file has been opened yet.

PROCEDURE cTCL_File.IFile;

BEGIN
itsFileSpec.vRefNum := -1;
itsFileSpec.parID := -1;
itsFileSpec.name := '';
END;

Note that procedure SFSpecify is not available in Carbon, because GetWDInfo, which it calls, is not supported in Carbon.

{$ifc TARGET_API_MAC_CARBON}
procedure SFSpecify (macSFReply: SFReply);
{$endc}

cBartender
----------
CBartender.ParseItemString has been revised to permit the # character to appear in a menu. If it is preceded in the resource file by a '\' character, the # character will appear in the menu. For example, 'A menu item with the \# character#100' will appear in the menu as:

A menu item with the # character

ConfirmClose
------------
ConfirmClose now returns a typed response

Declared a type ConfirmCloseResponses :

ConfirmCloseResponses = (ConfirmCloseOkToClose,
ConfirmCloseCancel,
ConfirmCloseDontSaveChanges);


This type is now used for the values returned by ConfirmClose.

SFTypes Extended to Support More than 4 File Types
--------------------------------------------------
Declared a new type, PtrToArrayOfOSTypes :

SFTypeListHandle = ^SFTypeListPtr;
SFTypeListPtr = ^SFTypeList;

- Redeclared SFFileTypes as a SFTypeListHandle .

- In cApplication.IApplication, dimension SFFileTypes for a default of 10 types.

- In cApplication.Free, dispose of SFFileTypes .

- Added a function, "cApplication.ResizeSfFileTypes " to redimension SFFileTypes for more types if needed.

- Added a function, "cApplication. GetNumberOfEntriesAvailableInSFFileTypes", to check the current size of SFFileTypes .

KEN'S NOTES

Here are Ken's notes on the mods he made to TCL:

About MultiDiff

This distribution is made possible by an application called MultiDiff, by Jon Watte. MultiDiff goes through a folder, examining all sub-folders and the files they contain, and updates all those files. MultiDiff has been widely used in connection with the port of the C version of TCL for use with CW. Thanks to Jon Watte for this indispensable app.

Version History: Carbon Version

October 27, 2002 - Version 1.3.1
June 16, 2002 - Version 1.3

Version History: Pre-Carbon Version
April 18 1996 - Version 1.1.2.1 - First release.
April 24 1996 - Version 1.1.2.2 - mods to CMenuDefProc.p to support PPC.
April 25 1996 - Version 1.1.2.3 - mods to MethTableUtils.p.
July 10 1996 - Version 1.2 - mods to CMenuDefProc.p,
cw_gluePPC.c, FW_Tearoffs.p, MethTableUtils.p, & CompilerVars.prefix.
TCL lib files updated. Starter App project files included.

Revisions to TCL were made by Marcel Achim of Metrowerks so that
it would compile using the CW compilers. I beta-tested this
version of TCL on a 100,000 line+ (not counting TCL) program, and
it seems to work just like TCL 1.1.2 did when compiled with Think
Pascal. Marcel even ported the exceptions-handling mechanisms for
both 68K and PPC.

A Note From Marcel
Marcel sent me email containing the following:

"I just did some coding, note that Metrowerks doesn't support TCL. I did it to test my compiler that's all but if it can help someone else that's even better."

Thank you, Marcel and Metrowerks, for CW Pascal, CW Object
Pascal, and CW PPC Pascal, and thank you Marcel for your great
contribution to the Pascal programming community with this
version of TCL.

Legal Notices

This package and its contents is made available to you an an "as is" basis. No warranty is made, either express or implied, by statute or otherwise, regarding this package - including TCL, this version of TCL, and the MultiDiff application - its quality, its performance, its merchantability, or its fitness for any particular purpose. All of the authors assume no liability for damages, direct or consequential, which may result from the use of this package or any of its contents.


Copyright © 2002 Vik Rubenfeld. All Rights Reserved.