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,611 of 2,978    |
|    John Smith to John Smith    |
|    Re: Getting a real number from the keybo    |
|    26 May 05 14:54:10    |
   
   From: assemblywizard@gmail.com   
      
   Or, in other words, this DOES NOT work:   
   PROGRAM T;   
      
   uses crt, strings;   
      
   var   
    ch: char;   
    s: string;   
    r: real;   
    i: integer;   
      
   begin   
    ch:=#0; {just in case you were previously using it}   
    s[0]:=#0; {set string length to 0 characters}   
    while ch <> #13 do   
    BEGIN   
    ch:=ReadKey;   
    s:=s+ch;   
    END;   
    dec(s[0]);   
    {"deletes" the #13 (CR) and the end by decreasing string length}   
    val(s, r, i);   
    writeln('r = ', r:8:8);   
   end.   
      
   THIS WORKS:   
   VAR s: string;   
    r: real;   
    i: integer;   
   readln(s);   
   val(s, r, i);   
   writeln('r = ', r:8:8);   
      
   Now, how can I do that while reading ONE character at a time?   
      
   Warmest regards,   
   John   
      
   "John Smith"
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca