[comp.sys.mac.programmer] TCL and Handle questions

j1whalen@handel.helios.nd.edu (Jon Whalen) (06/25/91)

Dear Net.mac.gurus

I have two novice Mac programmer questions.

First my environment: SE/30, sys7.0, Think C 4.0.5, also Mac LC, sys7.0,
and Think 4.0.5.

1) I'm trying to read in the contents of a data file from disk. In my project
I have a subclass of the TCL CDocument class. In the OpenFile method I read
in the contents of the file with:

    theFile->ReadAll(&theData);     /* ReadAll() creates the handle */

Later on, I lock the handle, and de-reference it once to get a pointer 
to the data:

	HLock(theData);	/* Lock the block of memory */
	ptr = *theData;	/* Dereference the handle */

My file contains a couple of 80-byte header records, followed by float data.
I skip ahead past the header (ptr+=80 a couple of times) to get to the
data. Now I interpret the data as floats

	for( i = 0, j = 0; i < itsNumSamples; i++, j+=4 )
	{
		(*itsSamples)[i] = *(float *)&(ptr[j]);

Now, this works fine on my SE/30 at work, but when I try the same thing
on my LC, as soon as j passes 8191, the data is junk. This is obviously
very suspicious (;-), so I gather I'm missing something obvious about 
pointer arithmetic on the LC (related to the 16-bit addressing?).

Can anyone shed any light?

2) I have a Panorama which is Supervised by a ScrollPane, I would like to
be able to resize the Panorama at some point in my program after installing
it in the ScrollPane. I tried using SetBounds() on the Panorama object, which
does appear to update the ScrollBars idea of the size of the Panorama, but
I can't draw anything after that! It would appear that I'm mucking up
the coordinate system, although I don't know how or why :-(

In my Panorama::Draw() method:
	...

	GetBounds( &bounds );
	bounds.right = numSamps;  /* top and left are 0 */
	bounds.bottom = 156;
	SetBounds( &bounds );

	...

If I can't use SetBounds, what should I use to resize the thing on the
fly?

Thanx in advance for any enlightenment!

--jon (I should stick to Unix) whalen
--
--------------------------------------------------------------------------------
 Jon Whalen @ U. of Notre Dame | At the moment, I have absolutely nothing to
 j1whalen@handel.helios.nd.edu | say. (Which is probably for the best.)
--------------------------------------------------------------------------------