TweetFollow Us on Twitter

Nov 95 Tips
Volume Number:11
Issue Number:11
Column Tag:Tips & Tidbits

Tips & Tidbits

By Steve Sisak, Contributing Editor

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


Two Screen MacsBug

One feature of MacsBug that I like is the "swap" command, which lets you leave a second monitor display the debugger (and punches it out of the desktop).

Then, if each DebugStr() ends in ";g" you will get an onscreen log of the last 10 or 15 breaks. I used this to track an elusive bug that would freeze my Mac and trash Macsbug memory... I could see which breakpoint went last.

Matt Slot

Informant in the Menu Bar

I do drivers, and you just plain can’t set a breakpoint in ADB completion routines (freezes the keyboard so MacsBug is worthless!).

So I throw one of the routines below into the routine to see when a piece of code gets executed.

What does it do? It "lights up" a bar (length dependant on screen resolution) in the menu bar. So if you DotToggle(300); you get a flashing short line in the menu bar.

[Leave this out of production code! Beware of using this on 24 bit color screens. Make sure that the value of where will not cause anything to be written into the alpha channel. Your best bet is to test with the screen that’s only 8 bits deep. -sgs]

void DotOn(long where) {
   long  *dot;
   dot = (long *)(LMGetScrnBase() + where);
   *dot |= -1;
void DotOff(long where) {
   long  *dot;
   dot = (long *)(LMGetScrnBase() + where);
   *dot &= 0;
void DotToggle(long where) {
   long  *dot;
   dot = (long *)(LMGetScrnBase() + where);
   *dot ^= -1;

Dave Fleck

Informative Cursors

One technique that I have used in the past where dropping into the debugger wasn't an option, and logging wasn't getting flushed in time/took too long, was to create a bunch of cursors numbering 00 - 99, and made a call to set the cursor and return the number of the previous cursor:

short oldCursor = setDebugCursor(15);
    (void) setDebugCursor(oldCursor);

This way when the machine froze, the cursor would tell me what routine it had frozen in.

Tom Kimpton

MPW Editor Primitives

The MPW Command Reference describes 32 editor primitives which may be attached to any key sequence using the SetKey command. While the SetKey command itself is useful, the list of editor primitives alone is useful to MPW script writers.

Though only documented for use with SetKey, editor primitives may be used like any other MPW command: in scripts, command aliases, or AddMenu items. There are a couple of advantages:

1) They only work on the active window and have sharply defined functions, you don’t have to remember any selection expressions or argument lists. Compare:



       Find • "{Active}"

2) They’re fast. I haven’t put a stopwatch to it, but you can see the difference immediately in running a script that uses the primitives and one that doesn’t.

The MPW Command reference lists these 32 primitives, the names of which should be self-explanatory:
































There are also at least five primitives that aren’t in the command reference:






I can understand why Apple might not want users to casually drop into MacsBug from an MPW script, but I wonder why they chose not to document the scrolling commands? Whatever the reason, you should obviously use caution when playing with undocumented features.

Lee David Rimar
Absoft Corporation

Once Bitten Twice Shy

HGetState does not return a valid handle state when you pass it an empty handle (one whose master pointer is NULL). Instead, it returns an error code, so before you call HGetState, be sure to check that the handle isn’t empty and execute an alternate code path if it is.

I was bitten by this because I was using HGetState to determine if a handle was to a resource, and the resourced had been purged, so HGetStaate returned an error code instead of the handle flags and I incorrectly thought the handle wasn’t to a resource.

This is documented in Inside Macintosh, Memory, p. 1-61, but it bears some repeating. Remember to check the error values returned by the toolbox calls.

Eric Schlegel


Community Search:
MacTech Search:

Software Updates via MacUpdate

Planet Diver guide - How to survive long...
Planet Diver is an endless arcade game about diving through planets while dodging lava, killing bats, and collecting Starstuff. Here are some tips to help you go the distance. [Read more] | Read more »
KORG iDS-10 (Music)
KORG iDS-10 1.0.0 Device: iOS iPhone Category: Music Price: $9.99, Version: 1.0.0 (iTunes) Description: ** Debut Discount: 50% OFF! Sale Price US$9.99 (Regular price US$19.99). Other all Korg apps are also 50% OFF until Dec 28! **... | Read more »
World of Tanks Generals guide - Tips and...
World of Tanks Generals is a brand new card game by the developer behind the World of Tanks shooter franchise. It plays like a cross between chess and your typical card game. You have to keep in consideration where you place your tanks on the board... | Read more »
TruckSimulation 16 guide: How to succeed...
Remember those strangely enjoyable truck missions in Grand Theft Auto V whereit was a disturbing amount of fun to deliver cargo? TruckSimulation 16 is reminiscent of that, and has you play the role of a truck driver who has to deliver various... | Read more »
The best GIF making apps
Animated GIFs have exploded in popularity recently which is likely thanks to a combination of Tumblr, our shorter attention spans, and the simple fact they’re a lot of fun. [Read more] | Read more »
The best remote desktop apps for iOS
We've been sifting through the App Store to find the best ways to do computer tasks on a tablet. That gave us a thought - what if we could just do computer tasks from our tablets? Here's a list of the best remote desktop apps to help you use your... | Read more »
Warhammer 40,000: Freeblade guide - How...
Warhammer 40,000: Freebladejust launched in the App Store and it lets you live your childhood dream of blowing up and slashing a bunch of enemies as a massive, hulking Space Marine. It's not easy being a Space Marine though - and particularly if... | Read more »
Gopogo guide - How to bounce like the be...
Nitrome just launched a new game and, as to be expected, it's a lot of addictive fun. It's called Gopogo, and it challenges you to hoparound a bunch of platforms, avoiding enemies and picking up shiny stuff. It's not easy though - just like the... | Read more »
Sago Mini Superhero (Education)
Sago Mini Superhero 1.0 Device: iOS Universal Category: Education Price: $2.99, Version: 1.0 (iTunes) Description: KAPOW! Jack the rabbit bursts into the sky as the Sago Mini Superhero! Fly with Jack as he lifts impossible weights,... | Read more »
Star Wars: Galaxy of Heroes guide - How...
Star Wars: Galaxy of Heroes is all about collecting heroes, powering them up, and using them together to defeat your foes. It's pretty straightforward stuff for the most part, but increasing your characters' stats can be a bit confusing because it... | Read more »

Price Scanner via

New MacBook Air 13-Inch and 15-Inch Coming At...
The Taipei, Taiwan based Chinese language Economic Daily News’s Xie Yili reports that major redesign of the MacBook Air, which currently dates back to October, 2010, is expected to be unveiled next... Read more
World’s First USB-C Adapter For MacBook Suppo...
Innergie, a brand of Delta Electronics, has announced its official release of the world’s first USB-C adapter supporting four DC output voltages, the PowerGear USB-C 45. This true Type C adapter... Read more
13-inch and 11-inch MacBook Airs on sale for...
B&H Photo has 13″ and 11″ MacBook Airs on sale for up to $120 off MSRP as part of their Holiday sale including free shipping plus NY sales tax only: - 11″ 1.6GHz/128GB MacBook Air: $819 $90 off... Read more
13-inch MacBook Pros on sale for up to $150 o...
Take up to $150 off MSRP on the price of a new 13″ MacBook Pro at B&H Photo today as part of their Holiday sale. Shipping is free, and B&H charges NY tax only. These prices are currently the... Read more
13-inch 128GB MacBook Air now on sale for $79...
Best Buy has just lowered their price on the 2015 13″ 1.6GHz/128GB MacBook Air to $799.99 on their online store for Cyber Monday. Choose free shipping or free local store pickup (if available). Sale... Read more
Best Buy lowers 13-inch MacBook Pro prices, n...
Best Buy has lowered prices on select 13″ MacBook Pros this afternoon. Now save up to $200 off MSRP for Cyber Monday on the following models. Choose free shipping or free local store pickup (if... Read more
Cyber Monday: Apple MacBooks on sale for up t...
Apple resellers have MacBook Pros, MacBook Airs, and MacBooks on sale for up to $250 off MSRP for Cyber Monday 2015. The following is a roundup of the lowest prices available for new models from any... Read more
Cyber Monday: Apple Watch on sale for up to $...
B&H Photo has the Apple Watch on sale for Cyber Monday for $50-$100 off MSRP. Shipping is free, and B&H charges NY sales tax only: - Apple Watch Sport: $50 off - Apple Watch: $50-$100 off B... Read more
Cyber Monday: 15% off Apple products, and sto...
Use code CYBER15 on Cyber Monday only to take 15% on Apple products at Target, and store-wide. Choose free shipping or free local store pickup (if available). Sale prices for online orders only, in-... Read more
iPad Air 2 And iPad mini Among Top Five Black...
Adobe has released its 2015 online shopping data for Black Friday and Thanksgiving Day. The five best selling electronic products on Black Friday were Samsung 4K TVs, Apple iPad Air 2, Microsoft Xbox... Read more

Jobs Board

iOS Passbook & *Apple* Pay Engineer - A...
# iOS Passbook & Apple Pay Engineer Job Number: 36237585 Santa Clara Valley, Califo ia, United States Posted: May. 27, 2015 Weekly Hours: 40.00 **Job Summary** The Read more
*Apple* New Products Tester Needed - Apple (...
…we therefore look forward to put out products to quality test for durability. Apple leads the digital music revolution with its iPods and iTunes online store, continues Read more
Software Engineer, *Apple* Watch - Apple (U...
# Software Engineer, Apple Watch Job Number: 33362459 Santa Clara Valley, Califo ia, United States Posted: Jul. 28, 2015 Weekly Hours: 40.00 **Job Summary** Join the Read more
SW Engineer - *Apple* Music - Apple (United...
# SW Engineer - Apple Music Job Number: 40899104 San Francisco, Califo ia, United States Posted: Aug. 18, 2015 Weekly Hours: 40.00 **Job Summary** Join the Android Read more
Sr Software Engineer *Apple* Pay - Apple (U...
# Sr Software Engineer Apple Pay Job Number: 44003019 Santa Clara Valley, Califo ia, United States Posted: Nov. 13, 2015 Weekly Hours: 40.00 **Job Summary** Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.