Help with Macintosh programming

macintosh programming, mac programming, mac os programming, mac os x programming, mac programming language, mac programing

Archive for February, 2010

Re: Popup in list box??

   The only time I saw this was in FoxPro 2.5, a Microsoft program… I
hated it on sight, but I don’t have any real arguments…


- Hide quoted text — Show quoted text -

> An interface issue has emerged among our Windoze developers that I
> don’t recall seeing in Mac-land…  Using a cell of a multi-column list
> box to hold a popup menu which both shows its value and allows the
> value to be changed. My user interface policeman conscience has a
> problem with this, but I can’t put together a strong enough
> counterargument. Has anyone out there:

> 1) Seen this done in any apps on Mac? If so, how effective was it?
> 2) Implemented this? If so, how did you do it?

> Like so (text graphics liberties taken…):
> =================================================================
> | Column 1                   |   Popup Item >  | Column 3       |
> | Column 1                   |   Popup Item >  | Column 3       |
> |               blah blah blah                                  |
> |               yada yada yada                                  |
> |               the thing the thing the thing                   |
> =================================================================

[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]
[These lines added for no reason other than allowing me to post]

Check out my URL with a WWW browser:

posted by admin in Uncategorized and have Comments (3)

Re: What books to get for c++?

In article <39oi81$…>, pbs… (Paul Larson) wrote:
> What books should I get to learn c++?

Here’s some references I’ve kept on my HD:
  (I’ll try to organize ‘em for a miniFAQ)

Books on Mac Programming

Learning the Language (C/C++)

   _Learn C on the Macintosh_ by Dave Mark
     Addison Wesley Publishing

     A good introduction to the C language, includes a limited
     version of Think C 5.0.  Does not cover the toolbox, but
     then you shouldn’t be worrying about the toolbox till you
     understand the language

   _Learn C++ on the Macintosh_ by Dave Mark
     Addison Wesley Publishing, 1993 ISBN: 0-201-62204-1

     An introduction to C++, best if you already understand C.
     I’d consider this an unofficial "part 2" to Dave’s Learn C
     book.  Includes a limited version of Symantec C++ 6.0.

   _The C Programming Language_ 2nd ed. by Brian Kernighan
     and Dennis Ritchie, Prentice Hall, 1988 ISBN: 0-13-110362-8

     The definitive reference for the C language.  A must have.

   _The C++ Programming Language_ 2nd ed., by Bjarne Stroustrup
     Addison Wesley Publishing, 1991 ISBN: 0-201-53992-6

     As close to a definitive reference for the C++ language as
     exists.  Very important reference, but reads like stereo
     instructions.  Should not be considered an introduction.

Learning the Toolbox

   _Macintosh Programming Techniques_ by Dan Parks Sydow
     M&T Books, 1994 ISBN: 1-55828-326-9

      One of the best introductions to macintosh programming.
      Introduces windows, menus, etc.  Assumes a working knowledge
      of C.  Includes a floppy with all example source code, and
      an electronic tutorial.

    _Macintosh Programming Primer_ by Dave Marks

      Volumes one and two.  A good introduction to macintosh programming,
      and what I started with.  The Mac toolbox has changed a lot since
      Dave wrote this so make sure you DL the "updates" to the included
      code that brings it up to 1994 specs.

Learning an Environment

   _Symantec C++ for the Macintosh: The Basics_ by John May
     & Judy Whittle, M&T Books, 1993 ISBN: 1-55828-276-9

     A good introduction to Symantec’s C++ environment, one of the
     best programming environment’s for the mac (IMHO).  Reintroduces
     basic C++ concepts and the environment in detail.  Includes
     example source code on enclosed floppy disk.

   _Power Macintosh Programming Starter Kit_ by Tom Thompson
     Hayden Books, 1994 ISBN: 1-56830-091-3

     A good introduction to MetroWerk’s CodeWarrior, the other best
     programming environment for the mac, the only one to use if you’re
     building PPC code, and my current favorite.  The enclosed CD
     has a limited version of CodeWarrior (you can only work on
     the projects included in the disc – can’t create new ones),
     and example code.  Covers a lot of toolbox issues that are
     not explored in other introductory books and the PPC architecture
     in detail.  Assumes working knowledge of C, and the toolbox.


From: samr… (Samrobb)

