From: gvision@ntlworld.com   
      
   "John Smith" wrote in message   
   news:0kqle.141$wF7.5797017@news.sisna.com...   
   > Jim:   
   >   
   > That worked great, and if I use "readln(s)" val(s, r, i) works!!!   
   >   
   > So, my question is, why if I use readln will val work... and NOT when I   
   grab   
   > the string one char at a time with readkey--and is there a way I can   
   > "transform" the string read one char at a time, with readkey, to where it   
   > can be used with val?   
      
   (1) Read in each character and and construct the i/p string.   
   (2) Convert the string represention of the number with the Val() procedure.   
      
   If S is a string that = '123.45' then the following (untested) will return   
   the Real value 123.45:   
      
   function StrToReal(const S: string);   
   var   
    V: Real;   
    ErrPos: Integer;   
   begin   
    Val((S, V, ErrPos);   
    if ErrPos <> 0 then   
    ErrorAtPostion(S, ErrPos); { The ErrPos'th char of S is invalid }   
    StrToReal := V;   
   end;   
      
   As Jim says, if you're not getting (1) right then you're not going to get   
   any sensible value from Val.   
      
   --   
   Jay   
      
   Author of Graphic Vision   
   http://homepage.ntlworld.com/gvision/   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|