<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Pascal Timer' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Pascal Timer' posted on the 'Pascal' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 07:28:16 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 07:28:16 -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>Pascal Timer</title>
      <link>http://www.programmersheaven.com/mb/pasprog/414746/414746/pascal-timer/</link>
      <description>I'm sorry to disturb you...&lt;br /&gt;
There's this little game I'm developing and I'm stuck.&lt;br /&gt;
&lt;br /&gt;
So the game is about guessing a random number and I want to put a timer to see how long did the user to guess the number.&lt;br /&gt;
&lt;br /&gt;
Here's the code for the timer:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;Procedure Timer ;
 Begin
  time := 0 ;                  
 While a &amp;lt;&amp;gt; b do
  Begin
   Writeln ('Seconds: ',time,'') ;
   Delay (1000) ;
   Inc (time) ;
   ClrScr ;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
"a" is the input number and "b" is the randomized number.&lt;br /&gt;
The problem is that the program keeps repeating the delay of 1 second and it doesn't let me input a number.&lt;br /&gt;
&lt;br /&gt;
I thought on executing the main program and the procedure at the same time but I guess there is another way of doing it.&lt;br /&gt;
&lt;br /&gt;
Here's the code for the rest of the game:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;Program Guess_the_number ;
 Uses crt ;
 var a, b, time : Integer ;
 Begin
  ClrScr ;
  Timer ;     
  b := 1 ;     
  b := random (100) ; 
  Writeln ('Write a number between 1 and 100:') ;     
  Repeat     
   Readln (a) ;      
   If a &amp;lt; b
    then Writeln ('Too small...') ;      
   If a &amp;gt; b
    then Writeln ('Too big...') ;    
  Until a = b ;
  If a = b
   then Writeln ('You did it! The correct number was ',b,'!') ;    
   Writeln ('You took ',time,' seconds to guess it.') ;
  ReadKey ;  
 End ;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
You guys have any ideas?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/414746/414746/pascal-timer/</guid>
      <pubDate>Sat, 20 Mar 2010 15:53:11 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pascal Timer</title>
      <link>http://www.programmersheaven.com/mb/pasprog/414746/414748/re-pascal-timer/#414748</link>
      <description>&lt;pre class="sourcecode"&gt;&lt;span style="color: Blue;"&gt;program guess_the_number;

var a,b,tries:byte;
    time:longint;

begin
 randomize;
 tries:=0;
 a:=succ(random(100));
 time:=meml[0:$46c]; { &amp;lt;-- Get time from system counter, it gets updated every 55ms }
 repeat
  write(#13#10'Enter a number between 1 and 100 (0 to Exit) : ');readln(b);
  inc(tries);
  if b=0 then begin writeln(#13#10'Exiting...');halt;end;
  if a&amp;lt;b then writeln('Too big...') else
  if a&amp;gt;b then writeln('Too small...');
 until a=b;
 time:=trunc((meml[0:$46c]-time)/18.2); { &amp;lt;-- calculate elapsed time }
 writeln(#13#10#13#10'You took ',time,' seconds and ',tries,' tries to guess it.');readln;
end.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/414746/414748/re-pascal-timer/#414748</guid>
      <pubDate>Sat, 20 Mar 2010 23:38:40 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pascal Timer</title>
      <link>http://www.programmersheaven.com/mb/pasprog/414746/414759/re-pascal-timer/#414759</link>
      <description>Works like charm on Turbo Pascal, although I use Free Pascal more frequently, and there the code for the system counter and the elapsed time doesn't work.&lt;br /&gt;
&lt;br /&gt;
Anyway thanks for the code for Turbo.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/414746/414759/re-pascal-timer/#414759</guid>
      <pubDate>Sun, 21 Mar 2010 11:04:37 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pascal Timer</title>
      <link>http://www.programmersheaven.com/mb/pasprog/414746/414762/re-pascal-timer/#414762</link>
      <description>&lt;pre class="sourcecode"&gt;&lt;span style="color: Blue;"&gt;program guess_the_number;
&lt;span style="color: Red;"&gt;uses windows;&lt;/span&gt;
var a,b,tries:byte;
    time:&lt;span style="color: Red;"&gt;dword&lt;/span&gt;;

begin
 randomize;
 tries:=0;
 a:=succ(random(100));
 time:=&lt;span style="color: Red;"&gt;gettickcount;&lt;/span&gt; { &amp;lt;-- Get time from system counter, it gets updated every millisecond }
 repeat
  write(#13#10'Enter a number between 1 and 100 (0 to Exit) : ');readln(b);
  inc(tries);
  if b=0 then begin writeln(#13#10'Exiting...');halt;end;
  if a&amp;lt;b then writeln('Too big...') else
  if a&amp;gt;b then writeln('Too small...');
 until a=b;
 time:=trunc((&lt;span style="color: Red;"&gt;gettickcount&lt;/span&gt;-time)/&lt;span style="color: Red;"&gt;1000&lt;/span&gt;); { &amp;lt;-- calculate elapsed time }
 writeln(#13#10#13#10'You took ',time,' seconds and ',tries,' tries to guess it.');readln;
end.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/414746/414762/re-pascal-timer/#414762</guid>
      <pubDate>Sun, 21 Mar 2010 17:20:48 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pascal Timer</title>
      <link>http://www.programmersheaven.com/mb/pasprog/414746/414786/re-pascal-timer/#414786</link>
      <description>Worked exactly like I expected to.&lt;br /&gt;
Anyway, the code I put was just a part of the original game.&lt;br /&gt;
The original has 3 difficulty modes (easy, medium and hard) and has the option of playing by tries, by time or both.&lt;br /&gt;
Grace to your resolution, I managed to do it all.&lt;br /&gt;
&lt;br /&gt;
Looks like the game will keep entertained some of my classmates (if not all)&lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
From now on, I'll do my best to make better games.&lt;br /&gt;
&lt;br /&gt;
Thanks, mate.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/414746/414786/re-pascal-timer/#414786</guid>
      <pubDate>Mon, 22 Mar 2010 14:58:22 -0700</pubDate>
      <category>Pascal</category>
    </item>
  </channel>
</rss>