<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>Pascal Forum RSS Feed (Replies Included)</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the 'Pascal' forum at Programmer's Heaven, including replies.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 05:53:45 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 05:53:45 -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>Re: Help at making a tree trunk</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431080/432378/re-help-at-making-a-tree-trunk/#432378</link>
      <description>quikcartx could you please contact me regarding a bug in a piece of Pascal code I am experiencing?  dennis dot lamb at gmail</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431080/432378/re-help-at-making-a-tree-trunk/#432378</guid>
      <pubDate>Mon, 17 Jun 2013 13:12:45 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Help at making a tree trunk</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431080/432377/re-help-at-making-a-tree-trunk/#432377</link>
      <description>quickcartx could you please contact me regarding a pascal bug I need help with?  dennis dot lamb at gmail&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431080/432377/re-help-at-making-a-tree-trunk/#432377</guid>
      <pubDate>Mon, 17 Jun 2013 13:08:24 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Help at making a tree trunk</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431080/432376/re-help-at-making-a-tree-trunk/#432376</link>
      <description>quickcartx could you please contact me regarding a pascal bug I need help with?  dennis dot lamb at gmail&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431080/432376/re-help-at-making-a-tree-trunk/#432376</guid>
      <pubDate>Mon, 17 Jun 2013 13:06:33 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>problems reading from binary files</title>
      <link>http://www.programmersheaven.com/mb/pasprog/432361/432361/problems-reading-from-binary-files/</link>
      <description>Since I have my new computer I have problems running some .pas files. More specifically when handling binary files. In the program there should be read some records into a binary files and writen records to binary files.&lt;br /&gt;
I use the functions assign, reset, read, write,etc... (classic functions for handling binary files). When reading from certain files after compiling I get a run time error (2)..&lt;br /&gt;
When I run the program on my old computer, everything works fine.&lt;br /&gt;
Does anyone recognize this problem? Solutions?&lt;br /&gt;
Thnx&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/432361/432361/problems-reading-from-binary-files/</guid>
      <pubDate>Mon, 17 Jun 2013 00:51:55 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Pascal to P-Code</title>
      <link>http://www.programmersheaven.com/mb/pasprog/432319/432319/pascal-to-p-code/</link>
      <description>Hey guys what's up?&lt;br /&gt;
&lt;br /&gt;
I was wondering.. Does anyone know where I can find a tool for converting pure Pascal to P-Code in such a way I'd be able to see the P-Code source? Don't need to run the compiled app, just want to learn more about how Pascal is compiled into P-Code.&lt;br /&gt;
&lt;br /&gt;
Thanks.&lt;br /&gt;
&lt;br /&gt;
PS not sure if it's relevant, but I'm on Mac OSX</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/432319/432319/pascal-to-p-code/</guid>
      <pubDate>Fri, 14 Jun 2013 02:13:13 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Pascal to P-Code</title>
      <link>http://www.programmersheaven.com/mb/pasprog/432318/432318/pascal-to-p-code/</link>
      <description>Hey guys what's up?&lt;br /&gt;
&lt;br /&gt;
I was wondering.. Does anyone know where I can find a tool for converting pure Pascal to P-Code in such a way I'd be able to see the P-Code source? Don't need to run the compiled app, just want to learn more about how Pascal is compiled into P-Code.&lt;br /&gt;
&lt;br /&gt;
Thanks.&lt;br /&gt;
&lt;br /&gt;
PS not sure if it's relevant, but I'm on Mac OSX</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/432318/432318/pascal-to-p-code/</guid>
      <pubDate>Fri, 14 Jun 2013 02:11:23 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Help please</title>
      <link>http://www.programmersheaven.com/mb/pasprog/432134/432271/re-help-please/#432271</link>
      <description>I got to looking at your jammed up to the left program and could see that the procedure might have another problem.  So I made a change and put it through my Free Pascal 2.6 compiler and it looks like it will run.  So here is the code:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;  procedure razmeni ( var p, q : slog );

    var
      pom : slog;

    begin
      pom := p;
      p   := q;
      q   := pom
    end;&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/432134/432271/re-help-please/#432271</guid>
      <pubDate>Fri, 07 Jun 2013 18:17:06 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Help please</title>
      <link>http://www.programmersheaven.com/mb/pasprog/432134/432171/re-help-please/#432171</link>
      <description>There are a few things you should do: 1) format your program; put some indentation in it so the lines are readable, not all jammed to the left to conserve space, 2) put some spaces between the words and lines, 3) throw some comments in there to help yourself and others read and understand your program.  Okay, now to maybe get your program to compile.&lt;br /&gt;
&lt;br /&gt;
Change&lt;br /&gt;
&lt;pre class="sourcecode"&gt;{ procedure razmeni(var p,q:integer); } procedure razmeni ( var p, q : slog );&lt;/pre&gt;  The 2 arguments that you are passing are really &lt;span style="color: Green;"&gt;record&lt;/span&gt;s and not &lt;span style="color: Red;"&gt;integer&lt;/span&gt;s.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/432134/432171/re-help-please/#432171</guid>
      <pubDate>Tue, 28 May 2013 19:57:46 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Help please</title>
      <link>http://www.programmersheaven.com/mb/pasprog/432134/432134/help-please/</link>
      <description>program ro;&lt;br /&gt;
 uses wincrt;&lt;br /&gt;
 type&lt;br /&gt;
 slog=record&lt;br /&gt;
 ime:string;&lt;br /&gt;
 staz:integer;&lt;br /&gt;
 staz_uro:integer&lt;br /&gt;
 end;&lt;br /&gt;
 type&lt;br /&gt;
 niz=array[1..30] of slog;&lt;br /&gt;
 var&lt;br /&gt;
 radnik:niz;&lt;br /&gt;
 pom:slog;&lt;br /&gt;
 n,i,j:integer;&lt;br /&gt;
 procedure razmeni(var p,q:integer);&lt;br /&gt;
 var pom:integer;&lt;br /&gt;
 begin&lt;br /&gt;
 pom:=p;&lt;br /&gt;
 p:=q;&lt;br /&gt;
 q:=pom&lt;br /&gt;
 end;&lt;br /&gt;
 begin&lt;br /&gt;
 write('unesi broj radnika:');&lt;br /&gt;
 readln(n);&lt;br /&gt;
 writeln('unesi podatke o radnicima:');&lt;br /&gt;
 for i:=1 to n do&lt;br /&gt;
begin&lt;br /&gt;
 with radnik[i] do&lt;br /&gt;
 begin&lt;br /&gt;
 write('Ime '); readln(ime);&lt;br /&gt;
 write('Ukupan radni staz '); &lt;br /&gt;
 readln(staz);&lt;br /&gt;
 write('Staz u radnoj organizaciji '); &lt;br /&gt;
 readln(staz_uro);&lt;br /&gt;
 writeln&lt;br /&gt;
 end&lt;br /&gt;
 end;&lt;br /&gt;
 for i:=1 to n-1 do&lt;br /&gt;
 for j:=i+1 to n do&lt;br /&gt;
 if radnik[i].staz&amp;lt; radnik[j].staz then&lt;br /&gt;
 razmeni(radnik[i], radnik[j]);&lt;br /&gt;
 writeln('Sortirani podaci po ukupnoj duzini radnog staza:');&lt;br /&gt;
 for i:=1 to n do&lt;br /&gt;
 with radnik[i] do&lt;br /&gt;
 begin&lt;br /&gt;
 writeln('Ime: ',ime);&lt;br /&gt;
 writeln('Ukupan staz: ',staz);&lt;br /&gt;
 writeln('Staz u radnoj organizaciji: ',staz_uro);&lt;br /&gt;
 writeln&lt;br /&gt;
 end;&lt;br /&gt;
 writeln;&lt;br /&gt;
 writeln('Imena radnika sa 10 god radnog staza_uro: ');&lt;br /&gt;
 for i:=1 to n do&lt;br /&gt;
 if radnik[i].staz_uro=10 then writeln (radnik[i].ime);&lt;br /&gt;
 end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Error 26 type missmatch in this line&lt;br /&gt;
