TweetFollow Us on Twitter

Hunk Mgr, Word Sol'n
Volume Number:6
Issue Number:11
Column Tag:Kelly's Corner

The Hunk Manager and Word Solution

By Dave Kelly, MacTutor Editorial Board

Hunk Manager Extends the Toolbox

The Hunk what? It’s the Hunk Manager, a new way to extend the capabilities of the Macintosh toolbox. Actually, the Hunk Manager is an ingenious way to get around some age old problems. As you’ll see, the Hunk Manager should have been made a part of the Macintosh toolbox from the beginning.

Problem #1: the number of resources in a single resource file is limited to 2727. Although the desktop manager overcomes this limitation, most users aren’t using it. You can refer to tech note #141 for a description of this limitation.

Problem #2: Apple has repeatedly warned (Refer to TN#74 and TN#203) that the resource fork of a file should never be used for non-resource data. In spite of all the warnings, some programmers still use the Resource Manager as a database. The Resource Manager is flexible, easy to use, it provides disk based I/O without extra calls, data can be extracted by either name or ID number, the data is stored transparently so the caller can pretend the data is always available. But, when these advantages are overused, the Resource Manager will become slow and unusable. As TN#203 says: “ the TANSTAAFL (There Ain’t No Such Thing As A Free Lunch) philosophy applies to the Resource Manager as well”.

The Hunk Manager takes a big bite out of the TANSTAAFL philosophy. Since the Hunk Manager was modeled after the Resource Manager, you can have your cake and eat it too! It provides an easy way to store and retrieve “Hunks” of data of arbitrary size and structure. You can store data in various Hunk types, in much the same way that the Resource Manager stores resources of different types. The Hunk Manager allows an unlimited number of records of any size, ultra-fast B*-tree indexing, and full file sharing.

The primary difference between the Hunk Manager and Resource Manager is that the Resource Manger stores data in the resource fork and the Hunk Manager stores data in the data fork. This eliminates the restrictions on size, speed, and access without sacrificing flexibility. Because the Hunk Manager calls are very similar to Resource Manager calls, most programmers already know how to use the Hunk Manager.

Hunk Manager calls are patterned after the structure of Resource Manager calls with only a few minor differences. You can’t access hunk data by name, only by type and ID number. This would be a welcome improvement, but not a necessity. The hunk data is indexed in the data fork with a B*-tree index located within the hunk file. An entry is created within this index for each hunk when it is added to the file.

The Hunk Manager is available with Multi-user support for an additional cost. Fields are contained in the hunk file data structure for determining if the file is shared or not. In a shared environment, the Hunk Manager operates like a bulletin board, allowing hunks to be added, created, changed, or removed a hunk at a time by anyone sharing the file.

The Hunk Manager is provided as a linkable object code library with a 20 page manual. If I didn’t know better I would have thought the manual was already a part of Inside Macintosh. The style and format is consistent with the style and format you’re used to seeing in Inside Macintosh.

I’ve included a demo I’ve written to that shows the similarity of the Hunk Manager and Resource Manager. The demo is found on the source code disk for this month. My demo allows you to create a hunk file, add data to it, view the data, sort the data, and add the sorted data to the hunk. It doesn’t really do much, but should give you an idea of the Hunk Manager.

Now for the good news the Hunk Manager is now available for MPW C, MPW Pascal, Think C, and Think Pascal. This means that nearly every programmer can use the Hunk Manager in his own programming environment. Also, after buying the Hunk Manager, no additional royalties are required. The only requirement is that you must put the Gettys Group’s copyright notice on your product.

You can watch for additional features to be released in upcoming versions of the Hunk Manager. These include: MS-DOS compatibility, automatic data compression, and automatic data encryption. Even without these additions, the Hunk Manager is a valuable tool which should be added to your library.

The Hunk Manager is available from:

The Gettys Group

401 E. Illinois Street, Suite 600

Chicago, Illinois 60611

312-836-4222