A couple of my favorites that Nick missed:

    _Macintosh Programming Secrets, Second Edition_ by Scott Knaster
      & Keith Rollin, Addison Wesley, 1992 ISBN: 0-201-58134-5

      A good book if you’re interested in seeing some of the more…
      interesting… stuff you can do on a Mac.  C source code included,
      with a lot of helpful inisght into some neat tasks and tricks that
      are not intuitively obvious.

    _How To Write Macintosh Software, Third Edition_ by Scott Knaster,
      Addison Wesley, 1992 ISBN: 0-201-60805-7

      An OUTSTANDING overview of Macintosh software, from a technical
      point of view.  An excellent guide to debugging on the Mac, with
      detailed explanations of how to examine and understand the code
      that your compiler generates.  Written well enough that even a
      non-assembler type like myself can understand what they’re saying.

    _Comprehensive C_ by David Spuler, Prentice Hall, 1992
      ISBN: 0-13-156514-1

      Picked this one up in Australia, so you might have trouble finding
      it elsewhere.  A *very* good guide to ANSI standard C, covering all
      the various libraries in detail.  Good chapters on portability and
      reusability of code, and general debugging techniques.  A special
      appendix detailing the differences between C and Pascal for anyone
      moving between languages.  The first 6 chapters or so are an      
      in-depth look at all the various C keywords for flow control,
      variable assignments, etc.  Geared more towards a UNIX type
      environment, but a good book for anyone wanting to know more about
      C nonetheless.



From: ni… ( nick.c )
Newsgroups: comp.sys.mac.programmer,comp.sys.mac.programmer.codewarrior
Subject: Re: Books/Reference: opinions needed!!
Date: Sun, 25 Sep 94 01:28:48 GMT
Organization: The Pitt, Chemistry
References: <36282p$…>

In Article <36282p$…>, st… (Robert)

>Inside Macintosh: Overview – worth it or not?  necessary?  What Inside mac
>books are absolutely essential for any mac programmer?

    A good introduction to the general structure of the essentials of
      a mac program.  Read it – once.  Not necessary, but helpfull.

    The essential NIM?  Depends on what you’re doing.  In general I’d
      say Toolbox, More Toolbox, Imaging with Quickdraw, and Files.
      I found "Text" very usefull, not sure I’d call it essential.
      Some folks say "Memory" is essential, not sure I’d agree.

>Power Macintosh Programming Starter Kit (book + CD)  Anyone used it?  Is it
>useful for people who have, say, CW gold but no PowerPC?  What is the "special"
>version of MW CodeWarrior included on the CD like?  (i.e. how stripped down?)

    A neat book, it discusses some issues unique to the Power Mac that
      I know of no other source for.  It also presents some unique mac
      programming techniques (eg Rez) that are not usually brought up
      in introductory books.  The version of CW included will only allow
      you to open existing projects, not create new ones.  There are
      example projects on the CD, so you have a fully functional environment
      for learning/evaluating CW – but you won’t be able to use it to
      generate your own projects.  I’d recommend this book to someone
      who wants to familiarize themselves with the CW environment, or
      is considering buying CW, or who has an interest in programming
      for the powermac.  I would not recommend this for someone entirely
      new to mac programming.

>Other books:  (How suitable for complete neophytes?  How "good" in general?)

>Think THINK C by Dan Parks Sydow

    It’s been highly recommended on the net, and Dan is a good author,
      but I haven’t read it.

>Macintosh Programming for Dummies by Dan Parks Sydow
>The C Programming Primer from Dave Mark

    A little out of date, but it’s what I learned with, and I’d still
      recommend it for someone who knows C but is unfamiliar with
      programming on the mac.  Written in plain old english,
      it presents the concepts and implementation of basic macintosh
      programming techniques such as how to use menus and how to
      manage windows.  It’s still very relevant, and extremely well

>Learn C on the Macintosh by Dave Mark

    The mac toolbox is a collection of rom "tools" that you use to
      generate many of the common elements of the macintosh interface:
      both it’s visible interface and it’s "method" for dealing with
      user interactions.  A program is a recipe for getting a job
      done that the computer will read and follow.  You can tell the
      computer to use the "tools" in the rom toolbox as well as other
      actions but you have to tell the computer in a language it’ll
      understand.  The most common language for creating these recipes
      on the mac is C.  You have to learn to a language before you
      can do anything else, if you choose to learn C, Dave Mark’s book
      is a clear, effective, and well structured introduction to that
      language.  Recommended as the first book you buy to learn macintosh