razmeni(radnik[i], radnik[j]);&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/432134/432134/help-please/</guid>
      <pubDate>Sun, 26 May 2013 14:45:50 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Help please</title>
      <link>http://www.programmersheaven.com/mb/pasprog/432133/432133/help-please/</link>
      <description>program ro;&lt;br /&gt;
 uses wincrt;&lt;br /&gt;
 type&lt;br /&gt;
 slog=record&lt;br /&gt;
 ime:string;&lt;br /&gt;
 staz:integer;&lt;br /&gt;
 staz_uro:integer&lt;br /&gt;
 end;&lt;br /&gt;
 type&lt;br /&gt;
 niz=array[1..30] of slog;&lt;br /&gt;
 var&lt;br /&gt;
 radnik:niz;&lt;br /&gt;
 pom:slog;&lt;br /&gt;
 n,i,j:integer;&lt;br /&gt;
 procedure razmeni(var p,q:integer);&lt;br /&gt;
 var pom:integer;&lt;br /&gt;
 begin&lt;br /&gt;
 pom:=p;&lt;br /&gt;
 p:=q;&lt;br /&gt;
 q:=pom&lt;br /&gt;
 end;&lt;br /&gt;
 begin&lt;br /&gt;
 write('unesi broj radnika:');&lt;br /&gt;
 readln(n);&lt;br /&gt;
 writeln('unesi podatke o radnicima:');&lt;br /&gt;
 for i:=1 to n do&lt;br /&gt;
begin&lt;br /&gt;
 with radnik[i] do&lt;br /&gt;
 begin&lt;br /&gt;
 write('Ime '); readln(ime);&lt;br /&gt;
 write('Ukupan radni staz '); &lt;br /&gt;
 readln(staz);&lt;br /&gt;
 write('Staz u radnoj organizaciji '); &lt;br /&gt;
 readln(staz_uro);&lt;br /&gt;
 writeln&lt;br /&gt;
 end&lt;br /&gt;
 end;&lt;br /&gt;
 for i:=1 to n-1 do&lt;br /&gt;
 for j:=i+1 to n do&lt;br /&gt;
 if radnik[i].staz&amp;lt; radnik[j].staz then&lt;br /&gt;
 razmeni(radnik[i], radnik[j]);&lt;br /&gt;
 writeln('Sortirani podaci po ukupnoj duzini radnog staza:');&lt;br /&gt;
 for i:=1 to n do&lt;br /&gt;
 with radnik[i] do&lt;br /&gt;
 begin&lt;br /&gt;
 writeln('Ime: ',ime);&lt;br /&gt;
 writeln('Ukupan staz: ',staz);&lt;br /&gt;
 writeln('Staz u radnoj organizaciji: ',staz_uro);&lt;br /&gt;
 writeln&lt;br /&gt;
 end;&lt;br /&gt;
 writeln;&lt;br /&gt;
 writeln('Imena radnika sa 10 god radnog staza_uro: ');&lt;br /&gt;
 for i:=1 to n do&lt;br /&gt;
 if radnik[i].staz_uro=10 then writeln (radnik[i].ime);&lt;br /&gt;
 end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Error 26 type missmatch in this line&lt;br /&gt;
razmeni(radnik[i], radnik[j]);&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/432133/432133/help-please/</guid>
      <pubDate>Sun, 26 May 2013 14:44:00 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Only a BEEP in WinCE MC9090</title>
      <link>http://www.programmersheaven.com/mb/pasprog/432002/432002/only-a-beep-in-wince-mc9090/</link>
      <description>Hello,&lt;br /&gt;
I am developing an application with Lazarus for Windows CE 5.0 (Motorola / Symbol MC9090).&lt;br /&gt;
I need you to Realize the MC9090 a BEEP with strong volumen.&lt;br /&gt;
With the instruction pascal beep, beep makes very low.&lt;br /&gt;
Can help me how to get a very loud BEEP.&lt;br /&gt;
&lt;br /&gt;
thanks&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/432002/432002/only-a-beep-in-wince-mc9090/</guid>
      <pubDate>Thu, 09 May 2013 04:22:45 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Only a BEEP in WinCE MC9090</title>
      <link>http://www.programmersheaven.com/mb/pasprog/432001/432001/only-a-beep-in-wince-mc9090/</link>
      <description>Hello,&lt;br /&gt;
I am developing an application with Lazarus for Windows CE 5.0 (Motorola / Symbol MC9090).&lt;br /&gt;
I need you to Realize the MC9090 a BEEP with strong volumen.&lt;br /&gt;
With the instruction pascal beep, beep makes very low.&lt;br /&gt;
Can help me how to get a very loud BEEP.&lt;br /&gt;
&lt;br /&gt;
thanks&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/432001/432001/only-a-beep-in-wince-mc9090/</guid>
      <pubDate>Thu, 09 May 2013 04:20:55 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Alternative array access</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431967/431967/alternative-array-access/</link>
      <description>Hi,&lt;br /&gt;
&lt;br /&gt;
just wanted to check if anyone knows about an apparently valid, alternate way to access elements of an array:&lt;br /&gt;
&lt;br /&gt;
instead of myArray[x] it is myArray(.x.)&lt;br /&gt;
&lt;br /&gt;
compiles and works just as well, I´ve just never seen it before, nor read anything about it&lt;br /&gt;
&lt;br /&gt;
does anyone have some info where this is explicitly defined?&lt;br /&gt;
&lt;br /&gt;
Thx,&lt;br /&gt;
&lt;br /&gt;
Jack&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431967/431967/alternative-array-access/</guid>
      <pubDate>Sun, 05 May 2013 07:36:10 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Code for a multiplication table.</title>
      <link>http://www.programmersheaven.com/mb/pasprog/319234/431960/re-code-for-a-multiplication-table/#431960</link>
      <description>manipulate it to get what you need...&lt;br /&gt;
{ Code for normal multiplication&lt;br /&gt;
}&lt;br /&gt;
program ass8;&lt;br /&gt;
var i,j,store:integer;&lt;br /&gt;
const tab=#9;&lt;br /&gt;
begin&lt;br /&gt;
for i:= 1 to 10 do&lt;br /&gt;
begin&lt;br /&gt;
for j:= 1 to 10 do&lt;br /&gt;
begin&lt;br /&gt;
store:= i*j;&lt;br /&gt;
write(store,tab);&lt;br /&gt;
end;&lt;br /&gt;
writeln();&lt;br /&gt;
end;&lt;br /&gt;
end.&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/319234/431960/re-code-for-a-multiplication-table/#431960</guid>
      <pubDate>Fri, 03 May 2013 20:14:32 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Code for a multiplication table.</title>
      <link>http://www.programmersheaven.com/mb/pasprog/319234/431959/re-code-for-a-multiplication-table/#431959</link>
      <description>manipulate it to get what you need...&lt;br /&gt;
{ Code for normal multiplication&lt;br /&gt;
}&lt;br /&gt;
program ass8;&lt;br /&gt;
var i,j,store:integer;&lt;br /&gt;
const tab=#9;&lt;br /&gt;
begin&lt;br /&gt;
for i:= 1 to 10 do&lt;br /&gt;
begin&lt;br /&gt;
for j:= 1 to 10 do&lt;br /&gt;
begin&lt;br /&gt;
store:= i*j;&lt;br /&gt;
write(store,tab);&lt;br /&gt;
end;&lt;br /&gt;
writeln();&lt;br /&gt;
end;&lt;br /&gt;
end.&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/319234/431959/re-code-for-a-multiplication-table/#431959</guid>
      <pubDate>Fri, 03 May 2013 20:12:42 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Code for a multiplication table.</title>
      <link>http://www.programmersheaven.com/mb/pasprog/319234/431958/re-code-for-a-multiplication-table/#431958</link>
      <description>manipulate it to get what you need...&lt;br /&gt;
{ Code for normal multiplication&lt;br /&gt;
}&lt;br /&gt;
program ass8;&lt;br /&gt;
var i,j,store:integer;&lt;br /&gt;
const tab=#9;&lt;br /&gt;
begin&lt;br /&gt;
for i:= 1 to 10 do&lt;br /&gt;
begin&lt;br /&gt;
for j:= 1 to 10 do&lt;br /&gt;
begin&lt;br /&gt;
store:= i*j;&lt;br /&gt;
write(store,tab);&lt;br /&gt;
end;&lt;br /&gt;
writeln();&lt;br /&gt;
end;&lt;br /&gt;
end.&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/319234/431958/re-code-for-a-multiplication-table/#431958</guid>
      <pubDate>Fri, 03 May 2013 20:10:51 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>WTS: New release Apple Iphone 5 and Apple Ipad 4 @ Affordable price</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431893/431893/wts-new-release-apple-iphone-5-and-apple-ipad-4--affordable-price/</link>
      <description>&lt;strong&gt;We have the brand new Apple iPhone 5(Factory Unlocked) 64,32 and 16GB, Black and White SEALED BOX WORKS ANY SIM&lt;br /&gt;
