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

Delve back into the Sanctum of Rebirth t...
I don’t know about you, but I am all for a big, interconnected tree of lore in games or series. The MCU, the fabulous marathon that is The Legend of Heroes, and the long-running MMO Runescape. The Ode of the Devourer quest has released and is the... | Read more »
TouchArcade is Shutting Down
This is a post that I’ve known was coming for quite some time, but that doesn’t make it any easier to write. After more than 16 years TouchArcade will be closing its doors and shutting down operations. There may be an additional post here or there... | Read more »
Combo Quest (Games)
Combo Quest 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: Combo Quest is an epic, time tap role-playing adventure. In this unique masterpiece, you are a knight on a heroic quest to retrieve... | Read more »
Hero Emblems (Games)
Hero Emblems 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: ** 25% OFF for a limited time to celebrate the release ** ** Note for iPhone 6 user: If it doesn't run fullscreen on your device... | Read more »
Puzzle Blitz (Games)
Puzzle Blitz 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Puzzle Blitz is a frantic puzzle solving race against the clock! Solve as many puzzles as you can, before time runs out! You have... | Read more »
Sky Patrol (Games)
Sky Patrol 1.0.1 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.1 (iTunes) Description: 'Strategic Twist On The Classic Shooter Genre' - Indie Game Mag... | Read more »
The Princess Bride - The Official Game...
The Princess Bride - The Official Game 1.1 Device: iOS Universal Category: Games Price: $3.99, Version: 1.1 (iTunes) Description: An epic game based on the beloved classic movie? Inconceivable! Play the world of The Princess Bride... | Read more »
Frozen Synapse (Games)
Frozen Synapse 1.0 Device: iOS iPhone Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: Frozen Synapse is a multi-award-winning tactical game. (Full cross-play with desktop and tablet versions) 9/10 Edge 9/10 Eurogamer... | Read more »
Space Marshals (Games)
Space Marshals 1.0.1 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.1 (iTunes) Description: ### IMPORTANT ### Please note that iPhone 4 is not supported. Space Marshals is a Sci-fi Wild West adventure taking place... | Read more »
Battle Slimes (Games)
Battle Slimes 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: BATTLE SLIMES is a fun local multiplayer game. Control speedy & bouncy slime blobs as you compete with friends and family.... | Read more »

Price Scanner via MacPrices.net

Amazon and Best Buy have Apple’s 10th-generat...
Amazon and Best Buy are offering $50-$30 discounts on Apple’s 10th-generation iPads this week, with models now available starting at only $299. These are the lowest prices available for Apple’s... Read more
Red Pocket Mobile is offering a $300 rebate o...
Red Pocket Mobile has new Apple iPhone 16’s on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
New at Xfinity Mobile: iPhone 16 Pros for $40...
Switch to Xfinity Mobile with a new line of service, and take $400 off the price of any new iPhone 16 Pro through October 10, 2024. Final value is applied to your account, monthly, over a 24-month... Read more
16-inch Apple MacBook Pros on sale this week...
Best Buy has 16″ M3 Pro and M3 Max Apple MacBook Pros on sale for $500 off MSRP on their online store this week. Prices valid for online orders only, in-store prices may vary. Order online and choose... Read more
iPhone 15 and 15 Plus free at Verizon for new...
Verizon has the iPhone 15 and iPhone 15 Plus now on sale for $0 per month (that’s free!) when you add a new line of service. No trade-in is required. Discount is applied to your account monthly over... Read more
Verizon offers free iPhone 16 and 16 Pro mode...
Verizon is offering $1000 discounts on the new iPhone 16 Pro, $830 for the 16 and 16 Plus, for customers opening a new line of service. Discount is applied via monthly bill credits over a 36 month... Read more
AT&T offers free iPhone 16 and 16 Pro mod...
AT&T is offering $1000 discounts on the new iPhone 16 Pro, $830 for the 16 and 16 Plus, for new and existing customers with an eligible trade-in. Discount is applied via monthly bill credits over... Read more
Buy a new iPhone 16 at Visible, and get $10 o...
Switch to Visible, and buy a new iPhone 16 (full price or financed), and Visible will take $10 off their monthly Visible+ service for 36 months. Visible is Verizon’s low-cost service. Visible+ is... Read more
Apple iPhone 16 deals are live at Xfinity Mob...
Switch to Xfinity Mobile with a new line of service, and take up to $1000 off the price of a new iPhone 16 through October 10, 2024. Final value is applied to your account, monthly, after qualifying... Read more
Get a free iPhone 16 at Boost Mobile plus Unl...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 16 or 16 Pro including service with their Unlimited plan (30GB of premium data) for a total charge of $65... Read more

Jobs Board

EUC *Apple* /MAC Platform Engineer - Corning...
EUC Apple /MAC Platform Engineer **Date:** Sep 13, 2024 **Location:** Charlotte, NC, US, 28216Corning, NY, US, 14831 **Company:** Corning Requisition Number: 64844 Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of 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
Secret *Apple* MacOS Workspace ONE AirWatch...
Job Description The Apple MacOS Workspace ONE AirWatch Engineer role is primarily responsible for managing a fleet of 400-500 MacBook computers. The ideal candidate 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.