Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!apple.com!dowdy From: dowdy@apple.com (Tom Dowdy) Newsgroups: comp.sys.mac.programmer Subject: Re: print variables on screen ? Message-ID: <5960@internal.Apple.COM> Date: 2 Jan 90 18:14:08 GMT References: <1837@ultb.isc.rit.edu> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 44 In article <1837@ultb.isc.rit.edu> sfm3166@ultb.isc.rit.edu (S.F. Modi) writes: > say printf("xxx") as it defaults to the compiler window. So how do you print a variable ? for > example I want to print Well, this example might be a bit off base from what you want, but it certainly can be changed into what you want. I've seen versions of this called wprintf() that output into a scrolling window. I personally usually prefer to see things in Macsbug, because usually this code is only in for debugging. Follows is code to output printf() style into Macsbug. I use this with MPW and . Requires linking with C libraries. The runtime routines require A5, thus not too useful in VBL tasks and so forth (sorry, Tim). Uses 256 bytes of stack space for the temp string. Haven't tried this sort of thing with Lightspeed, maybe someone can convert it and let the world know. Hope this is useful to some folks out there... /* ---------------------------------------------------------- */ void debugprintf(char *sFormat, ...) /* Stolen from Geoff Coco. Take a printf style list of args, pass them on and debugstr them. Call as you would printf. */ { Str255 sOut; va_list pArgs; va_start(pArgs, sFormat); vsprintf(sOut, sFormat, pArgs); c2pstr(sOut); DebugStr(sOut); } // debugprintf Tom Dowdy Internet: dowdy@apple.COM Apple Computer MS:81EQ UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy 20525 Mariani Ave AppleLink: DOWDY1 Cupertino, CA 95014 "The 'Ooh-Ah' Bird is so called because it lays square eggs."