<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Problem with "readln" statement' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Problem with "readln" statement' posted on the 'Pascal' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 14:04:19 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 14:04:19 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Problem with "readln" statement</title>
      <link>http://www.programmersheaven.com/mb/pasprog/178927/178927/problem-with-readln-statement/</link>
      <description>basically what i want to do is have a limited field.&lt;br /&gt;
if i have a string[5] i should only be able to enter 5 characters in my&lt;br /&gt;
readln, but i can enter more than that. is there a way to limit it so u&lt;br /&gt;
can only type in 5 characters?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/178927/178927/problem-with-readln-statement/</guid>
      <pubDate>Wed, 26 Mar 2003 13:11:07 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Problem with "readln" statement</title>
      <link>http://www.programmersheaven.com/mb/pasprog/178927/178929/re-problem-with-readln-statement/#178929</link>
      <description>: basically what i want to do is have a limited field.&lt;br /&gt;
: if i have a string[5] i should only be able to enter 5 characters in my&lt;br /&gt;
: readln, but i can enter more than that. is there a way to limit it so u&lt;br /&gt;
: can only type in 5 characters?&lt;br /&gt;
: &lt;br /&gt;
Hey there.  There is also another way of reading input from the keyboard.  You can use Repeat Until Keypressed and then obtain the character pressed by assigning it to a variable (Press:=Readkey;).  These commands are held in the Crt unit ;o) Hope that helps ya out.  &lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Repeat
Repeat Until Keypressed;  {Wait for keypress}
Press:=Readkey;           {Obtain character}
Write(Press);             
Str:=Str+Press;           {Add character to String}
Until length(Str)=5;      
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
-SteveXP- o(-_-)o&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/178927/178929/re-problem-with-readln-statement/#178929</guid>
      <pubDate>Wed, 26 Mar 2003 13:25:41 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Problem with "readln" statement</title>
      <link>http://www.programmersheaven.com/mb/pasprog/178927/178956/re-problem-with-readln-statement/#178956</link>
      <description>: Hey there.  There is also another way of reading input from the keyboard.  You can use Repeat Until Keypressed and then obtain the character pressed by assigning it to a variable (Press:=Readkey;).  These commands are held in the Crt unit ;o) Hope that helps ya out.  &lt;br /&gt;
: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: Repeat
: Repeat Until Keypressed;  {Wait for keypress}
: Press:=Readkey;           {Obtain character}
: Write(Press);             
: Str:=Str+Press;           {Add character to String}
: Until length(Str)=5;      
: &lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
ReadKey is a blocking function, so you dont need that extra repeat until keypressed loop in there.  It is actually a good idea to have it in conjunction with timeslice code though, since that'll stop your program from using 100% of the CPU.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/178927/178956/re-problem-with-readln-statement/#178956</guid>
      <pubDate>Wed, 26 Mar 2003 14:59:58 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Problem with "readln" statement</title>
      <link>http://www.programmersheaven.com/mb/pasprog/178927/186829/re-problem-with-readln-statement/#186829</link>
      <description>: : Hey there.  There is also another way of reading input from the keyboard.  You can use Repeat Until Keypressed and then obtain the character pressed by assigning it to a variable (Press:=Readkey;).  These commands are held in the Crt unit ;o) Hope that helps ya out.  &lt;br /&gt;
: : &lt;br /&gt;
: : &lt;pre class="sourcecode"&gt;
: : Repeat
: : Repeat Until Keypressed;  {Wait for keypress}
: : Press:=Readkey;           {Obtain character}
: : Write(Press);             
: : Str:=Str+Press;           {Add character to String}
: : Until length(Str)=5;      
: : &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: ReadKey is a blocking function, so you dont need that extra repeat until keypressed loop in there.  It is actually a good idea to have it &lt;br /&gt;
in conjunction with timeslice code though, since that'll stop your program from using 100% of the CPU.&lt;br /&gt;
: &lt;br /&gt;
I think it doesn't work in this easy way, becouse you have to check&lt;br /&gt;
if the key is a valid character and the user must have a chance to edit his string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/178927/186829/re-problem-with-readln-statement/#186829</guid>
      <pubDate>Sat, 03 May 2003 12:27:21 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Problem with "readln" statement</title>
      <link>http://www.programmersheaven.com/mb/pasprog/178927/186855/re-problem-with-readln-statement/#186855</link>
      <description>: basically what i want to do is have a limited field.&lt;br /&gt;
: if i have a string[5] i should only be able to enter 5 characters in my&lt;br /&gt;
: readln, but i can enter more than that. is there a way to limit it so u&lt;br /&gt;
: can only type in 5 characters?&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
This will work for you for any desired length:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
FUNCTION GetString( MaxLength : Byte) : String;
VAR
   Key : Char;
   S : String;
Begin
     Repeat
           Key := Readkey;
           If Key = #8 Then
           Begin
                If Length(S) &amp;gt; 0 Then Dec(S[0]);
           End
           ELSE
           If (Length(S) &amp;lt;= MaxLength) AND    { Make sure it's not too long }
              Not(Key In[#10,#13,#27]) Then   { Make sure it doesn't }
              S := S + Key;                   { include Enter &amp;amp; ESC  }
     Until (Key = #13) or (Key = #27);
     If Key = #13 Then GetString := S
        ELSE GetString := '';
End;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
This will do any string length up to 255. Below is code for a maximum length of 5 charaters.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
 S := GetString(5);
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
  Phat Nat&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/178927/186855/re-problem-with-readln-statement/#186855</guid>
      <pubDate>Sat, 03 May 2003 17:24:15 -0700</pubDate>
      <category>Pascal</category>
    </item>
  </channel>
</rss>