home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!spool.mu.edu!umn.edu!csus.edu!netcom.com!wysocki
- From: wysocki@netcom.com (Chris Wysocki)
- Subject: Re: International Number Formats
- Message-ID: <1992Dec15.050212.2405@netcom.com>
- Organization: Connectix Corporation, San Mateo, CA
- References: <4TS=Cj-@engin.umich.edu>
- Date: Tue, 15 Dec 1992 05:02:12 GMT
- Lines: 40
-
- In article <4TS=Cj-@engin.umich.edu> Michael F. Kamprath <kamprath@space-grant.sprl.umich.edu> writes:
-
- >I'm trying to decipher IM VI with respect to how to convert a floating point
- >number into a string to be displayed in the correct format (as set by the Nums
- >&Date control panel) and vice versa (that is, strings --> numbers).
-
- Use the Script Manager routine Str2Format to convert a format string
- (such as "#,###,###;-#,###,###") to a canonical NumFormatString (which
- describes the format string in a script-independent manner), then use
- FormatX2Str and FormatStr2X to convert between 80-bit SANE extendeds
- and formatted strings. You can obtain the necessary NumberParts table
- from the 'itl4' resource via:
-
- Handle itl4H;
- NumberParts parts;
-
- itl4H = IUGetIntl(4);
- FailNILRes(itl4H);
- parts = *(NumberParts *)(*itl4H + (**(Itl4Handle)itl4H).defPartsOffset);
-
- The one trick is that you need to save the canonical NumFormatString
- returned by Str2Format in some way (e.g. in a resource), since
- Str2Format will interpret the format string differently depending on
- the current system environment (active script system, Numbers and
- Dates control panel settings, etc.) To avoid this, write a throw-away
- program that calls Str2Format and saves the resulting NumFormatString
- in a resource. Then, when you need to display a formatted number in
- your main program, get the saved NumFormatString resource, lock it
- down, and pass the dereferenced handle to FormatX2Str. Complete
- details about Str2Format, FormatX2Str and FormatStr2X can be found in
- the Worldwide Guide to System Software stack, available on the
- developer CDs.
-
- Chris.
- --
- ------------------------------------------------------------------------------
- Chris Wysocki Internet: wysocki@netcom.com
- Software Engineer America Online: AFA ChrisW
- Connectix Corporation CompuServe: 72010,1140
-
-