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.

TIP OF THE MONTH

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:

routine1()
{
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:

 MoveStartOfFile

with

       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:

DeleteCharLeft

DeleteCharRight

DeleteEndOfFile

DeleteEndOfLine

DeleteStartOfFile

DeleteStartOfLine

DeleteWordLeft

DeleteWordRight

MoveCharLeft

MoveCharRight

MoveEndOfLine

MoveLineDown

MoveLineUp

MovePageDown

MovePageUp

MoveStartOfFile

MoveStartOfLine

MoveWordLeft

MoveWordRight

SelectCharLeft

SelectCharRight

SelectEndOfFile

SelectEndOfLine

SelectLineDown

SelectLineUP

SelectPageDown

SelectPageUp

SelectStartOfFile

SelectStartOfLine

SelectWordLeft

SelectWordRight

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

ScrollEnd

ScrollHome

ScrollPageDn

ScrollPageUp

DebuggerCommand

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

Apple Digital Camera RAW Compatibility 6...
Apple Digital Camera RAW Compatibility update adds RAW image compatibility to Aperture 3 and iPhoto '11. For more information on supported RAW formats, see this page. Version 6.03: This update adds... Read more
OmniGraffle Pro 6.1.4 - Create diagrams,...
OmniGraffle Pro helps you draw beautiful diagrams, family trees, flow charts, org charts, layouts, and (mathematically speaking) any other directed or non-directed graphs. We've had people use... Read more
OmniGraffle 6.1.4 - Create diagrams, flo...
OmniGraffle helps you draw beautiful diagrams, family trees, flow charts, org charts, layouts, and (mathematically speaking) any other directed or non-directed graphs. We've had people use Graffle to... Read more
MegaSeg 5.9.5 - Professional MP3 DJ appl...
MegaSeg is a complete solution for pro audio/video DJ mixing, radio automation, and music scheduling with rock-solid performance and an easy-to-use design. Mix with visual waveforms and Magic... Read more
MarsEdit 3.6.8 - Quick and convenient bl...
MarsEdit is a blog editor for OS X that makes editing your blog like writing email, with spell-checking, drafts, multiple windows, and even AppleScript support. It works with with most blog services... Read more
BBEdit 11.0.3 - Powerful text and HTML e...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more
Microsoft Office Preview 15.8 - Popular...
Welcome to the new and modern Microsoft Office for Mac. You will receive regular updates automatically until the official release in the second half of 2015. With the redesigned Ribbon and your... Read more
Yosemite Cache Cleaner 9.0.5 - Clear cac...
Yosemite Cache Cleaner is an award-winning general purpose tool for OS X. YCC makes system maintenance simple with an easy point-and-click interface to many OS X functions. Novice and expert users... Read more
ExpanDrive 4.3.2 - Access cloud storage...
ExpanDrive builds cloud storage in every application, acts just like a USB drive plugged into your Mac. With ExpanDrive, you can securely access any remote file server directly from the Finder or... Read more
RapidWeaver 6.0.8 - Create template-base...
RapidWeaver is a next-generation Web design application to help you easily create professional-looking Web sites in minutes. No knowledge of complex code is required, RapidWeaver will take care of... Read more

Huge New Content Update to RuPaul’s Drag...
Huge New Content Update to RuPaul’s Drag Race: Dragopolis 2.0! Posted by Jessica Fisher on March 6th, 2015 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Take a First Look at NaturalMotion’s Daw...
NaturalMotion has released a preview of their upcoming title, Dawn of Titans. Dawn of Titans immerses you in a world of fantasy as you build your kingdom, raise an army, and capture territories. The focus on this epic action strategy game was the... | Read more »
GDC 2015 – Warfriends is Something Famil...
GDC 2015 – Warfriends is Something Familiar That’s Also a Little Different Posted by Rob Rich on March 6th, 2015 [ permalink ] About Fun‘s upcoming Warfriends is quite the interesting hybrid. | Read more »
GDC 2015 – This is Why Everybody’s Talki...
GDC 2015 – This is Why Everybody’s Talking About Downwell Posted by Rob Rich on March 6th, 2015 [ permalink ] So Downwell. Holy crap. | Read more »
It’s Guild vs. Guild in Summoners War’s...
It’s Guild vs. Guild in Summoners War’s Newest Update! Posted by Jessica Fisher on March 6th, 2015 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
GDC 2015 – Toast USA’s Line-Up is Lookin...
GDC 2015 – Toast USA’s Line-Up is Looking Pretty Darn Cool Posted by Rob Rich on March 6th, 2015 [ permalink ] Guardian Stone Guardian Stone has been in the works for quite some time, but it’s finally getting close to a release. | Read more »
Heavenstrike Rivals: Beginners’s Tips, T...
Dig this: Would you like to know what we thought of this steampunk strategy game? Check out our Heavenstrike Rivals review! The Basics | Read more »
Bored? MyLeisure FreeTime Maximizer Will...
Bored? MyLeisure FreeTime Maximizer Will Take Care of That! Posted by Jessica Fisher on March 5th, 2015 [ permalink ] iPhone App - Designed for the iPhone, compatible with the iPad | Read more »
New Publisher Allstar Games Heads West w...
Allstar Games has announced its first mobile title designed for western audiences, Allstar Heroes. The game will be a massive online battle arena (MOBA) that offers dozens of heroes for you to collect and pit against your opponents. As each hero has... | Read more »
RAD Boarding Review
RAD Boarding Review By Jennifer Allen on March 5th, 2015 Our Rating: :: NEARLY RADUniversal App - Designed for iPhone and iPad RAD Boarding isn’t quite one of the greats, but it has potential.   | Read more »

Price Scanner via MacPrices.net

iOS 8.2 Coming Monday; Official Changelog An...
BGR’s Jonathan Geller reports that Apple will release an iOS 8.2 Final on Monday, presumably in conjunction with its scheduled “Spring Forward” special event. Geller also reports that he’s been... Read more
iBusiness Technologies Announces iReplenish t...
iBusiness Technologies, partnered nationally with Apple to provide businesses with iPad-based MobiliForms, has announced that for every system purchased it will plant 50 trees through The Nature... Read more
EnerPlex Surfr Battery & Solar Case for i...
Ascent Solar Technologies, Inc. a developer of state-of-the-art, flexible thin-film photovoltaic modules, integrated into the company’s EnerPlex series of consumer products, has announced immediate... Read more
16GB iPad mini 3 on sale for $349, save $50
 Walmart has the 16GB iPad mini 3 WiFi on sale on their online store for $349.99 including free shipping or free local store pickup. Their price is $50 off MSRP, and it’s the lowest price available... Read more
Save up to 15% with Apple refurbished Time Ca...
The Apple Store has certified refurbished Time Capsules available for up to $60 off MSRP. Apple’s one-year warranty is included with each Time Capsule, and shipping is free: - 2TB Time Capsule: $255... Read more
Save up to $105 on AppleCare Protection Plans
B&H Photo has 3-Year AppleCare Warranties on sale for up to $105 off MSRP including free shipping plus NY sales tax only: - Mac Laptops 15″ and Above: $244 $105 off MSRP - Mac Laptops 13″ and... Read more
Apple restocks refurbished 15-inch Retina Mac...
The Apple Store has restocked Apple Certified Refurbished 2014 15″ Retina MacBook Pros, available for up to $400 off the cost of new models. An Apple one-year warranty is included with each model,... Read more
Roundup of MacBook Air sale prices, models up...
B&H Photo has MacBook Airs on sale for up to $100 off MSRP. Shipping is free, and B&H charges NY sales tax only: - 11″ 128GB MacBook Air: $799 100 off MSRP - 11″ 256GB MacBook Air: $999 $100... Read more
New Firstrade Mobile App Enables On-The-Go Tr...
Firstrade Securities Inc. has announced its new mobile app, which gives investors immediate access to the company’s trading platform on all mobile devices. The app was developed in-house and was... Read more
Sonnet Introduces USB 3.0 + eSATA Thunderbolt...
Sonnet has announced the launch of its new USB 3.0 + eSATA Thunderbolt Adapter for easy connectivity to USB 3.0 devices and eSATA storage, and USB 3.0 + Gigabit Ethernet Thunderbolt Adapter for easy... Read more

Jobs Board

*Apple* Solutions Consultant- Retail Sales -...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Solutions Consultant - Retail Sales...
**Job Summary** As an Apple Solutions Consultant (ASC) you are the link between our customers and our products. Your role is to drive the Apple business in a retail Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Solutions Consultant - Retail Sales...
**Job Summary** As an Apple Solutions Consultant (ASC) you are the link between our customers and our products. Your role is to drive the Apple business in a retail Read more
Position Opening at *Apple* - Apple (United...
…Summary** As a Specialist, you help create the energy and excitement around Apple products, providing the right solutions and getting products into customers' hands. You Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.