FAX: 312-836-4220

Price: $295 Single User and #395 Multi-User.

No additional royalties are required.

No copy protection.

Word Solution breaks the 32K Limit!

Have you ever tried to write a “real” word processor as a part of your application? That’s right, a full featured word processor to supplement the application you are writing. It’s not too hard to use Text Edit calls to create a simple editor, but Text Edit is limited. First, Text Edit only supports up to 32K of text. In addition, you can only have one font, one font size, and one style for the whole document. Besides, you’ve been warned not to abuse the managers (Tech note #203). The TextEdit package is not a database. If you have tried to overcome these limitations, you probably spent hours of time (6 months or more) with results less than desirable. It’s very likely that you don’t have that kind of time to spend on the text editing portion of your application; after all, the application isn’t a word processor, that’s only part of it.

There is a word solution. DataPak Software has released (originally released in May 1990) Word Solution Engine, an object code module that adds full featured word processing routines to your application. WS-Engine is the result of years of development. Years of development usually means years of headaches. As the author/developer, Gary Crandall says, “Creating good text editing on the Mac is a stark nightmare, to say the least”.

“Just when you think you have it solved, you try handling more than five lines of text and it’s DOG CITY. What’s worse, your word-wrapping, font changes and mouse-dragging routines become so complex you wake up in the middle of the night screaming and being chased by animated bomb screens, chanting ‘ERROR ID=02, ERROR ID=02 ...!’” At this point you should be reminded that re-inventing the wheel could cost you much more than the mere $300 that WS-Engine costs.

WS-Engine primarily supports MPW Pascal, MPW C, MPW Assembler, Think C, and Think Pascal. That takes care of the most popular environments. There are two ways you can use WS-Engine: 1) you can use the linkable object code, or 2) you can use the res object which runs independent of your compiled code. You could use the res object with other languages than mentioned above because it resides in a separate resource file. The linked object file is preferred because it can be included in your compiled code.

A typical THINK Pascal 3.0 project requires the linked object file, WS.Linked.a.o, and the WS interface file, WSIntf.p. Other files needed would depend on your own application and which routines in the WS Engine you actually use (for example: you don’t need color stuff if you’re not using it).

The details of data structures and procedure/ function calls are described in a 49 page (8 1/2 by 11) manual. The routines are presented in Pascal format to maintain compatibility with Inside Macintosh. Examples of most of the calls are available in the Demo program in both C and Pascal. The demo is a nearly complete “real” word processor. There are a few bugs in the demo code, but it clearly displays the capabilities of the WS-Engine. The demo also demonstrates the “Rulers” add-on package that provides paragraph formatting (various tab stops including decimal tab, tab leaders, paragraph borders and variable line spacing). The manual is also available on the disk and can be printed out using a word processor built with the WS Engine.

Features

In summary, the WS-Engine includes these and other routines:

• Getting/Setting Text - for inserting raw text into an editing structure and getting the selected text.

• Display - used to display text given a WSHandle. Supports off screen bitmap.

• Events, Mice and Keys - responds to events to perform “intelligent” handling of mouse and keyboard events

• Changing Text Format - used to change the font, style, point size, or foreground color (Color Quickdraw) of multiple areas of text.

• Cut, Copy, Paste - handles cut, copy, and paste to the Scrap (includes undo)

• Selection Ranges & Scrolling - highlighting of the text and smooth text scrolling.

• Finding Screen Points & Words - Use this to find words (for Search & replace) and points (pixel positions).

• I/O & Printing Support - packs a WSHandle into a single continuous data stream to allow easy saving of editing structures to files or resources. Handles printing of text that falls within a specific rectangle.

• Customizing Text: “UserStyles” - used to define special text characteristics such as text width or drawing special characters, etc.

• UserStyle Maintenance - maintains the “UserStyles”

• Low-Level Hooks - used for customized text displays.