&lt;br /&gt;
Apple iPhone 5 is the thinnest, Lightest iPhone Ever Features all-New aluminum design, and a stunning 4-Inch Retina Display. An Apple-designed A6 chip for blazing fast performance; and ultrafast wireless technology including LTE and DC-HSDPA - all while delivering even better battery life. The iPhone 5 comes with iOS 6, the world's most advanced mobile operating system...&lt;br /&gt;
&lt;br /&gt;
Package content&lt;br /&gt;
1 Apple iPhone 5 Phone&lt;br /&gt;
1 Charger&lt;br /&gt;
1 Data Cable&lt;br /&gt;
1 Handsfree&lt;br /&gt;
1 User's GuidePackage content&lt;br /&gt;
&lt;br /&gt;
warranty : 12 months Original warranty&lt;br /&gt;
&lt;br /&gt;
Also Available instock&lt;br /&gt;
&lt;br /&gt;
Apple iPad 3 with Wi-Fi + 4G(16GB,32GB and 64gb)&lt;br /&gt;
&lt;br /&gt;
The Apple iPad 3 WiFi + 4G 64GB is brand new unlocked never used in box directly from manufactuer comes with full accessories and capable of working any where with any network&lt;br /&gt;
&lt;br /&gt;
Specifications General&lt;br /&gt;
&lt;br /&gt;
Product Type : Tablet&lt;br /&gt;
Width : 7.3 in&lt;br /&gt;
Depth : 0.4 in&lt;br /&gt;
Height : 9.5 in&lt;br /&gt;
Weight : 21.2 oz&lt;br /&gt;
&lt;br /&gt;
warranty : 12 months Original warranty&lt;br /&gt;
&lt;br /&gt;
Feel Free to contact us:&lt;br /&gt;
&lt;br /&gt;
Sales Manager: Syed Ali&lt;br /&gt;
&lt;br /&gt;
Email: info.sayedali@gmail.com&lt;br /&gt;
&lt;br /&gt;
BB PIN 24/7 CHAT: 2737E5A3&lt;br /&gt;
&lt;br /&gt;
Skype: info.sayedali&lt;br /&gt;
&lt;br /&gt;
Tel:  +60136139217&lt;br /&gt;
&lt;br /&gt;
Thanks for your pratonize&lt;/strong&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431893/431893/wts-new-release-apple-iphone-5-and-apple-ipad-4--affordable-price/</guid>
      <pubDate>Thu, 11 Apr 2013 15:13:33 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Stack overflow</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431815/431815/stack-overflow/</link>
      <description>So, i have written recursion which after certain number of calls causes stack overflow. I would like to know if somehow i can avoid this.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
procedure SOLVE (var A : LBOARD; INDEX : integer; var SOLUTION : boolean);
var i : integer;
begin
    if SOLUTION = false
        then if FULL(A)
                 then begin
                         SOLUTION := true;
                         TextColor(10);
                         WriteLn('Possible solution found.');
                         PRINT_CHESSBOARD(A);
                      end
                 else if THERE_ARE_POSSIBLE_MOVES(A)
                          then begin
                                  for i := INDEX downto 1 do
                                     if CAN_BE_MOVED(A, i) and (A[i] = 1)
                                         then begin
                                                 MOVE(A, i);
                                                 RESET(A, i);
                                                 if QUEEN_TO_LEFT(A, i) = 0
                                                     then SOLVE(A, QUEEN_TO_RIGHT(A), SOLUTION)
                                                     else SOLVE(A, QUEEN_TO_LEFT(A,i), SOLUTION);
                                              end;
                               end
        else begin
                TextColor(4);
                WriteLn('No possible solution found.');
             end;
end;
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431815/431815/stack-overflow/</guid>
      <pubDate>Sat, 06 Apr 2013 05:25:03 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Pooh Soro Porject using Dev- Pascal Compiler.</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431809/431809/pooh-soro-porject-using-dev--pascal-compiler/</link>
      <description>Hello everyone, My class is having team assignments for the Pooh Sorority project. My group got this for in the lines of code which ill post below. The instructions and the .dat file used in this program are in the zip file i attached to the program. First we need to use functions instead of procedures but procedures tend to work and the functions weren't working for us. If someone could help fix up our code and make it work (i hope we are close) to what the instructions say that would be great. Also some of the comments are either old code we were going to use or maybe. and its supposed to print to a printer but it wont let us cause the teacher assigns hw to his students over topics we haven't discussed yet... Anyways I am using the 64 bit version of dev-Pascal compiler so if it can compile in that crappy compiler then it works for me! thanks for any inputs or help is very much appreciated! &lt;br /&gt;
