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,630 of 2,978    |
|    John Smith to All    |
|    Re: Getting a real number from the keybo    |
|    27 May 05 14:24:29    |
   
   From: assemblywizard@gmail.com   
      
   Never mind bonehead:   
   I have written a program which demonstartes ALL three--null string   
   array--pascal string--and a "real" string...   
   ... this DOES COMPILE--this DOES RUN...   
   NONE OF THE METHODS WORK and the real is always returned from val as ZERO!   
   Simply change this so one of the methods work, and the real is returned...   
   by reading in the character ONE CHAR at a time...   
   --RUN IT BEFORE YOU REPLY--   
   {******* CODE BEGINS ******}   
   program test;   
   {$X+}   
      
   USES Crt, Strings;   
      
   VAR   
    a: array[0..80] of char; { as null string compatable array }   
    b: array[1..80] of char; { as a Pascal String }   
    s: string[80]; { as a string }   
    ch: Char;   
    ctr: Integer;   
    r: real;   
      
   BEGIN   
   { first demo as a null string compatable array }   
    ch := ' '; { give it something NOT a CR }   
    ctr := 0; { null terminated string index }   
    while ch <> #13 do   
    begin   
    ch := readkey;   
    write(ch);   
    a[ctr] := ch;   
    inc(ctr);   
    end;   
    writeln;   
    writeln(a);   
    val(a, r, ctr);   
    writeln(r:8:8);   
      
   { second demo as a pascal string array }   
    ch := ' '; { give it something NOT a CR }   
    ctr := 1; { Pascal string index }   
    while ch <> #13 do   
    begin   
    ch := readkey;   
    write(ch);   
    b[ctr] := ch;   
    inc(ctr);   
    end;   
    writeln;   
    writeln(b);   
    val(b, r, ctr);   
    writeln(r:8:8);   
      
   { third demo as a string }   
    ch := ' '; { give it something NOT a CR }   
    ctr := 1; { Pascal string index }   
    while ch <> #13 do   
    begin   
    ch := readkey;   
    write(ch);   
    s[ctr] := ch;   
    inc(ctr);   
    end;   
    writeln;   
    writeln(s);   
    val(s, r, ctr);   
    writeln(r:8:8);   
   END.   
   {******* CODE ENDS *******}   
      
   John   
      
   "Jim Leonard"
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca