home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,631 of 2,978   
   John Smith to abuse@telia.com   
   Re: Getting a real number from the keybo   
   27 May 05 14:52:28   
   
   From: assemblywizard@gmail.com   
      
   That is NOT reading a string of digits and a decimal point (a REAL number),   
   it reads a SINGLE digit--that my friend--is an INTEGER!   
      
   John   
   "Björn Felten"  wrote in message   
   news:fxMle.25723$d5.175503@newsb.telia.net...   
   >> Have you ran your code, can you do math with the real which comes from   
   >> the sting... does it work if you enter a decimal point in the string?   
   >> Try it...   
   >   
   >    Yes, yes, yes and yes. In case you missed it the first time, here's   
   > what I suggested:   
   >   
   > {$N+}{$X+}   
   > uses crt;   
   >   
   > var   
   >    ch:  char;   
   >    ctr: integer;   
   >    s:   string;   
   >    r:   extended;   
   >   
   > BEGIN   
   >    while ch <> #13 do   
   >       BEGIN   
   >          inc(ctr);   
   >          ch := readkey;   
   >          write(ch);   
   >          s[ctr] := ch;   
   >      END;   
   >      s[0]:=char(ctr-1);   
   >      val(s, r, ctr);   
   >      writeln('r = ', r:8:8);   
   > END.   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca