Help with Macintosh programming

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

Archive for June, 2011

Weird Errors With Code

I recently wrote a vector template class for a program I am writing.  I
declare vectors in a few parts of my program but when I try to declare a
vector as a data member of another class, I get the errors below.  The
vector is declared exact same way as the other vectors in my program and
yet only it causes errors.  Any ideas why I get the errors in one part
of my program but not another?

-Brandon

Error   : ‘;’ expected
particle.h line 9   vector<float> pos(3);

Error   : declaration syntax error
particle.h line 11   private:

Error   : declaration syntax error
particle.h line 13   };

Here is the file that causes the errors.  I numbered it to make it
easier to spot the lines from the error messages above.

01 #ifndef PARTICLE_H
02 #define PARTICLE_H
03
04 #include "tVector.h"
05
06 class particle
07 {
08     public:
09         vector<float> pos(3);
10         vector<float> acc(3);
11     private:
12
13 };
14
15 #endif

.
posted by admin in Uncategorized and have Comments (5)

Re: AppleScript "display dialog" and "say" don't work for me

For those of you who have been following my travails, I thought I’d share
the eventual solution.

I re-applied the Sys 8.6 updater, and all my problems have vanished.  Both
display dialog and say now work perfectly.

I had been putting that dreadful step off until last, since the updater
didn’t give me any choice in what it updated and the rest of my system has
been working fine.  (If it ain’t broke…)

But it seems that something in the 8.6 updater makes display dialog and
say work.  This is despite (1) the fact that Scripting Additions was
already at System Folder level and (2) the fact that both display dialog
and say were in the Standard Additions dictionary even before applying
this updater.

<shrug>

Many, many thanks to all who offered suggestions!

Esther Michaels

posted by admin in Uncategorized and have No Comments

Macintosh C

I’m learning Macintosh C for X via MacTech’s excellent tutorial at
http://www.mactech.com/macintosh-c/ .

Their main insistence, though, is that I use CodeWarrior for the demo
programs. I have a copy, but it’s for Classic and shamefully outdated. Is it
possible to compile the same program using Apple’s SDK? Don’t forget that I
have to port the included .rsrc files for SDK to use, too; that’s the hart
part.

Help? Thanks.

MY MAGNETIC POEM (#44)

- — -

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    | GENERATED |
>     in new generations, all will    >>>>  | 100% FREE | Will Oram
>    exalt those with a passion for   >>>>> | OF SANITY | CEO, Software Software
>    repulsive apparel and language,  >>>>> | BY A FOOL | spam…@mac.com
>          yet no conscience          >>>>  | THE INANE | WEBSITE COMING SOON
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     | WILL ORAM |

posted by admin in Uncategorized and have Comment (1)

Compile time checks for size of variable

I want to ensure at compile time that a particular variable has a given
size, namely, four bytes.  I also want to ensure at compile time that a
particular enumerated constant is not larger that a given value.  I
thought to do something like this:

#if sizeof (gMyVariable) != 4
        #error gMyVariable must have a size of 4 bytes!
#endif

#if kMyEnumeration > 255
        #error kMyEnumeration must be an 8-bit value!
#endif

So far as I can tell, however, these directives don’t accomplish my
goals.  What will?

Thanks,
Eric

posted by admin in Uncategorized and have Comments (6)

Quick way for globals coords

Hi, is there a quicker way to do the following:

    bounds = gGVBuffer_Front->portRect;
    SetPort(gGVBuffer_Front);
    LocalToGlobal((Point*)&bounds);
    SetGWorld(gGVBuffer_Back, NULL);

This code works fine, but I dont really want to waste the time calling the 3
OS calls for an offset. I looked at
(**(*(CGrafPtr)gGVBuffer_Front).portPixMap).bounds.left which equals -72 on
my mac. The above call sets bounds.left to 72. So can I use this direct
method and be fairly safe?


James Collins
jamescoll…@austarnet.com.au

posted by admin in Uncategorized and have Comments (7)

PB library conflit ?

PB link work correctly if the target is Tool.
But if the target is the Cocoa Application
the linker report this error:

/usr/bin/ld: /Users/me/Documents/MK/build/intermediates/TestAppl.build/master.o
illegal reference to symbol: _IOIteratorNext defined in indirectly referenced
dynamic library /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit

IOIteratorNext appear only one time in the same source file for both target.
Why this error in Cocoa Application but not in Tool ?

Any suggestion will be greatly appreciate.


Alain Birtz
Cegep St-Hyacinthe College
Internet a…@videotron.ca, abi…@cegepsth.qc.ca

posted by admin in Uncategorized and have Comments (2)

Code Fragment Help

Hi,

I’m trying to understand mac programming and it seems that
the equivalent to a dll on windows is a code fragment.

I’ve found a bunch of code that tells me I need to use
GetDiskFragment() and FindSymbol() to actually load
the fragment and access a procedure, but what/how
do I create a program in Codewarrior that will compile into a fragment?

Any sample code (just a skeleton) would be greatly
appreciated or a pointer to some web page :)

Many thanks,
Jedidja

posted by admin in Uncategorized and have Comment (1)

How to setTitle of a button built by Interface Builder ?

The .h file generated by Interface Builder give a IBAction reference to
the button
but how to change the title from this ?


Alain Birtz
Cegep St-Hyacinthe College
Internet a…@videotron.ca, abi…@cegepsth.qc.ca

posted by admin in Uncategorized and have Comment (1)

how to get date of local network

Is it possible to get access to the local network’s date and time
and not the local machine’s date. (Mac OS 9)

Any help would be appreciated.

thanks

posted by admin in Uncategorized and have Comments (3)

How to do HoldMemory on a routine?

Hi, I’m new to mac programming but have been doing it on PCs and Unices
for a while. I’m working in MPW with MrC.

I’m trying to write a simple application to explore information available
through the PCMCIA Card Services managers. It requires me to register a
handler routine which must not be swapped out – thus, I need to call
HoldMemory on my routine.

It’s simple to get the starting address, but how do I determine how large
the function is?

-Jim

posted by admin in Uncategorized and have Comments (2)