&lt;br /&gt;
program pooh ;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{THIS PROGRAM WILL LOAD THE FILES ON ITS OWN AS LONG AS THEY ARE IN THE DIRECTORY THE APPLICATION IS IN!&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
This line causes the runtime error. If you take it out of notes the program will start, get error 2 and close out.&lt;br /&gt;
  }&lt;br /&gt;
 {uses&lt;br /&gt;
printer;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
const&lt;br /&gt;
maxnum = 50;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TYPE&lt;br /&gt;
{Memory}&lt;br /&gt;
string20 = string[20];&lt;br /&gt;
jameshetfield = ARRAY [1..3,1..maxnum] of string20;   {I AM THE TABLE!}&lt;br /&gt;
&lt;br /&gt;
VAR&lt;br /&gt;
&lt;br /&gt;
{---------------&lt;br /&gt;
Input variables}&lt;br /&gt;
poohlist : text ;{The original file being opened}&lt;br /&gt;
poohsave : text ;{The new file being save}&lt;br /&gt;
poohprint : text; {this prints the file}&lt;br /&gt;
how : string;&lt;br /&gt;
&lt;br /&gt;
DataFile : String ;{Asks what the name of the file you want to open is, scrapped}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{-------------------&lt;br /&gt;
Processing variables}&lt;br /&gt;
&lt;br /&gt;
firstname : string; {names}&lt;br /&gt;
lastname : string;    {could be one variable but whatever}&lt;br /&gt;
&lt;br /&gt;
Complex : string;  {Complexion}&lt;br /&gt;
&lt;br /&gt;
Height : string;     {height}&lt;br /&gt;
&lt;br /&gt;
Trait : string;       {trait}&lt;br /&gt;
lucker : string;      {lucky}&lt;br /&gt;
Age : integer;         {sage}&lt;br /&gt;
&lt;br /&gt;
lucky : boolean;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 directory : string;&lt;br /&gt;
readingglasses : char; {reads the characters individually to check for spaces}&lt;br /&gt;
&lt;br /&gt;
{counters}&lt;br /&gt;
readcount : integer;&lt;br /&gt;
totreadcount : integer;&lt;br /&gt;
totlucky : integer;&lt;br /&gt;
tot : integer;&lt;br /&gt;
counter : integer;&lt;br /&gt;
totper : real;&lt;br /&gt;
dashcounter : integer;&lt;br /&gt;
totletter : integer;&lt;br /&gt;
&lt;br /&gt;
{----------------&lt;br /&gt;
Output variables}&lt;br /&gt;
&lt;br /&gt;
poohtable : jameshetfield;    {table}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{----------------------------&lt;br /&gt;
GET FILE DIRECTORY&lt;br /&gt;
----------------------------}&lt;br /&gt;
procedure getdirectory;&lt;br /&gt;
begin&lt;br /&gt;
{gets exact file location AND name}&lt;br /&gt;
 directory := ParamStr(0);&lt;br /&gt;
&lt;br /&gt;
{Getting how long the string is}&lt;br /&gt;
totletter := length(directory);&lt;br /&gt;
&lt;br /&gt;
{Subtractng the file name (pooh.pas) from the directory}&lt;br /&gt;
dashcounter := totletter - 8;&lt;br /&gt;
delete(directory, dashcounter, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{----------------------------&lt;br /&gt;
GET FILE NAME PROCEDURE&lt;br /&gt;
----------------------------}&lt;br /&gt;
&lt;br /&gt;
{Getting the filename instead of hardcoding it}&lt;br /&gt;
procedure getfile;&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
assign(poohlist,directory+'\pooh.dat');&lt;br /&gt;
&lt;br /&gt;
assign(poohsave,directory+'\luckyornot.dat');&lt;br /&gt;
&lt;br /&gt;
rewrite(poohsave);&lt;br /&gt;
reset(poohlist);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{----------------------------&lt;br /&gt;
GET FIRST AND LAST NAME PROCEDURE&lt;br /&gt;
----------------------------}&lt;br /&gt;
procedure getname;&lt;br /&gt;
begin&lt;br /&gt;
{clearing variables}&lt;br /&gt;
readcount := 0;&lt;br /&gt;
totreadcount := 0;&lt;br /&gt;
lastname := '';&lt;br /&gt;
firstname := '';&lt;br /&gt;
&lt;br /&gt;
{GETTING FIRST NAME}&lt;br /&gt;
readingglasses := 'k';&lt;br /&gt;
WHILE (readingglasses &amp;lt;&amp;gt; ' ') DO&lt;br /&gt;
begin&lt;br /&gt;
read(poohlist, readingglasses);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{Seeing if the name is done}&lt;br /&gt;
if (readingglasses &amp;lt;&amp;gt;  ' ') THEN&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
{Making sure it's 20 characters}&lt;br /&gt;
if readcount &amp;lt;&amp;gt; 20 THEN&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
{adding each character individually, and counting the characters}&lt;br /&gt;
insert(readingglasses,firstname,(readcount + 1));&lt;br /&gt;
readcount := readcount + 1;&lt;br /&gt;
totreadcount := totreadcount + 1;&lt;br /&gt;
end;&lt;br /&gt;
end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{GETTING LAST NAME}&lt;br /&gt;
readcount := 0;&lt;br /&gt;
&lt;br /&gt;
readingglasses := 'k';&lt;br /&gt;
WHILE (readingglasses &amp;lt;&amp;gt; ' ') DO&lt;br /&gt;
begin&lt;br /&gt;
read(poohlist, readingglasses);&lt;br /&gt;
&lt;br /&gt;
{Seeing if the name is done}&lt;br /&gt;
if (readingglasses &amp;lt;&amp;gt; ' ') THEN&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
{Making sure it's 20 characters}&lt;br /&gt;
IF totreadcount &amp;lt;&amp;gt; 20 THEN&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
{adding each character individually, and counting the characters}&lt;br /&gt;
insert(readingglasses,lastname,(readcount + 1));&lt;br /&gt;
readcount := readcount + 1;&lt;br /&gt;
totreadcount := totreadcount + 1;&lt;br /&gt;
end&lt;br /&gt;
end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{----------------------------&lt;br /&gt;
CALCULATING IF LUCKY OR NOT&lt;br /&gt;
----------------------------}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure islucky;&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
height := '';&lt;br /&gt;
age := 0;&lt;br /&gt;
complex := '';&lt;br /&gt;
trait := '';&lt;br /&gt;
&lt;br /&gt;
{Reading  complex}&lt;br /&gt;
readingglasses := 'k';&lt;br /&gt;
WHILE (readingglasses &amp;lt;&amp;gt; ' ') DO&lt;br /&gt;
begin&lt;br /&gt;
read(poohlist, readingglasses);&lt;br /&gt;
readcount := readcount + 1;&lt;br /&gt;
insert(readingglasses,complex,(readcount));&lt;br /&gt;
end ;&lt;br /&gt;
&lt;br /&gt;
{Reading  height}&lt;br /&gt;
readingglasses := 'k';&lt;br /&gt;
WHILE (readingglasses &amp;lt;&amp;gt; ' ') DO&lt;br /&gt;
begin&lt;br /&gt;
read(poohlist, readingglasses);&lt;br /&gt;
readcount := readcount + 1;&lt;br /&gt;
insert(readingglasses,height,(readcount));&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
{Reading  trait}&lt;br /&gt;
readingglasses := 'k';&lt;br /&gt;
WHILE (readingglasses &amp;lt;&amp;gt; ' ') DO&lt;br /&gt;
begin&lt;br /&gt;
read(poohlist, readingglasses);&lt;br /&gt;
readcount := readcount + 1;&lt;br /&gt;
insert(readingglasses,trait,(readcount));&lt;br /&gt;
end ;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{Reading  age}&lt;br /&gt;
{WHILE NOT eoln(poohlist) DO&lt;br /&gt;
begin    }&lt;br /&gt;
readln(poohlist, age);&lt;br /&gt;
{end ; }&lt;br /&gt;
&lt;br /&gt;
lucky := ((height = 'Tall') AND (trait = 'Handsome') AND (complex &amp;lt;&amp;gt; 'Dark') AND ((Age &amp;gt; 20) AND (Age &amp;lt; 30)))&lt;br /&gt;
OR ((((trait = 'Timit') or (height = 'Medium') or (complex &amp;lt;&amp;gt; 'Whitish')) AND ((age &amp;lt; 22) OR (age &amp;gt; 28)))&lt;br /&gt;
and NOT ((height = 'small') and (trait = 'Aggressive') and (age &amp;gt; 65))&lt;br /&gt;
and not ((trait = 'Timid') AND (trait = 'Tall') and (age &amp;lt; 16)));&lt;br /&gt;
&lt;br /&gt;
totlucky := totlucky + ord(lucky);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{----------------------------&lt;br /&gt;
SAVING TO TABLE&lt;br /&gt;
----------------------------}&lt;br /&gt;
procedure savetojames;&lt;br /&gt;
begin&lt;br /&gt;
poohtable[1][tot] := firstname;&lt;br /&gt;
 poohtable[2,tot] := lastname;&lt;br /&gt;
 if(lucky) THEN&lt;br /&gt;
 poohtable[3,tot] := 'Lucky'&lt;br /&gt;
 else&lt;br /&gt;
 poohtable[3,tot] := 'Unlucky';&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 {----------------------------&lt;br /&gt;
WRITING TO FILE&lt;br /&gt;
----------------------------}&lt;br /&gt;
procedure writetofile;&lt;br /&gt;
begin&lt;br /&gt;
          {I had to add Flush to make sure it wrote ALL of the words, because it would stop halfway through. I'm not sure if we learned this yet}&lt;br /&gt;
 counter := 1;&lt;br /&gt;
 writeln(poohsave,'Pooh Project');&lt;br /&gt;
 writeln(poohsave,'Group 1');&lt;br /&gt;
  writeln(poohsave,'CIS 136 30');&lt;br /&gt;
 writeln(poohsave);&lt;br /&gt;
 writeln(poohsave,'Last name':10, '|' , 'First name':10, '|', 'Lucky?':10);&lt;br /&gt;
writeln(poohsave,'==============================='
);&lt;br /&gt;
Flush(poohsave);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
while counter &amp;lt; tot do&lt;br /&gt;
begin&lt;br /&gt;
writeln(poohsave,poohtable[1,counter]:10 ,poohtable[2,counter]:10, poohtable[3,counter]:10);&lt;br /&gt;
Flush(poohsave);&lt;br /&gt;
counter := counter + 1;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
totper := totlucky DIV tot;&lt;br /&gt;
&lt;br /&gt;
writeln(poohsave, 'Total lucky: ', totlucky);&lt;br /&gt;
writeln(poohsave, 'Total unlucky: ', (totlucky - tot));&lt;br /&gt;
writeln(poohsave, 'Total suitors: ', tot);&lt;br /&gt;
writeln(poohsave, 'Percentage lucky: ', (100 - totper*10):3:0, '%');&lt;br /&gt;
writeln(poohsave, 'Percentage unlucky: ', (totper*10):3:0, '%');&lt;br /&gt;
Flush(poohsave);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 {----------------------------&lt;br /&gt;
WRITING TO SCREEN&lt;br /&gt;
----------------------------}&lt;br /&gt;
procedure writetoscreen;&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
 writeln('Last name':10, '|' , 'First name':10, '|', 'Lucky?':10);&lt;br /&gt;
writeln('===============================');&lt;br /&gt;
 counter := 1;&lt;br /&gt;
while counter &amp;lt; tot do&lt;br /&gt;
begin&lt;br /&gt;
writeln(poohtable[1,counter]:10 ,poohtable[2,counter]:10, poohtable[3,counter]:10);&lt;br /&gt;
counter := counter + 1;&lt;br /&gt;
end;&lt;br /&gt;
writeln;&lt;br /&gt;
&lt;br /&gt;
writeln('Total lucky: ', totlucky);&lt;br /&gt;
writeln('Total ulucky: ', (tot - totlucky));&lt;br /&gt;
writeln('Total suitors: ', tot);&lt;br /&gt;
writeln('Percentage lucky: ', (100 - totper*10):3:0, '%');&lt;br /&gt;
writeln('Percentage unlucky: ', (totper*10):3:0, '%');&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 {----------------------------&lt;br /&gt;
PRINTING&lt;br /&gt;
I couldn't finish writing this because I couldn't even be able to load the printer.&lt;br /&gt;
----------------------------}&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
 procedure  writetoprinter;&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    counter := 1;&lt;br /&gt;
 writeln(lst,'Pooh Project');&lt;br /&gt;
 writeln(poohprint,'Group 1');&lt;br /&gt;
  writeln(poohprint,'CIS 136 30');&lt;br /&gt;
 writeln(poohprint);&lt;br /&gt;
 writeln(poohprint,'Last name':10, '|' , 'First name':10, '|', 'Lucky?':10);&lt;br /&gt;
writeln(poohprint,'===============================
');&lt;br /&gt;
Flush(poohprint);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
while counter &amp;lt; tot do&lt;br /&gt;
begin&lt;br /&gt;
writeln(poohprint,poohtable[1,counter]:10 ,poohtable[2,counter]:10, poohtable[3,counter]:10);&lt;br /&gt;
Flush(poohprint);&lt;br /&gt;
counter := counter + 1;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
totper := totlucky DIV tot;&lt;br /&gt;
&lt;br /&gt;
writeln(poohprint, 'Total lucky: ', totlucky);&lt;br /&gt;
writeln(poohprint, 'Total unlucky: ', (totlucky - tot));&lt;br /&gt;
writeln(poohprint, 'Total suitors: ', tot);&lt;br /&gt;
writeln(poohprint, 'Percentage lucky: ', (100 - totper*10):3:0, '%');&lt;br /&gt;
writeln(poohprint, 'Percentage unlucky: ', (totper*10):3:0, '%');&lt;br /&gt;
Flush(poohprint);&lt;br /&gt;
close(poohprint);&lt;br /&gt;
end;&lt;br /&gt;
}&lt;br /&gt;
{----------------------------&lt;br /&gt;
MAIN PROGRAM&lt;br /&gt;
----------------------------}&lt;br /&gt;
&lt;br /&gt;
begin&lt;br /&gt;
{assign(lst,'lpt1' );   }&lt;br /&gt;
getdirectory;&lt;br /&gt;
getfile;&lt;br /&gt;
&lt;br /&gt;
While NOT eof(poohlist) DO&lt;br /&gt;
Begin&lt;br /&gt;
While NOT eoln(poohlist) DO&lt;br /&gt;
begin&lt;br /&gt;
tot := tot + 1;&lt;br /&gt;
{Processing the data}&lt;br /&gt;
getname;&lt;br /&gt;
islucky;&lt;br /&gt;
&lt;br /&gt;
{Saving the data}&lt;br /&gt;
Savetojames;&lt;br /&gt;
end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{asking how it wants to be presented}&lt;br /&gt;
DataFile := 'dfds';&lt;br /&gt;
writeln('How do you want to be given the data? Print to screen (types s), write to file (type f), or print on a printer (type p)?)');&lt;br /&gt;
while datafile &amp;lt;&amp;gt;  'k' DO&lt;br /&gt;
begin&lt;br /&gt;
readln(how);&lt;br /&gt;
&lt;br /&gt;
{Screen?}&lt;br /&gt;
if how = 's'  THEN&lt;br /&gt;
begin&lt;br /&gt;
writetoscreen;&lt;br /&gt;
datafile := 'k';&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
{File?}&lt;br /&gt;
else if how = 'f' THEN&lt;br /&gt;
begin&lt;br /&gt;
write('Written to: ', directory+'\luckyornot.dat');&lt;br /&gt;
writetofile;&lt;br /&gt;
datafile := 'k';&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
{Printer?}&lt;br /&gt;
else if how = 'p' THEN&lt;br /&gt;
begin&lt;br /&gt;
write('Printed');&lt;br /&gt;
datafile := 'k';&lt;br /&gt;
{writetoprinter;  }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
{Hello. My name is error}&lt;br /&gt;
else&lt;br /&gt;
writeln('Could not understand, input should be one of the following: s  f  p');&lt;br /&gt;
&lt;br /&gt;
end;&lt;br /&gt;
readln();&lt;br /&gt;
Close(poohsave);&lt;br /&gt;
Close(poohlist);&lt;br /&gt;
end.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431809/431809/pooh-soro-porject-using-dev--pascal-compiler/</guid>
      <pubDate>Fri, 05 Apr 2013 13:38:39 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Loop repeating even though got correct guess</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431781/431792/re-loop-repeating-even-though-got-correct-guess/#431792</link>
      <description>&lt;pre class="sourcecode"&gt;
   function playgame()  :  Integer ;
   
   var 
      target, gnum,  guess :  Integer ;
      guessed              :  Boolean ;
   
   begin
      gnum     := 0 ;
      target   := Random(2) + 1 ;
      guessed  := false ;
    
      Repeat 
         gnum :=  gnum + 1 ;
         Write('Guess', ' ', gnum, ':') ; 
         
         // gnum :=  gnum + 1 ;
         // Write('Guess', ' ', gnum, ':') ;
         guess := ReadIntegerRange(1, 100) ;
         if guess &amp;gt; target then begin
            WriteLn('The number is smaller then ', guess)
         end
         else if guess &amp;lt; target then begin
            WriteLn('The number is larger then ', guess)
         end
         else begin 
            WriteLn('Well Done .. the number was .. ', guess) ;
            guessed := True
         end
      until (guessed = true) or (gnum &amp;gt;= 7)
   end ;    //until guess = target ;
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431781/431792/re-loop-repeating-even-though-got-correct-guess/#431792</guid>
      <pubDate>Fri, 05 Apr 2013 01:26:46 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Loop repeating even though got correct guess</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431781/431781/loop-repeating-even-though-got-correct-guess/</link>
      <description>My loop is keep repeating even though i got correct guess how do i solve that ??&lt;br /&gt;
&lt;br&gt;&lt;br&gt;&lt;strong&gt;Attachment:&lt;/strong&gt; &lt;a href="http://www.programmersheaven.com/mb/DownloadAttachment.aspx?AttachmentID=2590"&gt;g.pas&lt;/a&gt; (1618 bytes | downloaded 35 times)</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431781/431781/loop-repeating-even-though-got-correct-guess/</guid>
      <pubDate>Thu, 04 Apr 2013 04:17:41 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>help with this program!</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431743/431743/help-with-this-program/</link>
      <description>hello everyone, I am having problems with this program, I don´t know where is the problem. It´s function is to read a txt. So could yo help me?&lt;br /&gt;
&lt;br /&gt;
this is the program:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;program leerarchivo;

const

se='/';

type

  jugadores =(Jugador,CPU1,CPU2,CPU3,CPU4,CPU5);

  estado= (activo,eliminado); // estados de los jugadores en la partida

 mazo= (Biblioteca,Cocina,Comedor,Estudio,Vestibulo,Salon
,
        Invernadero,SalaDeBaile,SalaDeBillar,SenioraBlanco
,
        SenioraCeleste,ProfesorCiruela,SenioritaEscarlata,
CoronelMostaza,
        SeniorVerde,Candelabro,Cuchillo,Cuerda,LlaveIngles
a,Revolver,Tubo);

 lugares= Biblioteca..SalaDeBillar;

 personajes= SenioraBlanco..SeniorVerde;

 armas = Candelabro..Tubo;

 tablero= array [1..5] of array [1..5] of lugares;

 sobre= array [1..3] of mazo;

 manos= array [1..6] of array [jugadores] of mazo;

 listas= array [jugadores] of array [mazo] of boolean; //Lista de sospechosos

 posibles=array [1..9] of lugares;

 arreglo_cartas= array[1..18] of mazo;

 fichaTec=record // Datos de los participantes
  peon : personajes; // peon del jugador
  ubicacion:lugares; // ubicacion del jugador
  estatus: estado; // estado del jugador
  end;

 fichas = array [jugadores] of fichaTec;


var

lugar:tablero;
    Crimen:sobre;
  culpable:personajes;
  arma:armas;
  escena:lugares;
  J1:fichas;
  baraja:mazo;
  mano:manos;
  ultjug:jugadores;
  gameover:boolean;
  lista:listas;
  numjug:integer;
  jugact:jugadores;
  var arreglo:arreglo_cartas;
  ganador:boolean;
  resp:(acusar,sospechar);
  nombreArchivo:string;
  resp2:(guardar,jugar);
  i:mazo;
  contador:integer;
  archivo:text;

  numcartas: array[jugadores] of integer;
  numlistas:array [jugadores] of integer;
  control:integer;
  dum:string;
  temp:array [jugadores] of array [1..21] of mazo;
  afg:integer;
  jugturno:personajes;
  tur:jugadores;

begin

	writeln;
	writeln('lectura de archivo');
	writeln;
	writeln('introduzca el nombre de la partida');
	readln(nombreArchivo);

	assign(archivo,nombreArchivo);
	reset(archivo);

	while not eof (archivo) do begin


		readln(archivo,numjug);

		if numjug=3 then begin

			readln(archivo,crimen[1],crimen[2],crimen[3]);
	
			readln(archivo,j1[jugador].peon,j1[jugador].estatu
s,j1[jugador].ubicacion,numcartas[jugador],numlist
as[jugador]);

			for control:=1 to numcartas[jugador] do read(archivo,mano[control][jugador]);	
			readln(archivo,dum);				
			for control:=1 to numlistas[jugador] do read(archivo,temp[jugador][control]);
			readln(archivo,dum);

			readln(archivo,j1[cpu1].peon,j1[cpu1].estatus,j1[c
pu1].ubicacion,numcartas[cpu1],numlistas[cpu1]);
			if j1[cpu1].estatus=activo then begin
				for control:=1 to numcartas[cpu1] do read(archivo,mano[control][cpu1]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu1] do read(archivo,temp[cpu1][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu1] do read(archivo,temp[cpu1][control]);
				readln(archivo,dum);
			end;
			
			readln(archivo,j1[cpu2].peon,j1[cpu2].estatus,j1[c
pu2].ubicacion,numcartas[cpu2],numlistas[cpu2]);
			if j1[cpu2].estatus=activo then begin
				for control:=1 to numcartas[cpu2] do read(archivo,mano[control][cpu2]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu2] do read(archivo,temp[cpu2][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu2] do read(archivo,temp[cpu2][control]);
				readln(archivo,dum);
			end;

			readln(archivo,jugturno);

			for tur:=jugador to cpu2 do begin
				if j1[tur].peon=jugturno then jugact:=tur;
			end;

			for control:=1 to numlistas[jugador] do lista[jugador][temp[jugador][control]]:=true;
			for control:=1 to numlistas[cpu1] do lista[cpu1][temp[cpu1][control]]:=true;
			for control:=1 to numlistas[cpu2] do lista[cpu2][temp[cpu2][control]]:=true;
		end
		
		else if numjug=4 then begin

			readln(archivo,crimen[1],crimen[2],crimen[3]);
			readln(archivo,j1[jugador].peon,j1[jugador].estatu
s,j1[jugador].ubicacion,numcartas[jugador],numlist
as[jugador]);
			for control:=1 to numcartas[jugador] do read(archivo,mano[control][jugador]);	
			readln(archivo,dum);				
			for control:=1 to numlistas[jugador] do read(archivo,temp[jugador][control]);
			readln(archivo,dum);

			readln(archivo,j1[cpu1].peon,j1[cpu1].estatus,j1[c
pu1].ubicacion,numcartas[cpu1],numlistas[cpu1]);
			if j1[cpu1].estatus=activo then begin
				for control:=1 to numcartas[cpu1] do read(archivo,mano[control][cpu1]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu1] do read(archivo,temp[cpu1][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu1] do read(archivo,temp[cpu1][control]);
				readln(archivo,dum);
			end;

			readln(archivo,j1[cpu2].peon,j1[cpu2].estatus,j1[c
pu2].ubicacion,numcartas[cpu2],numlistas[cpu2]);
			if j1[cpu2].estatus=activo then begin
				for control:=1 to numcartas[cpu2] do read(archivo,mano[control][cpu2]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu2] do read(archivo,temp[cpu2][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu2] do read(archivo,temp[cpu2][control]);
				readln(archivo,dum);
			end;
			
			readln(archivo,j1[cpu3].peon,j1[cpu3].estatus,j1[c
pu3].ubicacion,numcartas[cpu3],numlistas[cpu3]);
			if j1[cpu3].estatus=activo then begin
				for control:=1 to numcartas[cpu3] do read(archivo,mano[control][cpu3]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu3] do read(archivo,temp[cpu3][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu3] do read(archivo,temp[cpu3][control]);
				readln(archivo,dum);
			end;

			readln(archivo,jugturno);

			for tur:=jugador to cpu3 do begin
				if j1[tur].peon=jugturno then jugact:=tur;
			end;

			for control:=1 to numlistas[jugador] do lista[jugador][temp[jugador][control]]:=true;
			for control:=1 to numlistas[cpu1] do lista[cpu1][temp[cpu1][control]]:=true;
			for control:=1 to numlistas[cpu2] do lista[cpu2][temp[cpu2][control]]:=true;
			for control:=1 to numlistas[cpu3] do lista[cpu3][temp[cpu3][control]]:=true;


		end	

		else if numjug=5 then begin

			readln(archivo,crimen[1],crimen[2],crimen[3]);
			
			readln(archivo,crimen[1],crimen[2],crimen[3]);
			readln(archivo,j1[jugador].peon,j1[jugador].estatu
s,j1[jugador].ubicacion,numcartas[jugador],numlist
as[jugador]);
			for control:=1 to numcartas[jugador] do read(archivo,mano[control][jugador]);	
			readln(archivo,dum);				
			for control:=1 to numlistas[jugador] do read(archivo,temp[jugador][control]);
			readln(archivo,dum);

			readln(archivo,j1[cpu1].peon,j1[cpu1].estatus,j1[c
pu1].ubicacion,numcartas[cpu1],numlistas[cpu1]);
			if j1[cpu1].estatus=activo then begin
				for control:=1 to numcartas[cpu1] do read(archivo,mano[control][cpu1]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu1] do read(archivo,temp[cpu1][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu1] do read(archivo,temp[cpu1][control]);
				readln(archivo,dum);
			end;

			readln(archivo,j1[cpu2].peon,j1[cpu2].estatus,j1[c
pu2].ubicacion,numcartas[cpu2],numlistas[cpu2]);
			if j1[cpu2].estatus=activo then begin
				for control:=1 to numcartas[cpu2] do read(archivo,mano[control][cpu2]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu2] do read(archivo,temp[cpu2][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu2] do read(archivo,temp[cpu2][control]);
				readln(archivo,dum);
			end;

			
			readln(archivo,j1[cpu3].peon,j1[cpu3].estatus,j1[c
pu3].ubicacion,numcartas[cpu3],numlistas[cpu3]);
			if j1[cpu3].estatus=activo then begin
				for control:=1 to numcartas[cpu3] do read(archivo,mano[control][cpu3]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu3] do read(archivo,temp[cpu3][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu3] do read(archivo,temp[cpu3][control]);
				readln(archivo,dum);
			end;
			
			readln(archivo,j1[cpu4].peon,j1[cpu4].estatus,j1[c
pu4].ubicacion,numcartas[cpu4],numlistas[cpu4]);
			if j1[cpu4].estatus=activo then begin
				for control:=1 to numcartas[cpu4] do read(archivo,mano[control][cpu4]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu4] do read(archivo,temp[cpu4][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu4] do read(archivo,temp[cpu4][control]);
				readln(archivo,dum);
			end;

			readln(archivo,jugturno);

			for tur:=jugador to cpu4 do begin
				if j1[tur].peon=jugturno then jugact:=tur;
			end;
			
			for control:=1 to numlistas[jugador] do lista[jugador][temp[jugador][control]]:=true;
			for control:=1 to numlistas[cpu1] do lista[cpu1][temp[cpu1][control]]:=true;
			for control:=1 to numlistas[cpu2] do lista[cpu2][temp[cpu2][control]]:=true;
			for control:=1 to numlistas[cpu3] do lista[cpu3][temp[cpu3][control]]:=true;
			for control:=1 to numlistas[cpu4] do lista[cpu3][temp[cpu4][control]]:=true;


		end	

		else if numjug=6 then begin

			readln(archivo,crimen[1],crimen[2],crimen[3]);
	
			readln(archivo,crimen[1],crimen[2],crimen[3]);
			readln(archivo,j1[jugador].peon,j1[jugador].estatu
s,j1[jugador].ubicacion,numcartas[jugador],numlist
as[jugador]);
			for control:=1 to numcartas[jugador] do read(archivo,mano[control][jugador]);	
			readln(archivo,dum);				
			for control:=1 to numlistas[jugador] do read(archivo,temp[jugador][control]);
			readln(archivo,dum);

			readln(archivo,j1[cpu1].peon,j1[cpu1].estatus,j1[c
pu1].ubicacion,numcartas[cpu1],numlistas[cpu1]);
			if j1[cpu1].estatus=activo then begin
				for control:=1 to numcartas[cpu1] do read(archivo,mano[control][cpu1]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu1] do read(archivo,temp[cpu1][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu1] do read(archivo,temp[cpu1][control]);
				readln(archivo,dum);
			end;

			readln(archivo,j1[cpu2].peon,j1[cpu2].estatus,j1[c
pu2].ubicacion,numcartas[cpu2],numlistas[cpu2]);
			if j1[cpu2].estatus=activo then begin
				for control:=1 to numcartas[cpu2] do read(archivo,mano[control][cpu2]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu2] do read(archivo,temp[cpu2][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu2] do read(archivo,temp[cpu2][control]);
				readln(archivo,dum);
			end;
			
			readln(archivo,j1[cpu3].peon,j1[cpu3].estatus,j1[c
pu3].ubicacion,numcartas[cpu3],numlistas[cpu3]);
			if j1[cpu3].estatus=activo then begin
				for control:=1 to numcartas[cpu3] do read(archivo,mano[control][cpu3]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu3] do read(archivo,temp[cpu3][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu3] do read(archivo,temp[cpu3][control]);
				readln(archivo,dum);
			end;
			
			readln(archivo,j1[cpu4].peon,j1[cpu4].estatus,j1[c
pu4].ubicacion,numcartas[cpu4],numlistas[cpu4]);
			if j1[cpu4].estatus=activo then begin
				for control:=1 to numcartas[cpu4] do read(archivo,mano[control][cpu4]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu4] do read(archivo,temp[cpu4][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu4] do read(archivo,temp[cpu4][control]);
				readln(archivo,dum);
			end;

			readln(archivo,j1[cpu5].peon,j1[cpu5].estatus,j1[c
pu5].ubicacion,numcartas[cpu5],numlistas[cpu5]);
			if j1[cpu5].estatus=activo then begin
				for control:=1 to numcartas[cpu5] do read(archivo,mano[control][cpu5]);	
				readln(archivo,dum);				
				for control:=1 to numlistas[cpu5] do read(archivo,temp[cpu5][control]);
				readln(archivo,dum);
			end
			else begin
				readln(archivo,dum);
				for control:=1 to numlistas[cpu5] do read(archivo,temp[cpu5][control]);
				readln(archivo,dum);
			end;

			readln(archivo,jugturno);
			
			for tur:=jugador to cpu5 do begin
				if j1[tur].peon=jugturno then jugact:=tur;
			end;

			for control:=1 to numlistas[jugador] do lista[jugador][temp[jugador][control]]:=true;
			for control:=1 to numlistas[cpu1] do lista[cpu1][temp[cpu1][control]]:=true;
			for control:=1 to numlistas[cpu2] do lista[cpu2][temp[cpu2][control]]:=true;
			for control:=1 to numlistas[cpu3] do lista[cpu3][temp[cpu3][control]]:=true;
			for control:=1 to numlistas[cpu4] do lista[cpu3][temp[cpu4][control]]:=true;
			for control:=1 to numlistas[cpu5] do lista[cpu5][temp[cpu5][control]]:=true;

		end;	
	end;
	
	close(archivo);

	writeln('hola');
	readln;

end.	&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And this is the txt:&lt;br /&gt;
&lt;br /&gt;
5													&lt;br /&gt;
	ProfesorCiruela	LlaveInglesa	Cocina											&lt;br /&gt;
	SenioritaEscarlata	activo	Cocina	4	14									&lt;br /&gt;
	Estudio	SalaDeBaile	SenioraBlanco	Candelabro										&lt;br /&gt;
	Vestibulo	Salon	SenioraCeleste	Cuchillo	SalaDeBillar	Biblioteca	SeniorVerde	Tubo	Invernadero	SenioritaEscarlata	Cuerda	Comedor	CoronelMostaza	Revolver&lt;br /&gt;
	CoronelMostaza	activo	Estudio	5	9									&lt;br /&gt;
	Vestibulo	Salon	SenioraCeleste	Cuchillo	Comedor									&lt;br /&gt;
	Estudio	SalaDeBaile	SenioraBlanco	Candelabro	SalaDeBillar	Biblioteca	SeniorVerde	Tubo	CoronelMostaza					&lt;br /&gt;
	SenioraBlanco	activo	Vestibulo	5	9									&lt;br /&gt;
	SalaDeBillar	Biblioteca	SeniorVerde	Tubo	CoronelMostaza									&lt;br /&gt;
	Estudio	SalaDeBaile	SenioraBlanco	Candelabro	Vestibulo	Salon	SenioraCeleste	Cuchillo	Comedor					&lt;br /&gt;
	SenioraCeleste	activo	SalaDeBillar	4	9									&lt;br /&gt;
	Invernadero	SenioritaEscarlata	Cuerda	Revolver										&lt;br /&gt;
	Estudio	SalaDeBaile	SenioraBlanco	Candelabro	Vestibulo	Salon	SenioraCeleste	Cuchillo	Comedor					&lt;br /&gt;
	SeniorVerde	eliminado	Invernadero	0	14									&lt;br /&gt;
&lt;br /&gt;
	Vestibulo	Salon	SenioraCeleste	Cuchillo	SalaDeBillar	Biblioteca	SeniorVerde	Tubo	Invernadero	SenioritaEscarlata	Cuerda	Comedor	CoronelMostaza	Revolver&lt;br /&gt;
	CoronelMostaza	&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431743/431743/help-with-this-program/</guid>
      <pubDate>Fri, 29 Mar 2013 09:01:07 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>recursion (backtracking) problem, knight coverings</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431711/431711/recursion-backtracking-problem-knight-coverings/</link>
      <description>hello everyone,&lt;br /&gt;
i have problems with this program and i am praying for your help.&lt;br /&gt;
The task is to put given number of knights, on given size chess board, that every square of the board is covered. That is, every square on the board is either occupied by a knight or attacked by a knight. knights can attack each other. the solutions are givven here. &lt;a href="http://www.contestcen.com/knight.htm"&gt;&lt;/a&gt;&lt;br /&gt;
i am using recursion. algorithm:&lt;br /&gt;
1. choose not occupied square&lt;br /&gt;
2. try every knight, which can occupy that square&lt;br /&gt;
3. choose another square and so on, till knight max number is reached.&lt;br /&gt;
basicly, i try every posibble knight positions.&lt;br /&gt;
i wrote program, which is below, but it crashes when i put more than 6 knights, and show nonsense in boards below 6. i know that the problem is in backtracking, when i need to delete a knight. but i dont know how to correct it.&lt;br /&gt;
again, praying for your help. Thanks in advance.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;program zirgai;
uses crt;
type lenta = array[1..8,1..8] of char;
     ejimai = array[1..8] of integer;
var L:lenta;
    N,M,Grizti:ejimai;
    zirgu_sk,dydis,r:integer;
//******************************//
procedure nulinimas(var L:lenta; d:integer);
var x,y:integer;
begin
for x:=1 to d do
    begin
    for y:=1 to d do
        begin
        L[x,y]:='0';
        end;
    end;
end;
//******************************//
procedure tikrinimas(L:lenta; d:integer; var r:integer);
var x,y:integer;
begin
r:=1;
for x:=1 to d do
    begin
    for y:=1 to d do
        begin
        if L[x,y]='0' then begin r:=0; break; end;
        end;
    if L[x,y]='0' then begin r:=0; break; end;
    end;
end;
//******************************//
procedure braizyti(L:lenta; d:integer);
var x1,x2,y1,y2,counter,x,y:integer;
begin
counter:=1;
y1:=1;
y2:=3;
    for x:=1 to d do                                          // draws a chess board
    begin
    x1:=1;
    x2:=5;
        for y:=1 to d do
        begin
        window(x1,y1,x2,y2);
        if (counter mod 2) = 0 then textbackground(red)
        else textbackground(green);
        clrscr;
        writeln;
        writeln('  ',L[x,y]);
        counter:=counter+1;
        x1:=x1+5;
        x2:=x2+5;
        end;
    y1:=y1+3;
    y2:=y2+3;
    if (d mod 2) = 0 then counter:=counter+1;
    end;
end;
//******************************//
procedure Delioti(zirgas,x,y:integer);
var i,z:integer;
begin
tikrinimas(L,dydis,r);
if r=1 then
begin
writeln('done');                    // checks if all sqaures are covered
braizyti(L,dydis);
readln;
exit;
end;
//////////////////////////////////////////////////
/////////
    if (x&amp;lt;&amp;gt;1) and (y&amp;lt;&amp;gt;1) and (zirgas&amp;lt;&amp;gt;0) then
    begin
        if (x&amp;gt;=1) and (y&amp;gt;=1) and (x&amp;lt;=dydis) and (y&amp;lt;=dydis) then
        begin
        L[x,y]:='Z';                                                                             // puts knight, and marks covered squares
            for i:=1 to 8 do
            begin
                if (x+N[i]&amp;gt;=1) and (y+M[i]&amp;gt;=1) and (x+N[i]&amp;lt;=dydis) and (y+M[i]&amp;lt;=dydis)
                and (L[x+N[i],y+M[i]]&amp;lt;&amp;gt;'Z') and (L[x+N[i],y+M[i]]&amp;lt;&amp;gt;'.') then
                begin
                L[x+N[i],y+M[i]]:='.';  Grizti[i]:=1;
                end;
            end;
        end;
    end;

//////////////////////////////////////////////////
/////////
    for x:=1 to dydis do
    begin
        for y:=1 to dydis do
        begin
        if (L[x,y]&amp;lt;&amp;gt;'Z') and (L[x,y]&amp;lt;&amp;gt;'.') then break;                          // finds not occupied square
        end;
    if (L[x,y]&amp;lt;&amp;gt;'Z') and (L[x,y]&amp;lt;&amp;gt;'.') then break;
    end;

    if zirgas&amp;lt;=zirgu_sk then
    begin
        for i:=1 to 8 do                                                         // recursion. calls procedure again and again
        begin
        Delioti(zirgas+1,x+N[i],y+M[i]);
        end;
    end;
//////////////////////////////////////////////////
/////////
    if (x&amp;lt;&amp;gt;1) and (y&amp;lt;&amp;gt;1) and (zirgas&amp;lt;&amp;gt;0) then
    begin
        if (x&amp;gt;=1) and (y&amp;gt;=1) and (x&amp;lt;=dydis) and (y&amp;lt;=dydis) then
        begin
        L[x,y]:='0';
            for i:=1 to 8 do
            begin
                if Grizti[i]=1 then
                begin                                                               // deletes knight, and his covered squares
                L[x+N[i],y+M[i]]:='0';
                end;
            end;
        end;
    end;
    for z:=1 to 8 do
    begin
    Grizti[z]:=0;
    end;
//////////////////////////////////////////////////
/////////
end;
//******************************//
begin
  N[1]:=1;  M[1]:=2;
  N[2]:=1;  M[2]:=-2;
  N[3]:=2;  M[3]:=-1;
  N[4]:=2;  M[4]:=1;
  N[5]:=-2; M[5]:=-1;
  N[6]:=-2; M[6]:=1;
  N[7]:=-1; M[7]:=-2;
  N[8]:=-1; M[8]:=2;
    for dydis:=1 to 8 do
    begin
    Grizti[dydis]:=0;
    end;
writeln('zirgu skaicius:');
readln(zirgu_sk);
writeln('lentos dydis:');
readln(dydis);
nulinimas(L,dydis);    // changes all squares value to '0'
Delioti(0,1,1);
readln;
end.
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431711/431711/recursion-backtracking-problem-knight-coverings/</guid>
      <pubDate>Tue, 26 Mar 2013 14:20:59 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>recursion (backtracking) problem, knight coverings</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431710/431710/recursion-backtracking-problem-knight-coverings/</link>
      <description>hello everyone,&lt;br /&gt;
i have problems with this program and i am praying for your help.&lt;br /&gt;
The task is to put given number of knights, on given size chess board, that every square of the board is covered. That is, every square on the board is either occupied by a knight or attacked by a knight. knights can attack each other. the solutions are givven here. &lt;a href="http://www.contestcen.com/knight.htm"&gt;&lt;/a&gt;&lt;br /&gt;
i am using recursion. algorithm:&lt;br /&gt;
1. choose not occupied square&lt;br /&gt;
2. try every knight, which can occupy that square&lt;br /&gt;
3. choose another square and so on, till knight max number is reached.&lt;br /&gt;
basicly, i try every posibble knight positions.&lt;br /&gt;
i wrote program, which is below, but it crashes when i put more than 6 knights, and show nonsense in boards below 6. i know that the problem is in backtracking, when i need to delete a knight. but i dont know how to correct it.&lt;br /&gt;
again, praying for your help. Thanks in advance.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;program zirgai;
uses crt;
type lenta = array[1..8,1..8] of char;
     ejimai = array[1..8] of integer;
var L:lenta;
    N,M,Grizti:ejimai;
    zirgu_sk,dydis,r:integer;
//******************************//
procedure nulinimas(var L:lenta; d:integer);
var x,y:integer;
begin
for x:=1 to d do
    begin
    for y:=1 to d do
        begin
        L[x,y]:='0';
        end;
    end;
end;
//******************************//
procedure tikrinimas(L:lenta; d:integer; var r:integer);
var x,y:integer;
begin
r:=1;
for x:=1 to d do
    begin
    for y:=1 to d do
        begin
        if L[x,y]='0' then begin r:=0; break; end;
        end;
    if L[x,y]='0' then begin r:=0; break; end;
    end;
end;
//******************************//
procedure braizyti(L:lenta; d:integer);
var x1,x2,y1,y2,counter,x,y:integer;
begin
counter:=1;
y1:=1;
y2:=3;
    for x:=1 to d do                                          // draws a chess board
    begin
    x1:=1;
    x2:=5;
        for y:=1 to d do
        begin
        window(x1,y1,x2,y2);
        if (counter mod 2) = 0 then textbackground(red)
        else textbackground(green);
        clrscr;
        writeln;
        writeln('  ',L[x,y]);
        counter:=counter+1;
        x1:=x1+5;
        x2:=x2+5;
        end;
    y1:=y1+3;
    y2:=y2+3;
    if (d mod 2) = 0 then counter:=counter+1;
    end;
end;
//******************************//
procedure Delioti(zirgas,x,y:integer);
var i,z:integer;
begin
tikrinimas(L,dydis,r);
if r=1 then
begin
writeln('done');                    // checks if all sqaures are covered
braizyti(L,dydis);
readln;
exit;
end;
//////////////////////////////////////////////////
/////////
    if (x&amp;lt;&amp;gt;1) and (y&amp;lt;&amp;gt;1) and (zirgas&amp;lt;&amp;gt;0) then
    begin
        if (x&amp;gt;=1) and (y&amp;gt;=1) and (x&amp;lt;=dydis) and (y&amp;lt;=dydis) then
        begin
        L[x,y]:='Z';                                                                             // puts knight, and marks covered squares
            for i:=1 to 8 do
            begin
                if (x+N[i]&amp;gt;=1) and (y+M[i]&amp;gt;=1) and (x+N[i]&amp;lt;=dydis) and (y+M[i]&amp;lt;=dydis)
                and (L[x+N[i],y+M[i]]&amp;lt;&amp;gt;'Z') and (L[x+N[i],y+M[i]]&amp;lt;&amp;gt;'.') then
                begin
                L[x+N[i],y+M[i]]:='.';  Grizti[i]:=1;
                end;
            end;
        end;
    end;

//////////////////////////////////////////////////
/////////
    for x:=1 to dydis do
    begin
        for y:=1 to dydis do
        begin
        if (L[x,y]&amp;lt;&amp;gt;'Z') and (L[x,y]&amp;lt;&amp;gt;'.') then break;                          // finds not occupied square
        end;
    if (L[x,y]&amp;lt;&amp;gt;'Z') and (L[x,y]&amp;lt;&amp;gt;'.') then break;
    end;

    if zirgas&amp;lt;=zirgu_sk then
    begin
        for i:=1 to 8 do                                                         // recursion. calls procedure again and again
        begin
        Delioti(zirgas+1,x+N[i],y+M[i]);
        end;
    end;
//////////////////////////////////////////////////
/////////
    if (x&amp;lt;&amp;gt;1) and (y&amp;lt;&amp;gt;1) and (zirgas&amp;lt;&amp;gt;0) then
    begin
        if (x&amp;gt;=1) and (y&amp;gt;=1) and (x&amp;lt;=dydis) and (y&amp;lt;=dydis) then
        begin
        L[x,y]:='0';
            for i:=1 to 8 do
            begin
                if Grizti[i]=1 then
                begin                                                               // deletes knight, and his covered squares
                L[x+N[i],y+M[i]]:='0';
                end;
            end;
        end;
    end;
    for z:=1 to 8 do
    begin
    Grizti[z]:=0;
    end;
//////////////////////////////////////////////////
/////////
end;
//******************************//
begin
  N[1]:=1;  M[1]:=2;
  N[2]:=1;  M[2]:=-2;
  N[3]:=2;  M[3]:=-1;
  N[4]:=2;  M[4]:=1;
  N[5]:=-2; M[5]:=-1;
  N[6]:=-2; M[6]:=1;
  N[7]:=-1; M[7]:=-2;
  N[8]:=-1; M[8]:=2;
    for dydis:=1 to 8 do
    begin
    Grizti[dydis]:=0;
    end;
writeln('zirgu skaicius:');
readln(zirgu_sk);
writeln('lentos dydis:');
readln(dydis);
nulinimas(L,dydis);    // changes all squares value to '0'
Delioti(0,1,1);
readln;
end.
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431710/431710/recursion-backtracking-problem-knight-coverings/</guid>
      <pubDate>Tue, 26 Mar 2013 14:14:27 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Pascal compile problem</title>
      <link>http://www.programmersheaven.com/mb/pasprog/431678/431678/pascal-compile-problem/</link>
      <description>Good morning to everyone. I've been searching for two days, and I cannot find a solution for my problem. When I write a program in pascal turbo, I click run and it works perfectly, but when I try to open up the file in an executable (.exe) extension I can't and the computer gives me this error "The version of this file is incompatible with the version of Windows you are using(...)" , I've already changed the properties for every windows( xp, 95, vista etc...) and it doesn't work anyway. Any solution?. I've uploaded the file, please check if it works in your system(https://mega.co.nz/#!CkognDxS!GTywNkA-bmlM5HZfTb5IN25U2xdS9MggL12qSjN4Dig), I didn't upload it here since they do not accept .exe files. Thank you for reading this and for your time. (I'm using windows 7).&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/431678/431678/pascal-compile-problem/</guid>
      <pubDate>Sun, 24 Mar 2013 03:56:32 -0700</pubDate>
      <category>Pascal</category>
    </item>
  </channel>
</rss>