[comp.sys.mac.programmer] Help

snow@dinl.uucp (john snow) (12/17/88)

I am a new Mac programmer in need of help.  I have a Mac II with color
monitor and have picked up every book I could find with 'Mac' in the
title.  While these have helped a lot, they will sometines tell me just
enough to get into trouble, with no clue as to how to get out.  So I have
come to the conclusion that I need a copy of these mystical 'Tech Notes'
that I have seen mentioned in various places.

In addition to being new to the Mac, I am VERY new to this (or any other)
network, so I'm not even sure this is going to get out.  But if it does,
I would certainly appreciate any help any of you kind people could give
me in obtaining a copy of these wounderous bits of knowledge.

Thanks

John Snow

hedstrom@uvicctr.UUCP (Brad Hedstrom) (03/15/89)

I started programming on the Mac last week using LSC and am pulling my hair
out trying to get this Picture thing to work. I want to define a small picture
(using the OpenPicture and ClosePicture QuikDraw commands) and repeat it many
times. The problem? I never get any graphics on the screen. I am using
TranSkel and working from the MultiSkel demo (MultiZoom.c) that was archived
with it. Below is the section of code where I am trying to define/draw the
picture. I would be ever so thankful for any insights that you may be able to
give me and maybe I'll even have some hair left on my head.

static Update (resized)
Boolean	resized;
{
Integer	i;
Rect	picSize, dstRect;
PicHandle	picH;	

	EraseRect (&sysWind->portRect);		/* erase window */
	DrawGrowBox(sysWind);	
	SetWindClip (sysWind);		/* set clipRgn to portRect - growbox */
	SetRect(&picSize, 0, 0, 120,100);	
	picH = OpenPicture(&picSize);	/* start "recording" picture */
	MoveTo(0,0);	
	Line(10,10);
	/* misc quikdraw command */
	ClosePicture();			/* stop "recording" */
	SetRect(&dstRect, 20, 20, 140,120);	
	DrawPicture(&picH, &dstRect);	
	ResetWindClip (sysWind);	/* restore old clipRgn */
}

Thanks for any comment or suggestions (like "pull your head out, lamo!")
-- 
_____________________________________________________________________________
Brad Hedstrom, University of Victoria, ECE Dept.
Internet:  hedstrom@sirius.uvic.ca
UUCP:   ...!{uw-beaver,ubc-vision}!uvicctr!hedstrom

