From: assemblywizard@gmail.com   
      
   I am attempting to convert the string to a "real number" (extended, comp is   
   ok too)...   
   Hard to do math with a sting...   
      
   Warmest regards,   
   John   
      
   "Jim Leonard" wrote in message   
   news:1117138099.252081.245570@z14g2000cwz.googlegroups.com...   
   > John Smith wrote:   
   >> I have tried the following:   
   >> {$N+}{$X+}   
   >> ch: char;   
   >> i: integer;   
   >> s: array[0..80] of char;   
   >> r: extended;   
   >> BEGIN   
   >> while ctr <> #13 do   
   >> BEGIN   
   >> ch := getkey;   
   >> s[ctr] := ch;   
   >> inc(ctr);   
   >> END;   
   >> val(s, r, ctr);   
   >> writeln('r = ', r:8:8);   
   >> END;   
   >>   
   >> It doesn't work, what am I doing wrong?   
   >   
   > A lot :-) Instead, try this:   
   >   
   > 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:=getkey;   
   > s:=s+ch;   
   > END;   
   > dec(s[0]); {"deletes" the #13 (CR) and the end by decreasing string   
   > length}   
   >   
   > That will progressivly fill up string "s" with each character. You can   
   > get the length of the string with s[0] (the first byte is the length of   
   > the string).   
   >   
   > However, it is much easier to replace ALL of that with simply one   
   > statement:   
   >   
   > readln(s);   
   >   
   > As for the rest, I have no idea what you're trying to do with:   
   >   
   > val(s, r, ctr);   
   > writeln('r = ', r:8:8);   
   >   
   > ...maybe you can explain what your goal is?   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|