Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!stjhmc!p12.f56.n114.z1.fidonet.org!Chris.Gehlker From: Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) Newsgroups: comp.sys.mac.programmer Subject: RE: Drawstring Question Message-ID: <31268.275A511A@stjhmc.fidonet.org> Date: 3 Dec 90 13:13:04 GMT Sender: ufgate@stjhmc.fidonet.org (newsout1.26) Organization: FidoNet node 1:114/56.12 - AZ MAC UG, Phoenix AZ Lines: 33 > Now there is a new problem: > Since I am using a drawing Window as my output medium, I can not use > the standard output functions (printf). I want to display the values of > some variables though. Since I have to use DrawString, this seems to be > a problem. For example, how do I draw a properly formatted floating > point number?? Drawstring does not give you formatting options and > seems to require a string. How do you get around this ?? Any ideas?? I guess num2str() is a well kept secret. Apple documents it in the SANE Manual rather than in IM. Anyhoo, it's: void num2str(decform *, extended, void *); in SANE.h. A decform is a struct that set the style to normal or scientific and tells the function how many decimal points to use for rounding. You pass it an Str255 in the final argument and it fills it in for you. Then you pass it to DrawString(). See the following fragment: ... extended x = 1.2345; Str255outString; decformf; ... f.style = FIXEDDECIMAL; f. digits = 8; num2str(&f, x, outString); DrawString(outString); ... -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!56.12!Chris.Gehlker Internet: Chris.Gehlker@p12.f56.n114.z1.fidonet.org