>Learn C++ on the Macintosh by Dave Mark

    C++ is a superset of C, and should not be the first language you
      learn.  This was one of two books I read when I learned C++,
      and I recommend it, however I’d consider this book the un-official
      "volume 2" to Dave Mark’s _Learn C on the Macintosh_.  Learn
      C first, then learn the toolbox.  Program for a while, and when
      you’re confident with that this book is a good intro to the joys
      and frustrations of a new *style* of programming called OOP.
      C++, an enhanced version of C, is a good choice to implement
      that style.

>Symantec C++ Programming for the Macintosh  by ???

    Eh.  A good introduction to the Symantec environment, and a handy
      reference – but not a must have.  It general learning the compiler
      is the easy part, learning what you can do with it – that’s the

    Does re-introduce a lot of C++ concepts, but not the place to learn

>How to Write Macintosh Software, Third Edition
>"Macintosh Programming Secrets" 2nd edition by ???

    A good, *fun* book that includes so many "in-jokes" it’s hard
      to read with a straight face.  I don’t think this is intended
      as a "first" book on the toolbox, but it’s good supplemental
      reading – and a lot of fun to read.

- Hide quoted text — Show quoted text -

>Debugging Macintosh Software With MacsBug
>the Waite Group’s C Primer Plus

read more »

posted by admin in Uncategorized and have Comments (4)

Re: want editText numeric only

In article <39oike$…> jea… (Jeanne Ryan) writes:

_ >I’m trying to disallow non-numeric text in an editText field of a (modal)
_ >dialog I’m using. It appears to me that I have to have dialog pointed to
_ >by a DialogPeek pointer (to get to the DialogRecord). But beyond that
_ >I’m not having much luck. For example, I use SelIText to set the selStart
_ >and selEnd fields to 0 and 3 (I allow only a three digit number). But when
_ >I use my debugger (ThinkC), **(thePointer->textH)->selEnd is seen as

should be (**((DialogPeek) thePointer)->textH).selEnd

_ >"value has no members". In other words, I can’t access the data to use
_ >the text editor yet. I have previously accessed the data via GetDItem et
_ >al to get the value, but I can’t tell if it is non-numeric or not
_ >(letters are
_ >converted to their equivalent values, etc). I’ve only got the Inside Mac I
_ >manual as a reference, but it has no examples. Thanks in advance…

"value has no members" means you haven’t cast something to the correct type
in the debugger.

You can pre-process the events to diallow keyboard events with non-numeric
values if the TEHandle is aimed at the numeric text field. Don’t forget
leading +,-, and watch out for paste.

You can always look at the hText field of the TEHandle. It shows the
current contents of the item.

——— os… ———-
"Wendy, you were born a ninja princess, but you were kidnapped by a
band of tax accountants who raised you as their own." — Ninja C.P.A.

posted by admin in Uncategorized and have No Comments

Re: Think C user I/O messed up ?

In article <arnoudv-0811941755030…> arno… (Arnoud Verdwaald) writes:


   void  ToolBoxInit()


   Any help on this one is greatly appreciated! Thanks in advance.

   Arnoud Verdwaald.

I don’t believe you can use the stdio routines in the ANSI lib after
calling InitGraf().


Eric Brunson                                           brun…
Unix System Manager / CM2 Manager                              904.644.0188
Supercomputer Computations Research Institute      Florida State University

DISCLAIMER:  The opinions expressed herin are, not only my own, but are
also the opinions of my employer as well as those of The Florida State
University, the State of Florida and the President of the United States.

posted by admin in Uncategorized and have Comments (2)

How Do I get Think C 5.0.4


A friend of mine donated Think C 5.00 to me.  I plan to play
around with it on my powerbook 165c, but I heard that I should
really be using version 5.0.4.  How do I get this upgrade?
Is it FTPable or do I have to contact Symantech?  Do they even
still offer it?  Please email me any advice.  

Thanks in advance,

Normand Cloutier

posted by admin in Uncategorized and have Comments (3)

ThinkC 4->5 floating point quesstion.

I’m posting this question for my boss, hoping that someone
here can lend us a clue on how to fix this code to work with
THINKC version 5.  Any help, or pointers on where to look for
help, would be greatly appreciated.

Our research group operates a millimeter-wave radio telescope
which is controlled by a Macintosh IIfx programmed in Symantec
THINK C.   In response to hardware interrupts generated every 10
milliseconds (via a National Instruments 32-bit parallel digital
I/O board: NB-DIO-32F), the Mac executes some code that uses the
floating-point coprocessor (fpu).  Since the background (interrupted)
code also uses the fpu, the interrupt routine saves and restores the
state of the floating point unit.  The code used to save and restore
the fpu is given below:

void call_dvcmp(void)
/* save fpu before calling interrupt routine (dvcmp) */
   double *ptr;
   long OldA5;

   asm {
       movem.l a0-a4/d0-d7, -(sp)        /* Save cpu registers */
       move sr, -(sp)
       fsave -(sp)
       fmove fpsr, -(sp)       /* save flt-pt  status register */
       fmove fpcr, -(sp)       /* save flt-pt control register */

   OldA5 = SetCurrentA5();     /* save old A5, store current A5 */

   dvcmp();           /* THIS IS THE ACTUAL INTERRUPT ROUTINE */

   SetA5(OldA5);               /* restore A5 */

   asm {
       fmove (sp)+, fpcr       /* restore flt-pt control register */
       fmove (sp)+, fpsr       /* restore flt-pt  status register */
       frestore (sp)+
       move (sp)+, sr
       movem.l (sp)+, a0-a4/d0-d7   /* Restore cpu registers */


This code worked fine with THINK C version 4, but not with version
5.0. Using the version 5 complier, there are frequent, random errors
in floating point calculations done by the background code while the
interrupts are on.  

Does anyone know what changed between versions 4 and 5, and how I
can properly save the state of the fpu?

Thanks in advance,

PS sorry about the crosspost, I wasn’t sure how widely
has propagated.

posted by admin in Uncategorized and have No Comments

Applescript/Chooser Question

We’ve got two printers – one w/letterhead, one w/o.  Can I write a script
that will go into the chooser and select one of the two?  I want to link
it to a FM pro button.

I can get to the point where I’m bringing the chooser up, but I can’t
figure out how to select "laserwriter 8.0" and then the appropriate
printers (in a zone of about 20) in each of the boxes of the window.

Can anyone help?


Brian Lonardo
U.S. Peace Corps

posted by admin in Uncategorized and have Comments (2)

MacPerl implementation of rm?

Is there a way to simply remove a file using MacPerl?
I recall reading about a ftp site or web site with MacPerl
scripts, could someone re-post the addresses?

–Ron Smith

posted by admin in Uncategorized and have Comments (3)

how can I implement/program Plug-Ins?

How can I implement Plug-Ins into my program (like filters in the Photoshop)?
What kind of data-structures and functions do I need?
Will I need an extra program to generate the moduls (like the filters)?

Many Thanks for hints

posted by admin in Uncategorized and have Comments (7)

How many ways to stomp memory?

I have apparently found a way to step on memory that is
really tough (for me) to see. It shows up only on PPC;
the same code seems to be unbreakable on 68K.

The symptoms: I make 3 global buffers with NewPtr. One is
used by the serial driver (SerSetBuf(drivernum,buffer,size)),
the other two are used for a double-buffered input scheme
where one is being filled by PBReadAsync while the other is being
processed by other code. The buffers are all of adequate size,
or I’ll eat my hat.

Each time I use the serial driver I open it, check to make sure
the buffers match the current user settings for size, and change
them if they don’t match. After taking the data in, I do
a SerSetBuf(drivernum,buffer,0), then close the serial driver.

This all works just fine **except** for when I change buffer
sizes on a PowerMac. If the buffers are the wrong size, I call
DisposPtr(buffer), then buffer = NewPtr(newsize). And there, my
friends, I am usually greeted with an Access Fault exception. Sometimes
it happens in DisposPtr, occasionally DisposPtr survives but NewPtr

Yes, the buffers are all allocated successfully originally.
Yes, looking through the heap with MacsBug tells me that they are
the sizes they should be. Their contents are correct after use, too.
Yes, MacsBug says the heap is OK just before the call to DisposPtr.
No, the serial driver is not still open and tryng to use the buffers.
Yes, I called KillIO() to make sure before closing the driver.
Yes, there is *plenty* of application memory available.
Yes, as far as I can see (which is obviously not far enough) using
the Metrowerks PPC debugger, everything is perfect until I try
to dispose/remake the buffers

The PPC version is built with CW4.5, the 68K version is built with
MPW C. I can’t seem to make the code break on 68K; it just won’t
work in the native version on  a PowerMac. Weird.

Obviously I am stepping hard on memory somehow, because DisposPtr
is generally pretty reliable. :-) But I can’t find the smoking gun!

Any hints would be appreciated.

Mark Lankton (lank…
Laboratory for Atmospheric and Space Physics
University of Colorado

posted by admin in Uncategorized and have Comments (2)