TweetFollow Us on Twitter

Dec 95 Tips
Volume Number:11
Issue Number:12
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

Arguments To “s” In MacsBug

In MacsBug, the s [step] command will take an argument which is either a count or a condition on which to stop. This can be very useful for unwinding a twisty bit of code. For example, if you keep crashing in a particular spot, but you can’t tell how you got there or what happened just before, you can break before everything goes wrong and type


  s (pc == <badspot>)

Where badspot is where you know things are wrong. Macsbug will step through all of the instructions in between here and there. You can then examine the path taken in the scrollback or, if you turn on the log first, look at it all offline with an editor. With the newest versions of MacsBug, you can even step over mixed mode. Note that it’s possible for find weirder problems, too:


 s (a0 == 0)

will step until a0 equals 0.

 

 s (<addr>^ != <current value>)

will step until the long at <addr> changes.

You can use this trick to find a really wide variety of problems. Should you use this tip, donate my fee to the American Red Cross.

- Tim Dierks

They Said I Couldn’t
Return Errors From Constructors

I have read several times that “you can’t return an error from a constructor”. This is not entirely true. See the following code example:

class exampleClass : parentClass
{
  exampleClass( int arg1, OSErr& errOut );
    // initialization constructor
...etc....
};

exampleClass::exampleClass( int arg1, OSErr& errOut )
 : parentClass()  // parent class constructor explicitly called
 , memberData() // instance variable's explict constructor
{
//  errOut = noErr;  see note #4 below
  errOut = someSystemCall( arg1 );
}

void main ( void )
{
   OSErr  err;
   exampleClass  aVar( 12, err );
   if ( err != noErr ) 
   {....etc....
}

This example “obviously” returns error information.

However, errOut will NOT have a known value if the following occurs:

1. parentClass’s explicit constructor throws an exception.

2. memberData’s explicit constructor throws an exception.

3. someSystemCall throws an exception. This example used explicit contructor calls, but the same is true for implicit constructor calls to parent classes and member data varables.

4. if the errOut = noErr line is uncommented, then at least errOut can have a known value in the absence of other exceptions.

Of course, since main isn’t doing try/catch, then the test of err != noErr is not going to happen when an exception occurs, either.

- C. Keith Ray

Is Your App Windowshade Savvy?

Many apps change the cursor within certain areas of their windows. This may be to provide the crosshairs in a drawing window, or a hand cursor if something can be dragged in an area of your window. Unfortunately, many applications forget to check whether their window is windowshaded or not. If their window is windowshaded but still the front window, they go ahead and change the cursor anyway, leading to the effect of the cursor changing over “empty space.” Looks ugly. Here’s the fix:

if (EmptyRgn( ((WindowPeek)TheWindow)->contRgn )) 
//window shade has been used

Don’t change the cursor;

else

Go ahead and change the cursor;

In the above example, TheWindow is the windowptr to the window who’s areas we are changing the cursor for.

- Richard Unger and Eric Bourque

Shortcut to Open Header Files In CodeWarrior

Here is a feature that I’d long hoped for, and recently, by accident, found.

In Metrowerk’s IDE, typing ‘command tab’ will open the corresponding .h or .cp file. For example, if you’re working in a source file named “FileName.cp” typing ‘command tab’ will open “FileName.h”. This is an extremely useful feature that I hope Symantec will adopt.

- Norman Basha

Drop Into MacsBug at a Predictable Address

When dropping into MacsBug, I often find myself in the wrong application’s code. For example, lets say I want to force-quit the finder using “es” from MacsBug. (command-option-escape will quit and then restart the Finder). To make sure the Finder is the frontmost app, I hold the mouse down in one of the Finder’s menus and press the interrupt key, and I’m dropped in at a known location (a small loop within the menu manager). Not only that, but the current menu manager is emulated on PowerMacs, further ensuring my safety. Then a simple “es” quits the Finder.

- Damon Cokenias

Lock Your Libraries, Prevent Changes

Here’s a tip that may be obvious, but it’s useful, if somewhat simple.

If you don’t want to modify the standard libraries included in a development environment (the source to PowerPlant or TCL for example) you can use the following script to lock all the files. I use this script in MPW, but should work with ToolServer as well:

### First set the current directory to the folder containing the sources 
to lock
### note that this script does sub-folders also.
### replace "xxx" with your path, e.g., "HD:MPW:Interfaces:"
directory "Full path to the folder in which the files are:"

### Then set the lock bit to ON for all files which are of
### type 'TEXT' in the current directory and all sub-directories
### Notes:
###   remove "-r" to skip sub-directories
###   make the "L" lowercase ("l") to un-lock files
###   the -f is for full paths, -s to supress directory listings
SetFile -a L `files -r -f -s -t 'TEXT'`

Anyway, just thought I’d pass it on. It’s particularly useful while using a class browser like Object Master, where you can browse all classes and it’s easy to end up editing one of the supplied classes in PowerPlant/Think Class Library/MacApp.

- Tyler Morrison

[AppleScript also supports locking and unlocking of files. Simply modify the “locked” property of x, where x is a file alias or file name with: set the locked of file x to true

EdAsst - jtk]

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom 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.