[comp.sys.mac.programmer] Need Help

mxmora@unix.SRI.COM (Matt Mora) (03/16/90)

I am in the process of writing a library routine for
Quickbasic that will allow you to call XCMD's & and 
XFCN's from any quickbasic program. The part that is tripping
me up is the callback part. 

For example: (using the code below supplied by apple's XCMDUtils)

function StringMatch;
 begin
  with paramPtr^ do
   begin
    inArgs[1] := ORD(@pattern);
    inArgs[2] := ORD(target);
    request := xreqStringMatch;
    DoJsr(entryPoint);
    StringMatch := Ptr(outArgs[1]);
   end;
 end;

where DoJsr is:

PROCEDURE DoJsr (addr : ProcPtr);
INLINE
	$205F, $4E90;	{MOVEA.L (A7)+,A0}
                        {JSR     (A0)}


When the library code starts I set entrypoint
to be the address of the procdure to handle the callback.

for example

paramPtr^.entryPoint:=@CallbackHandler;

How do I return control to the xcmd from my 
callbackhandler? RTS?

Now when I actually call the xcmd after filling in
then paramptr block, can I just do:

myXCmdhndl:=GetNamedResource('XCMD',Xcmdname);
if myXCmdHndl<> nil then
  begin 
    Hlock(myXCmdHndl);
    DoJSR(myXCmdHndl^^);
    HunLock(myXCmdHndl);
    ReleaseResource(myXCmdHndl);
  end;
end;
  
or will this blow up in my face :-)


And some other random questions.

What exactly is a zero string. Is that a C string?
And when I do ZeroToPas, Do I truncate the string if its > 255?



Thanks for any clues you can give me.



























-- 
___________________________________________________________
Matthew Mora
SRI International                       mxmora@unix.sri.com
___________________________________________________________

jg23+@andrew.cmu.edu (John Robert Gray) (08/11/90)

  Hi, I just started programming in Macintosh and I got the book Inside
Macintosh all 5 volume.  On p 17 there is a program but what is it in?
Pascal, Think C or assembly language?  Any help would be appreciated.

John Gray

stevec@Apple.COM (Steve Christensen) (08/13/90)

In article <0akn9bW00WB7AVM0lD@andrew.cmu.edu> John Robert Gray writes:
>  Hi, I just started programming in Macintosh and I got the book Inside
>Macintosh all 5 volume.  On p 17 there is a program but what is it in?
>Pascal, Think C or assembly language?  Any help would be appreciated.

It's in Lisa (you remember that computer, right?) Pascal.  You can get rid
of the {$X-} and {$U-} compiler commands as well as the {$U ...}'s in the
USES...

steve

-- 
____________________________________________________________________

  Steve Christensen             Internet:   stevec@goofy.apple.com
  Apple Computer, Inc.          AppleLink:  STEVEC
  20525 Mariani Ave, MS 81-CS   CompuServe: 76174,1712
  Cupertino, CA  95014

  "You just contradicted me."  "No I didn't."
____________________________________________________________________

francis@arthur.uchicago.edu (Francis Stracke) (09/27/90)

In article <0akn9bW00WB7AVM0lD@andrew.cmu.edu> jg23+@andrew.cmu.edu (John Robert Gray) writes:
>  Hi, I just started programming in Macintosh and I got the book Inside
>Macintosh all 5 volume.  On p 17 there is a program but what is it in?
>Pascal, Think C or assembly language?  Any help would be appreciated.

1: p 17 of WHICH VOLUME??? (Surely you're not claiming to have all 5 bound
together?)
2: It's not in C.  IM does not deal with C.
3: If it puts an _ in front of the names of Toolbox calls, it's ML.

resnick@cogsci.uiuc.edu (Pete Resnick) (09/27/90)

francis@arthur.uchicago.edu (Francis Stracke) writes:

>In article <0akn9bW00WB7AVM0lD@andrew.cmu.edu> jg23+@andrew.cmu.edu (John Robert Gray) writes:
>>  Hi, I just started programming in Macintosh and I got the book Inside
>>Macintosh all 5 volume.  On p 17 there is a program but what is it in?
>>Pascal, Think C or assembly language?  Any help would be appreciated.

>1: p 17 of WHICH VOLUME??? (Surely you're not claiming to have all 5 bound
>together?)
>2: It's not in C.  IM does not deal with C.
>3: If it puts an _ in front of the names of Toolbox calls, it's ML.

Francis, has anyone ever told you you were rude? Of course what John is
asking about is the sample program on page 17 of Volume 1, and it is in
Pascal, which was the language that the original Macintosh's had available.

Sorry for Francis's rudeness John. Pascal is the language.

pr
--
Pete Resnick             (...so what is a mojo, and why would one be rising?)
Graduate assistant - Philosophy Department, Gregory Hall, UIUC
System manager - Cognitive Science Group, Beckman Institute, UIUC
Internet/ARPAnet/EDUnet  : resnick@cogsci.uiuc.edu
BITNET (if no other way) : FREE0285@UIUCVMD

carlton@husc8.harvard.edu (david carlton) (09/27/90)

In article <1990Sep26.220029.16514@midway.uchicago.edu> francis@arthur.uchicago.edu (Francis Stracke) writes:
   In article <0akn9bW00WB7AVM0lD@andrew.cmu.edu> jg23+@andrew.cmu.edu (John Robert Gray) writes:
   >  Hi, I just started programming in Macintosh and I got the book Inside
   >Macintosh all 5 volume.  On p 17 there is a program but what is it in?
   >Pascal, Think C or assembly language?  Any help would be appreciated.

   1: p 17 of WHICH VOLUME??? (Surely you're not claiming to have all 5 bound
   together?)
   2: It's not in C.  IM does not deal with C.
   3: If it puts an _ in front of the names of Toolbox calls, it's ML.

ML?  everybody's favorite (almost) functional programming language?
gee.  standard ML?  edinburgh ML?  didn't realize that apple had
adopted it as a standard programming language.

oh, you mean machine language?  sorry - i didn't realize that.  well,
i hate to tell you, but you didn't get this right, either.  you almost
certainly mean assembly language - machine language is basically a
bunch of numbers, certainly not underscores.  assembly language is
a very close cousin, perhaps, but hardly the same thing.

sheesh.  if you're going to be a pedant, could you at least try a bit
harder?  (and, for the original poster's sake, the language was
pascal.)

on a more serious note, does anybody actually know of a version of ML
that exists for the mac?

david carlton
carlton@husc9.harvard.edu
B5 f- t w- r-

b_murphy@fennel.cc.uwa.oz.au (10/01/90)

>>    Hi, I just started programming in Macintosh and I got the book Inside
>>  Macintosh all 5 volume.  On p 17 there is a program but what is it in?
>>  Pascal, Think C or assembly language?  Any help would be appreciated.
> 
>   1: p 17 of WHICH VOLUME??? (Surely you're not claiming to have all 5 bound
>    together?)

Give the kid a break. IM 1

>   2: It's not in C.  IM does not deal with C.

So answer the question... It's in Pascal, to be precise Lisa Pascal. (It
actually says so in the program ;-)

>   3: If it puts an _ in front of the names of Toolbox calls, it's ML.

Just to be picky here, *what's* ML ?

I know how it is to start on the Mac. I did so a *while* ago, just keep
asking questions, we do too.

-- 
-o (short for On-no)

     ()/)/)()  can be  r e a c h e d  at  B_MURPHY@VAXA.UWA.OZ.AU
_____________________________________________________________________
        The net never sleeps, come to think of it, do I ever?
---->  Thinking is dangerous, subversive and leads you astray.  <----