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,621 of 2,978   
   John Smith to Jason Burgon   
   Re: Getting a real number from the keybo   
   27 May 05 10:37:02   
   
   From: assemblywizard@gmail.com   
      
   Jason:   
      
   See a post of mine above, which gives an actual program/procedure which   
   fails--I don't need help in syntax--I don't need help building a string one   
   character at a time--all I need is for val to work on a string which has   
   been build one character at a time...   
      
   I KNOW PASCAL SYNTAX!!!   
      
   Warmest regards,   
   John   
   "Jason Burgon"  wrote in message   
   news:ETBle.138$Ax3.85@newsfe3-gui.ntli.net...   
   > "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)   

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


(c) 1994,  bbs@darkrealms.ca