Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!cs.utexas.edu!uunet!mcvax!kth!sunic!chalmers!tekno.chalmers.se!d83_sven_a From: d83_sven_a@tekno.chalmers.se (Sven (Sciz) Axelsson) Newsgroups: comp.sys.mac.programmer Subject: Re: Who has hacked numeric TEdit?. Message-ID: <803@tekno.chalmers.se> Date: 2 Jun 89 16:33:44 GMT References: <1076@mailrus.cc.umich.edu> <11722@well.UUCP> <16413@paris.ics.uci.edu> <25190@agate.BERKELEY.EDU> Organization: Chalmers Univ. of Technology, Gothenburg, Sweden Lines: 41 In article <25190@agate.BERKELEY.EDU>, lippin@jif.berkeley.edu (The Apathist) writes: > Recently Alastair Milne wrote: > [...] >> Now for the nasty part. I assuming we've been thinking so far about the >> entry of integers. What about real numbers? I may just have missed it, but >> I don't recall seeing any standards in I-M for real number format (beyond >> the settings of components that differ between countries.) Having worked >> on CAI material for some years, where such entry has to be made very >> tolerant for students who've never used a computer before, I can attest the >> number of difficulties to consider. Are there any standards for this? > > If you use the SANE routines (Str2Dec and a call to fp68k) to convert > strings to numbers, you get error codes if the input isn't right. I > haven't seen much documentation on how to use SANE, but it's not too > hard to figure out from the Apple Numerics Manual (which I've only > seen the preliminary edition of), and from looking through the files > and the math libraries (in LSC; your development system may > vary.) I found it worth knowing -- the routines are very versatile, > and they make your code more internationally compatible. I even use > the SANE routines to check the validity of integer input. > > In addition to using the SANE checks, you should, of course, check the > range of your input, and also check that it is not a NAN (that is, a > not-a-number). How about using the new script manager routines Str2Format and FormatStr2X? They provide a totally general means of inputting numbers in any format using templates as in 4th Dimension, Excel etc. (i.e. you can input a telephone number as (123) 4567-890 and get back then numerical 1234567890). I haven't actually used these, but from reading the Script Manager manual that was posted to comp.binaries.mac a while ago they sure look useful. You might have some problems getting the glue to use these if you don't use MPW though. +-------------------------+--------------------------------+------------------+ | Sven Axelsson | d83_sven_a@tekno.chalmers.se | DISCLAIMER: | | dep:t of Linguistics | (^^ best ^^) | | | univ. of Gothenburg | dlv_sa@hum.gu.se | This is not | | SWEDEN | usdsa@seguc21.bitnet | a disclaimer. | +-------------------------+--------------------------------+------------------+