It is obvious to even a casual programmer that WS-Engine would be a big time saver to anyone that requires word processing. I recommend the object code version. The source code version is much more complex to use and the extra expense is not worth it.

DataPak Software was founded in 1983 and has been developing for the Macintosh since that time. They specialize in developer engines such as Word Processing, Object, and Visual. Object Engine handles drawing of Quickdraw objects (MacDraw like) from your application. Visual allows a developer to create an icon based interface into an application. Other products include: the Printer Interface series, Executive Office, Graphic Writer, Mac-Jack and others.

Word Solution Engine is available from:

DataPak Software, Inc.

9317 N. E. Highway 99, Suite G

Vancouver, Washington 98665-8900

(206) 573-9155

FAX: (206) 573-9269

Orders: (800) 327-6703

AppleLink: D0142

Object Code: $300.00 (introductory price)

Source Code: $4500

The Rulers add-on is $170 (object code).

F.Y.I. Department

by Dave Kelly

Note: Source code files accompanying this section are located on MacTech CD-ROM or source code disks.

The introduction of color to the Macintosh brought developers new capabilities and new problems. Some capabilities brought problems which required information which was not available to the average developer. Accessing the video card is one of these kind of problems until now.

Developers often ask “How can I change the depth from my application like the Monitors cdev does?” Apple has given in to these requests in the form of Technical Note #276: Gimmie Depth Or Gimmie Death.

The following program demonstrates the two new functions, SetDepth and HasDepth as described in the tech note. If you have the tech note, no explanation is required.

Listing:  ChangeColorDepth.p

program ChangeColorDepth;
{based on Macintosh Technical Note #276}
{MacTutor, October, 1990}
{by Dave Kelly}
 var
 someResult: integer;
 gd: GDHandle;
 done: boolean;
 oldDepth, newDepth, Depthavailable, whichFlags, newFlags,     
 oldFlags, i: integer;
 monitortype: str255;

 function SetDepth (gd: GDHandle; newDepth, whichFlags, newFlags: integer): 
integer;
 inline
 $203C, $000A, $0013, $AAA2;  { Move.L #$000A0013,D0}
 {_pMgrDispatch}
 function HasDepth (gd: GDHandle; newDepth, whichFlags, newFlags: Integer): 
integer;
 inline
 $203C, $000A, $0014, $AAA2; { Move.L #$000A0016,D0}
 {_PMgrDispatch}
begin
 showtext;
 gd := GetMainDevice;  {this gets the graphics device correctly as it 
should.}
 whichFlags := 1;  { indicates that only one bit on newFlags is important}
 oldDepth := BitAnd(gd^^.gdmode, whichFlags);
 oldFlags := BitAnd(gd^^.gdflags, whichFlags);
 newDepth := 32;
 for newDepth := 32 downto 1 do
 begin
 Depthavailable := HasDepth(gd, newDepth, whichFlags, newFlags);
 if Depthavailable <> 0 then
 begin
 leave
 end;
 end;
 if oldDepth <> 0 then
 newDepth := 1;
 if oldFlags = 0 then
 newFlags := 1
 else
 newflags := 0;  { clears the gdDevType flag in the device record (0=monochrome, 
1=color).}
 if newflags = 0 then
 monitortype := ‘monochrome’
 else
 monitortype := ‘Color’;
 Depthavailable := HasDepth(gd, newDepth, whichFlags, newFlags);
 if Depthavailable = 0 then
 writeln(newDepth, ‘-bit depth ‘, monitortype, ‘ is not supported’)
 else
 begin
 writeln(newDepth, ‘-bit depth ‘, monitortype, ‘ is supported’);
 someresult := SetDepth(gd, newDepth, whichFlags, newFlags);
 showtext;
 if someresult <> 0 then
 begin
 writeln(‘The result was not successful’);
 writeln(‘The result=’, someResult);
 end
 end;
 writeln;
 writeln(‘Click the mouse to continue ’);
 repeat
 done := Button;
 until done;
end.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but new, Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.