TweetFollow Us on Twitter

Jan 95 Top 10
Volume Number:11
Issue Number:1
Column Tag:Think Top 10

Think Top 10

This monthly column, written by Symantec’s Technical Support Engineers, aims to provide you with information on Symantec products. Each month we cover either a specific application of tools or a “Q&A” list.

By Craig Conner and Rick Hartmann, Symantec Technical Support

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

Q: Why do I get a bus error when I try to use the VIA timer option for the profiler?

A: The Symantec C++ 7 documentation states that the profiler uses the VIA (Versatile Interface Adapter) timer which ticks every 1.28 microseconds. If you want to use Ticks (1/60 of a second), modify the profiler code to do so. Not all Macintosh models contain a VIA timer chip. To find out if your Mac has a VIA timer chip, you should use the functions gestaltHasVIA1 or gestaltHasVIA2 (Mac II).

If you have the chip, modify profile.c as follows:

#ifdef _VIATIMER_ 
  #define Ticks VIA_Ticks() 
#else 
  #ifdef __CONDITIONALMACROS__ 
  #define Ticks LMGetTicks() 
  #endif 
#endif

Next, remove all of the #ifdef __CONDITIONALMACRO__ statements in profile.c, then use the Ticks assignments.

Q: Why can’t I use fopen to open more than 12 files?

A: stdio.h defines a table for keeping track of open files. This table is defined as:

extern FILE __file[FOPEN_MAX]; 

where FOPEN_MAX is declared as 15. Three streams are reserved for stdin, stdout, and stderr which leaves 12 more for you to use. To open more than twelve files, increase the value of FOPEN_MAX and recompile the ANSI library. Alternatively, you can use Macintosh Toolbox calls to open files; those files are not counted against the limit.

Q: When I try to use TESetWordBreak I get a link error.

A: Below is an example of how to use TESetWordBreak with the current Universal Headers. The changes only apply to 68K use. You can use TESetWordBreak directly when compiling for PowerPC. Basically the problem is that Apple doesn’t provide the glue for the new routine name, but has written the Universal Headers as if they did. [This was fixed on ETO #15. Interface.o on ETO #15 has an extra entry point added for TESetWordBreak. There was also the same problem and fix for SetClikLoop -> TESetClickLoop - Ed stb]

#include <TextEdit.h>

// Need to undo the redefinition of SetWordBreak in the Universal Headers when in 
// 68K.  Glue for SetWordBreak is in MacTraps, but there is no glue for 
// TESetWordBreak.  We also need to redefine any calls using the new name 
// for the same reason

#ifndef powerc 
#undef SetWordBreak 
extern pascal void SetWordBreak(WordBreakUPP wBrkProc,TEHandle hTE); 

#define TESetWordBreak(wBrkProc, hTE) SetWordBreak(wBrkProc, hTE) 
#endif

pascal Boolean myWordBreaker(Ptr textPtr, short offset );

void foo() 
{
 TEHandle hTE;
 WordBreakUPP brk = NewWordBreakProc(myWordBreaker);
 
 // either of the following two are ok
 SetWordBreak(brk, hTE);
 TESetWordBreak(brk, hTE); 
}

pascal Boolean myWordBreaker(Ptr textPtr, short offset ) 
{
 if (textPtr[offset] == 's' )  
  return true;
 else
  return false; 
}

Q: How do I use new to obtain a two dimensional array?

A: Each row element in a two dimensional array is actually a pointer to the row. To access a two dimensional array using new, you need to tell the compiler that you want two dimensions like so:

int (*intarr)[3] = new int[2][3];

Then you can access the memory using array references, e.g. intarr[1][1].

Q: Do I have to declare objects as “volatile” in TRY/CATCH macros?

A: Yes. When a TRY is executed, all registers are saved. When CATCH is executed, the registers are restored to the saved state. If you change a value of a non-volatile variable within a TRY block, it’s possible that the value will be restored to what it was before the TRY when the CATCH is triggered. If you use a volatile variable, the compiler forces its value to be saved to memory any time it’s changed, and won’t let it be cached in a register.

Q: Do I need to recompile the ANSI++ library with 8-byte doubles to use it in a Visual Architect project?

A: 8-byte doubles are no longer required for VA (or other TCL) projects. The default VA project still ships with 8-byte doubles on while the ANSI++ library ships with it off. It is ok to turn this option off in your TCL projects.

Q: How do I trap CRadioControl commands within a dialog?

A: By default the values of radio buttons are not verified until a dialog box finishes the DoModalDialog() function. DoModalDialog returns a command of type long. At this point, the programmer should create a switch statement where the values of radio buttons are checked with the (CRadioGroupPane*)FindViewByID->GetStationID(theRadioDITL) method.

The problem with this style is that the values of the radio buttons are obtained after the dialog is dismissed. Often, the programmer will want to have the changing values of radio buttons change the characteristics of items in the dialog itself. For example, a programmer may want the font of a CDialogText to change according to the settings of radio buttons.

The solution has three parts.


1) Set up your derived CDLOGDirector class so that it owns the CRadioControl pointers. This will give you access to the radio buttons throughout your class.


