Path: utzoo!attcan!uunet!wuarchive!psuvax1!xavier!jackiw From: jackiw@cs.swarthmore.edu (Nick Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: Floating Point #'s as Strings in Dialogs using Think C 3.0 Message-ID: Date: 11 Jun 90 17:09:17 GMT References: <25837@netnews.upenn.edu> Sender: news@xavier.swarthmore.edu (Usenet News) Reply-To: jackiw@cs.swarthmore.edu (Nick Jackiw) Distribution: na Organization: Visual Geometry Project, Swarthmore College, PA Lines: 37 isler@grad1.cis.upenn.edu () writes: > I am writing a program in Think C 3.0 in which I would like to convert > floating point numbers to strings and place them in EditText items in > a dialog box. > sprintf(str, "%3.1f", value); > > Any suggestions? > S-K ISLER As mentioned previously, you'll need a Pascal string instead of a c-string. You may be better served by using the Toolbox, instead of C, to do your conversions for you. SANE implements the calls: procedure Str2Dec(s:DecStr;var Index:integer; var d:Decimal; var validPrefix:boolean); procedure Dec2Str(f:Decform; d:Decimal; var s:DecStr); procedure CStr2Dec(s:CStrPtr;var index:integer; var d:Decimal; var validPrefix:boolean); which will do all the necessary conversions for you. In addition to providing the appropriate types to your task, SANE is script-manager compatible, which may or may not be true of THINK C's sprintf. This means that if your application is for public use, it will format (and accept formatted numbers) appropriately to the country in which it's in use. See your SANE interface files for declarations of the individual types. -- -----Nicholas Jackiw [jackiw@cs.swarthmore.edu|jackiw@swarthmr.bitnet]----- "... Then, with an infernal shovel that increases my strength, I dig out of that inexhaustable mine whole chunks of lice, big as mountains. I split them up with an axe and I transport them in the depths of night to city streets."