[comp.sys.mac] StringToReal?

boz@eleazar.dartmouth.edu (John Boswell) (01/11/90)

Hi.
	I am trying to write an epr simulation program using Prototyper to
generate the Mac User-interface.  I have the simulation code that actually
does the numbercrunching working nicely, and thought I'd put a nice interface
on the program, letting Prototyper do most (all? or is that being to hopeful?)
of the work.  I have run up against a little problem with data entry:  I
made a dialog box in Prototyper to allow the user to enter in all the 
numerical parameters the user needs to run the simulation.  I generated the
Pascal code, and compiled the sucker in Think Pascal.  The problem is that
the call that actually gets the info from the dialog box (GetItext, or some
such thing), puts the data into a STRING variable.  I unfortunately need a 
REAL value here!  There would be no problem if I needed an integer, since
StringToNum would do the trick (I guess).  Does anyone know if there is
a similar function to convert to a real-type value?  Or, is there a way to
get real-types *directly* from the dialog?

	Since the dialog approach would be the best interface for entering
parameters, and I *know* *lots* of programs use that way for entering data,
I'd be *greatly* appreciative if anyone could steer me in the right direction!

Thanks in advance,

--
*************************************************************************
 John Boswell 			  	 	boz@eleazar.dartmouth.edu	
 Dept. of Chemistry		 		boz@dartCMS1.BITNET		
 Dartmouth College, Hangover, Nude Hampster  03755			

han@apple.COM (Byron Han, Project Scapegoat) (01/12/90)

In article <18429@dartvax.Dartmouth.EDU> boz@eleazar.dartmouth.edu (John 
Boswell) writes:
> the dialog box (GetItext, or some
> such thing), puts the data into a STRING variable.  I unfortunately need 
a 
> REAL value here!  There would be no problem if I needed an integer, since
> StringToNum would do the trick (I guess).  Does anyone know if there is
> a similar function to convert to a real-type value? 

In the SANE package, there is a routine, Str2Num which converts a string 
to a number.

Hope this helps.

+-------------------------------------------------------------------------+
| Disclaimer: Apple has no connection with my postings.                   |
+-------------------------------------------------------------------------+
Byron Han, CommToolbox Scapegoat  "DeAnza 3 - R.I.P. - 10/17/89 5:04PM"
Apple Computer, Inc.              --------------------------------
20525 Mariani Ave, MS 69L         Internet: han@apple.COM
Cupertino, CA 95014               UUCP:{sun,voder,nsc,decwrl}!apple!han
--------------------------------  GENIE:BYRONHAN   CompuServe:72167,1664
ATTnet: 408-974-6450              Applelink:HAN1   HAN1@applelink.apple.COM
---------------------------------------------------------------------------

ralph@computing-maths.cardiff.ac.uk (Ralph Martin) (01/18/90)

Byron Han, of Apple, writes:

>In article <18429@dartvax.Dartmouth.EDU> boz@eleazar.dartmouth.edu (John 
>Boswell) writes:
>> the dialog box (GetItext, or some
>> such thing), puts the data into a STRING variable.  I unfortunately need a 
>> REAL value here!  There would be no problem if I needed an integer, since
>> StringToNum would do the trick (I guess).  Does anyone know if there is
>> a similar function to convert to a real-type value? 
>
>In the SANE package, there is a routine, Str2Num which converts a string 
>to a number.

There's a problem with this, surely. Str2Num expects the decimal point to be
a point (full stop). In some countries, it may be a comma etc, so Str2Num
will not be appropriate, and more fancy things will be needed from the Script
Manager package.  

Comments?

Ralph

d88-jwa@nada.kth.se (Jon Watte) (01/24/90)

In article <1132@cf-cm.UUCP> ralph@computing-maths.cardiff.ac.uk (Ralph Martin) writes:
>Byron Han, of Apple, writes:

>>In the SANE package, there is a routine, Str2Num which converts a string 
>>to a number.

>There's a problem with this, surely. Str2Num expects the decimal point to be
>a point (full stop). In some countries, it may be a comma etc, so Str2Num

Well, you could always parse the string, look for the "comma, point,
whatever" symbol and change it for the dot. I believe the symbol(s)
to look for are easily obtainable from itl or similar resources.
(No IM nor TechNotes on this Unix system :-)

h+
-- 
   ---  Stay alert !  -  Trust no one !  -  Keep your laser handy !  ---
             h+@nada.kth.se  ==  h+@proxxi.se  ==  Jon Watte
                    longer .sig available on request

kazim@Apple.COM (Alex Kazim) (01/25/90)

In article <1132@cf-cm.UUCP> ralph@computing-maths.cardiff.ac.uk (Ralph Martin) writes:
>
>Byron Han, of Apple, writes:
>
>>In the SANE package, there is a routine, Str2Num which converts a string 
>>to a number.
>
>There's a problem with this, surely. Str2Num expects the decimal point to be
>a point (full stop). In some countries, it may be a comma etc, so Str2Num
>will not be appropriate, and more fancy things will be needed from the Script
>Manager package.  

Really?  I had always thought SANE took care of this (by looking at the INTL
0 resource for the various commas 'n things).  In fact, IM Vol 5, p 302 says
SANE routines will always return the correct result regardless of the 
script.

I didn't write either SANE or Script Mgr, but we may have a bug here.  

======================================================================
Alex Kazim, Apple Computer
Bo knows programming
====================================================================== 

silverio@brahms.berkeley.edu (C J Silverio) (02/02/90)

Ralph Martin writes:
   While I'm at it, I'll fire off another broadside. What the heck is
   Apple doing with its new "develop" magazine? This is now yet another
   place to have to read .... Apple should really put its energies into
   producing ONE definitive work of documentation which is UP-TO-DATE,
   and contains both tutorial and reference material integrated in a
   sensible fashion, rather than glossy magazines. Programmers need
   information, not publicity/sales type material.

I agree that Inside Mac is currently "a mess." but...

I just got my copy of _develop_ and it is really quite excellent. Jam
packed with good quality sample source code, each article is an
advanced-level tutorial for the Mac programmer who wants to know "How
do I use ..." In many cases, the articles are written by the people
that wrote the system software in question. The editing is quite good
-- no stupid jokes, no cruddy english, straightforward and
well-written. This magazine is everything that MacTutor would wish to
be: accurate, good-looking, and correctly spelled. There just isn't
any "publicity/sales type material," either.

Frankly, I'm not all that sure what to make of the CD-ROM that came
with it, but this is mostly because I don't have a CD-ROM player. The
same code is available from APDA on regular disks.

I am really quite impressed with this trend in tech support materials.
Recently we have seen the introduction of DTS sample code, well-
written and very applicable to day-to-day programming; TechNotes in a
HyperCard stack, making them TONS easier to find and use; and now
_develop._

Now if ONLY we could eliminate the delta document in Our Time.....

Subscription information:
develop
pobox 3725
San Diego, CA 92025 USA.
FAX Subscription Line: 619-485-7094

One year is $30 for USA, US$50 for anywhere else. Check, Money Order,
or credit card info must be enclosed, no cash or "Bill Me" orders.

You do not have to be an APDA member or Official-type Developer to
subscribe.