2) When you instantiate CRadioControl make a call to SetClickCmd(). Make sure to set each button with its own command. For the command to work, it must be something other than zero.

 myRadio1->SetClickCmd( cmdFontGeneva);

3) Add a DoCommand() function to your derived CDLOGDirector class.

 MyDialogDirector::DoCommand(theCommand) {
 
 switch (theCommand)
  {
  case cmdFontGeneva:
  myDialogText->SetTextFont(3);    //Set font to geneva
  break;
  case cmdFontChicago:
  myDialogText->SetTextFont(0);    //Set font to chicago
  break;
  default:
  inherited::DoCommand(theCommand);  //important
  }
 }

The default statement is extremely important for this construct. The inherited DoCommand() is trapped by CDialogDirector to process the OK and Cancel command. If you do not trap these commands yourself, or do not have an inherited method trap them, you will not be able to dismiss the dialog.

Q: In Visual Architect, can I have main windows that are not based on CSaver?

A: In Visual Architect 7.0.4, the code generation does not recognize the checkbox for the “Use File” option. The solution is to change the code in the “GenerateTCLApp” VA template file for documents, as follows:

$elseif class.basename == "CDocument"$
 $generate "Source:$class.name$.cp" "Doc_cp" once$
 $generate "Source:$class.name$.h" "Doc_h" once$
 $if class.view.usefile$
  $generate "Source:ItsContents_$class.name$.h"  "ItsContentsClass_h" 
once$
  $generate "Source:CSaver_$class.name$.cpp" "CSaver_class_cpp"  once$
 $end if$
 $define do_document 1$

Q: How do I change the font attributes in CStdPopupPane?

A: Changing the font of popup menus is not intuitively obvious. The process involves several steps.


1) Create a menu resource with a title and a menu item. Remember its ID number.


2) Instantiate your CStdPopupPane.

myPopUp = TCL_NEW( CStdPopupPane, (menuID, itsWindow, this,
  0,0, 100,100, TRUE, FALSE, FALSE));

3) Make sure to #include CTextEnvirons. Then create a local pointer to a TextInfoRec, and fill the struct with the text information that you want in your popup.

TextInfoRec * myTextInfo = new TextInfoRec;

myTextInfo->fontNumber = 10;
myTextInfo->theSize = 12;
myTextInfo->theStyle = bold;
myTextInfo->theMode = qd.thePort->txMode;

4) Cast the itsEnvironment member of the CStdPopUpPane as a CTextEnvirons, allocate memory for it, and call the SetTextInfo() method.

(CTextEnvirons*)myPopUp->itsEnvironment = 
 TCL_NEW (CTextEnvirons, (FALSE));
((CTextEnvirons*)myPopUp->itsEnvironment)-> 
 SetTextInfo(myTextInfo);

5) Don’t forget to delete the temporary variable myTextInfo.

Q: Visual Architect projects take so long to compile. How can I reduce the compile time? (Reprise)

A: In October’s Think Top 10 we had a question concerning saving time when using VA projects. The answer we gave was to compile the @1.Π file in the Visual Architect Project Model. The problem with that is that the debugging information doesn’t get copied when you create a new project.

To avoid that problem, before you compile, uncheck the Store Debug Info Separately switch in the debugger options for the Think Project Manager. This will store the debug info inside of the project file, so that it will be copied into your new project. If you wish, you can uncheck the switch after creating your project; it won’t force a recompilation.