dorourke@polyslo.CalPoly.EDU (David M. O'Rourke) (03/17/89)

In article <635@uvicctr.UUCP> hedstrom@uvicctr.UUCP (Brad Hedstrom) writes:
>	picH = OpenPicture(&picSize);	/* start "recording" picture */

  I don't have IM right in front of me, but I believe you mean

  picH = OpenPicture(picSize); 

I don't think the picsize rect parameter
is a var, I think OpenPicture wants the parameter to be call by value,
but I could be wrong since I'm going from memory, any comments from
anyone who's not too lazy to acutally look this thing up???
-- 
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|/////////////////////////////////////////
David M. O'Rourke____________________|_____________dorourke@polyslo.calpoly.edu
|       It's only 1's & 0's, so how difficult can Computer Science be?        |
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::|

lim@iris.ucdavis.edu (Lloyd Lim) (03/19/89)

In article <9461@polyslo.CalPoly.EDU> dorourke@polyslo.CalPoly.EDU (David M. O'Rourke) writes:
>In article <635@uvicctr.UUCP> hedstrom@uvicctr.UUCP (Brad Hedstrom) writes:
>>	picH = OpenPicture(&picSize);	/* start "recording" picture */
>
>  I don't have IM right in front of me, but I believe you mean
>
>  picH = OpenPicture(picSize); 
>
>I don't think the picsize rect parameter
>is a var, I think OpenPicture wants the parameter to be call by value,
>but I could be wrong since I'm going from memory, any comments from
>anyone who's not too lazy to acutally look this thing up???

&picSize was correct (for LSC at least).  OpenPicture does take a value
parameter but remember this is C!  All variables greater than 4 bytes in size
are passed by pointers.  I don't use MPW so I can't vouch for that but I see
no reason why it would be different for rects.  I know - you just forgot -
you didn't really mean to say that in your posting.  :-)

+++
Lloyd Lim     Internet: lim@iris.ucdavis.edu
              Compuserve: 72647,660
              US Mail: 146 Lysle Leach Hall, U.C. Davis, Davis, CA 95616

cleon@ut-emx.UUCP (Doug McNaught) (03/20/89)

> >	picH = OpenPicture(&picSize);	/* start "recording" picture */
>> I don't think the picsize rect parameter
>> is a var, I think OpenPicture wants the parameter to be call by value,
>> but I could be wrong since I'm going from memory, any comments from
>> anyone who's not too lazy to acutally look this thing up???
>> -- 
 As I said in the summary, OpenPicture does take a rect as a value (not VAR)
parameter, BUT pascal passes composite objects bigger than 32 bits by reference
anyway, so the ampersand *should* be there. 

Doug Mcnaught   cleon@emx.utexas.edu (campus)
university of texas at austin

keith@Apple.COM (Keith Rollin) (03/20/89)

In article <9461@polyslo.CalPoly.EDU> dorourke@polyslo.CalPoly.EDU (David M. O'Rourke) writes:
>In article <635@uvicctr.UUCP> hedstrom@uvicctr.UUCP (Brad Hedstrom) writes:
>>	picH = OpenPicture(&picSize);	/* start "recording" picture */
>
>  I don't have IM right in front of me, but I believe you mean
>
>  picH = OpenPicture(picSize); 
>
No, Brad had it right; the ampersand should be there.

The rest of the program isn't here so I can't be sure, but I think the problem
was that the DrawPicture() command used was something like:

	DrawPicture(&picH);

when it should have been:

	DrawPicture(picH);

The actual handle needs to be passed, not a pointer to it.

------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

anthonyt@castor.usc.edu (Anthony Tieu) (04/04/89)

I am writing an init to keep users from writing on to the hard disk.
I would like to know how to detect and obtain the last file or folder
that was created, so I can delete it. Any comments is welcome..

anthony tieu 

svc@well.UUCP (Leonard Rosenthol) (04/07/89)

In article <3369@nunki.usc.edu>, anthonyt@castor.usc.edu (Anthony Tieu) writes:
> I am writing an init to keep users from writing on to the hard disk.
> I would like to know how to detect and obtain the last file or folder
> that was created, so I can delete it. Any comments is welcome..
> 
	It seems to me that is the DEFINATELY the wrong approch to the problem!
If I were doing this (which I am not, thank god) I would simply patch _Open
and _Create so that if a appl tries to open a file it is returned ReadOnly and
_Create always returns an error so no files are created.  You might be careful
with these as this would mean that NOTHING could write to the disk (including
the OS, Inits, DA's ,etc.)

-- 
+--------------------------------------------------+
Leonard Rosenthol        |  GEnie : MACgician
Lazerware, inc.          |  MacNet: MACgician
UUCP: svc@well.UUCP      |  ALink : D0025

dplatt@coherent.com (Dave Platt) (04/08/89)

In article <11251@well.UUCP> svc@well.UUCP (Leonard Rosenthol) writes:
> In article <3369@nunki.usc.edu>, anthonyt@castor.usc.edu (Anthony Tieu) writes:
> > I am writing an init to keep users from writing on to the hard disk.
> > I would like to know how to detect and obtain the last file or folder
> > that was created, so I can delete it. Any comments is welcome..
> > 
> 
> It seems to me that is the DEFINATELY the wrong approch to the problem!
> If I were doing this (which I am not, thank god) I would simply patch
> _Open and _Create so that if a appl tries to open a file it is returned
> ReadOnly and _Create always returns an error so no files are created.
> You might be careful with these as this would mean that NOTHING could
> write to the disk (including the OS, Inits, DA's ,etc.)

Another approach would be to do as Jeff Shulman's "DiskLock" desk
accessory does... set the software-lock bit in the disk's HFS volume
structure.  This has the same effect (from the user's point of view) as
setting the write-protect tab on a floppy disk... the Finder will
display the little padlock icon in the disk and folder windows.  Of
course, a sufficiently-knowledgeable user armed with the right tools
could undo the locking... but the same user could defeat Anthony's
original idea simply by booting from a floppy disk and bypassing the
INIT entirely.

Locking an entire hard-disk will render many of the applications on it
entirely unusable.  Any application that wishes to create a scratch-file
will be unable to run (I'm thinking of MS Word in particular).  Any
application that tries to save the Clipboard to disk will have problems.
The same sort of problems will occur with Anthony's "delete the last
file created" approach, too... and perhaps even more severely.  Imagine
what Word might do if it were to create a temp file, and then (several
seconds later) find that the file had mysteriously disappeared.  Not good...
-- 
Dave Platt    FIDONET:  Dave Platt on 1:204/444        VOICE: (415) 493-8805
  UUCP: ...!{ames,sun,uunet}!coherent!dplatt     DOMAIN: dplatt@coherent.com
  INTERNET:   coherent!dplatt@ames.arpa,  ...@uunet.uu.net 
  USNAIL: Coherent Thought Inc.  3350 West Bayshore #205  Palo Alto CA 94303

tim@hoptoad.uucp (Tim Maroney) (04/08/89)

In article <3369@nunki.usc.edu>, anthonyt@castor.usc.edu (Anthony Tieu) writes:
> I am writing an init to keep users from writing on to the hard disk.
> I would like to know how to detect and obtain the last file or folder
> that was created, so I can delete it. Any comments is welcome..
 
In article <11251@well.UUCP> svc@well.UUCP (Leonard Rosenthol) writes:
>	It seems to me that is the DEFINATELY the wrong approch to the problem!
>If I were doing this (which I am not, thank god) I would simply patch _Open
>and _Create so that if a appl tries to open a file it is returned ReadOnly and
>_Create always returns an error so no files are created.  You might be careful
>with these as this would mean that NOTHING could write to the disk (including
>the OS, Inits, DA's ,etc.)

Unless, of course, someone reboots from a floppy.  Any INIT based
approach to security is trivial to defeat unless you remove the floppy
drive from the Macintosh case.  (I think it will still boot then, as
long as there's something bootable on SCSI.)  There's a product whose
name I forget that password protects volumes by putting code in their
boot blocks -- that one requires more technical expertise and time to
defeat.

Anyone who would be put off by a security INIT would probably be
equally daunted by a little sign on the front saying that the CIA is
monitoring the computer and will assassinate anyone who tries to
change the disk.
-- 
Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim
"As I was walking among the fires of Hell, delighted with the enjoyments of
 Genius; which to Angels look like torment and insanity.  I collected some of
 their Proverbs..." - Blake, "The Marriage of Heaven and Hell"

ech@pegasus.ATT.COM (Edward C Horvath) (04/12/89)

From article <11251@well.UUCP>, by svc@well.UUCP (Leonard Rosenthol):
> In article <3369@nunki.usc.edu>, anthonyt@castor.usc.edu (Anthony Tieu) writes:
>> I am writing an init to keep users from writing on to the hard disk.
>> I would like to know how to detect and obtain the last file or folder
>> that was created, so I can delete it. Any comments is welcome..
>> 
> 	It seems to me that is the DEFINATELY the wrong approch to the problem!
> If I were doing this (which I am not, thank god) I would simply patch _Open
> and _Create so that if a appl tries to open a file it is returned ReadOnly and
> _Create always returns an error so no files are created.  You might be careful
> with these as this would mean that NOTHING could write to the disk (including
> the OS, Inits, DA's ,etc.)

Would that it were that simple!  You also have to trap PBCatMove,
PBSetCatInfo, PBSetFInfo, and most of the rest of the FileMgr calls.

Of course, any app that needs a temp file will fail to run, maybe
gracefully, maybe not.

WHY ARE YOU TRYING TO DO THIS??!?!?!

=Ned Horvath=

dee@XAIT.Xerox.COM (Donald Eastlake) (04/12/89)

In article <2776@pegasus.ATT.COM> ech@pegasus.ATT.COM (Edward C Horvath) writes:
>Would that it were that simple!  You also have to trap PBCatMove,
>PBSetCatInfo, PBSetFInfo, and most of the rest of the FileMgr calls.

Isn't there a low memory hook that gives you control on all
FileMgr calls?
-- 
	+1 617-969-9570		Donald E. Eastlake, III
	ARPA: dee@XAIT.Xerox.COM    usenet:  {cbosg,decvax,linus}!cca!dee
	AppleLink:  D2002	Box N, MIT Branch PO, Cambridge, MA 02139 USA

jdavid@pnet51.cts.com (Jon Davidson) (07/15/89)

I am not to good at C programming on the mac and I am looking for a simple
example that will launch a application from a application like the launch
command in Microphone.  I just want it to be a simple program like

Main()
  {

"Please fill in this part for me"

  }


UUCP: {amdahl!bungia, uunet!rosevax, chinet, killer}!orbit!pnet51!jdavid
ARPA: crash!orbit!pnet51!jdavid@nosc.mil
INET: jdavid@pnet51.cts.com