Thanks to Michael Hopkins, Mark Baldwin, Steve Howard,
Phil Shapiro, Rich Parker, and the rest of the gang.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

ScreenFlow 8.2.5 - Create screen recordi...
ScreenFlow is powerful, easy-to-use screencasting software for the Mac. With ScreenFlow you can record the contents of your entire monitor while also capturing your video camera, microphone and your... Read more
MegaSeg 6.1.1 - Professional DJ and radi...
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
Beamer 3.4 - Stream any movie file from...
Beamer streams to your Apple TV or Chromecast. Plays any movie file - Just like the popular desktop movie players, Beamer accepts all common formats, codecs and resolutions. AVI, MKV, MOV, MP4, WMV... Read more
FotoMagico 5.6.12 - Powerful slideshow c...
FotoMagico lets you create professional slideshows from your photos and music with just a few, simple mouse clicks. It sports a very clean and intuitive yet powerful user interface. High image... Read more
OmniGraffle Pro 7.12.1 - 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
beaTunes 5.2.1 - Organize your music col...
beaTunes is a full-featured music player and organizational tool for music collections. How well organized is your music library? Are your artists always spelled the same way? Any R.E.M. vs REM?... Read more
HandBrake 1.3.0 - Versatile video encode...
HandBrake is a tool for converting video from nearly any format to a selection of modern, widely supported codecs. Features Supported Sources VIDEO_TS folder, DVD image or real DVD (unencrypted... Read more
Macs Fan Control 1.5.1.6 - Monitor and c...
Macs Fan Control allows you to monitor and control almost any aspect of your computer's fans, with support for controlling fan speed, temperature sensors pane, menu-bar icon, and autostart with... Read more
TunnelBear 3.9.3 - Subscription-based pr...
TunnelBear is a subscription-based virtual private network (VPN) service and companion app, enabling you to browse the internet privately and securely. Features Browse privately - Secure your data... Read more
calibre 4.3.0 - Complete e-book library...
Calibre is a complete e-book library manager. Organize your collection, convert your books to multiple formats, and sync with all of your devices. Let Calibre be your multi-tasking digital librarian... Read more

Latest Forum Discussions

See All

The House of Da Vinci 2 gets a new gamep...
The House of Da Vinci launched all the way back in 2017. Now, developer Blue Brain Games is gearing up to deliver a second dose of The Room-inspired puzzling. Some fresh details have now emerged, alongside the game's first official trailer. [Read... | Read more »
Shoot 'em up action awaits in Battl...
BattleBrew Productions has just introduced another entry into its award winning, barrelpunk inspired, BattleSky Brigade series. Whilst its previous title BattleSky Brigade TapTap provided fans with idle town building gameplay, this time the... | Read more »
Arcade classic R-Type Dimensions EX blas...
If you're a long time fan of shmups and have been looking for something to play lately, Tozai Games may have just released an ideal game for you on iOS. R-Type Dimensions EX brings the first R-Type and its sequel to iOS devices. [Read more] | Read more »
Intense VR first-person shooter Colonicl...
Our latest VR obsession is Colonicle, an intense VR FPS, recently released on Oculus and Google Play, courtesy of From Fake Eyes and Goboogie Games. It's a pulse-pounding multiplayer shooter which should appeal to genre fanatics and newcomers alike... | Read more »
PUBG Mobile's incoming update bring...
PUGB Mobile's newest Royale Pass season they're calling Fury of the Wasteland arrives tomorrow and with it comes a fair chunk of new content to the game. We'll be seeing a new map, weapon and even a companion system. [Read more] | Read more »
PSA: Download Bastion for free, but wait...
There hasn’t been much news from Supergiant Games on mobile lately regarding new games, but there’s something going on with their first game. Bastion released on the App Store in 2012, and back then it was published by Warner Bros. This Warner... | Read more »
Apple Arcade: Ranked - 51+ [Updated 11.5...
This is Part 2 of our Apple Arcade Ranking list. To see part 1, go here. 51. Patterned [Read more] | Read more »
NABOKI is a blissful puzzler from acclai...
Acclaimed developer Rainbow Train's latest game, NABOKI, is set to launch for iOS, Android, and Steam on November 13th. It's a blissful puzzler all about taking levels apart in interesting, inventive ways. [Read more] | Read more »
A Case of Distrust is a narrative-driven...
A Case of Distrust a narrative-focused mystery game that's set in the roaring 20s. In it, you play as a detective with one of the most private eye sounding names ever – Phyllis Cadence Malone. You'll follow her journey in San Francisco as she... | Read more »
Brown Dust’s October update offers playe...
October is turning out to be a productive month for the Neowiz team, and a fantastic month to be a Brown Dust player. First, there was a crossover event with the popular manga That Time I Got Reincarnated as a Slime. Then, there was the addition of... | Read more »

Price Scanner via MacPrices.net

Score a 37% discount on Apple Smart Keyboards...
Amazon has Apple Smart Keyboards for current-generation 10″ iPad Airs and previous-generation 10″ iPad Pros on sale today for $99.99 shipped. That’s a 37% discount over Apple’s regular MSRP of $159... Read more
Apple has refurbished 2019 13″ 1.4GHz MacBook...
Apple has a full line of Certified Refurbished 2019 13″ 1.4GHz 4-Core Touch Bar MacBook Pros available starting at $1099 and up to $230 off MSRP. Apple’s one-year warranty is included, shipping is... Read more
2019 13″ 1.4GHz 4-Core MacBook Pros on sale f...
Amazon has new 2019 13″ 1.4GHz 4-Core Touch Bar MacBook Pros on sale for $150-$200 off Apple’s MSRP. These are the same MacBook Pros sold by Apple in its retail and online stores: – 2019 13″ 1.4GHz/... Read more
11″ 64GB Gray WiFi iPad Pro on sale for $674,...
Amazon has the 11″ 64GB Gray WiFi iPad Pro on sale today for $674 shipped. Their price is $125 off MSRP for this iPad, and it’s the lowest price available for the 64GB model from any Apple reseller. Read more
2019 15″ MacBook Pros available for up to $42...
Apple has a full line of 2019 15″ 6-Core and 8-Core Touch Bar MacBook Pros, Certified Refurbished, available for up to $420 off the cost of new models. Each model features a new outer case, shipping... Read more
2019 15″ MacBook Pros on sale this week for $...
Apple resellers B&H Photo and Amazon are offering the new 2019 15″ MacBook Pros for up to $300 off Apple’s MSRP including free shipping. These are the same MacBook Pros sold by Apple in its... Read more
Sunday Sale: AirPods with Wireless Charging C...
B&H Photo has Apple AirPods with Wireless Charging Case on sale for $159.99 through 11:59pm ET on November 11th. Their price is $40 off Apple’s MSRP, and it’s the lowest price available for these... Read more
Details of Sams Club November 9th one day App...
Through midnight Saturday night (November 9th), Sams Club online has several Apple products on sale as part of their One Day sales event. Choose free shipping or free local store pickup (if available... Read more
Sprint is offering the 64GB Apple iPhone 11 f...
Sprint has the new 64GB iPhone 11 available for $15 per month for new lines. That’s about 50% off their standard monthly lease of $29.17. Over is valid until November 24, 2019. The fine print: “Lease... Read more
New Sprint November iPhone deal: Lease one iP...
Switch to Sprint and purchase an Apple iPhone 11, 11 Pro, or 11 Pro Max, and get a second 64GB iPhone 11 for free. Requires 2 new lines or 1 upgrade-eligible line and 1 new line. Offer is valid from... Read more

Jobs Board

*Apple* Mobility Pro - Best Buy (United Stat...
**746087BR** **Job Title:** Apple Mobility Pro **Job Category:** Store Associates **Store NUmber or Department:** 000319-Harlem & Irving-Store **Job Description:** Read more
Best Buy *Apple* Computing Master - Best Bu...
**743392BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Store Associates **Store NUmber or Department:** 001171-Southglenn-Store **Job Read more
Best Buy *Apple* Computing Master - Best Bu...
**746015BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Sales **Store NUmber or Department:** 000372-Federal Way-Store **Job Description:** Read more
*Apple* Mobility Pro - Best Buy (United Stat...
**744658BR** **Job Title:** Apple Mobility Pro **Job Category:** Store Associates **Store NUmber or Department:** 000586-South Hills-Store **Job Description:** At Read more
Best Buy *Apple* Computing Master - Best Bu...
**741552BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Sales **Store NUmber or Department:** 000277-Metcalf-Store **Job Description:** **What Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.