Recent

Author Topic: exitcode  (Read 4836 times)

returner

  • Newbie
  • Posts: 5
exitcode
« on: January 07, 2018, 11:53:44 pm »
Hi, here is the "returner" again:
I was so happy that my 79 lines program was compiled with no (!!!) mistake, but running it I got immediatelly, i.e. without really running the programm, the message "exitcode 201". Can anybody tell where I could find an explanation for that exitcode and similars - I'm afraid I'll have to deal with them.

Kays

  • Hero Member
  • *****
  • Posts: 632
  • Whasup!?
    • KaiBurghardt.de
Re: exitcode
« Reply #1 on: January 08, 2018, 12:11:43 am »
[…] Can anybody tell where I could find an explanation for that exitcode and similars - I'm afraid I'll have to deal with them.
Yeah, me too, I'm always confusing “is it in the programmer's or in the user's manual, or neither but the reference guide⁇”.

Run-time errors are documented in the user's guide.

Now, to treat it, you have to have a look at the programmer's guide.

I know, everything's confusing. If have the package fp-docs installed, you'll find them at /usr/share/doc/fp-docs/3.0.0/. Ideally, to help you more targeted, you'd post your code, especially since it's just less than a hundred lines.
Yours Sincerely
Kai Burghardt

jamie

  • Hero Member
  • *****
  • Posts: 7519
Re: exitcode
« Reply #2 on: January 08, 2018, 01:25:49 am »
Now is the time for you to learn how to use the Help file.

Look for Run-Time-Errors..

 of course if this is an actual Windows Error then you won't find that in the list and that error
is
 "RELOC_CHAIN_XCEEDS_SEGLIM"

 Which could mean a lot I guess, like maybe overriding memory etc.. But I would be more
inclined to say its a "Range Check Error", meaning, you went outside of a range on an array
or something like that.
The only true wisdom is knowing you know nothing

soerensen3

  • Full Member
  • ***
  • Posts: 213
Re: exitcode
« Reply #3 on: January 08, 2018, 01:36:35 am »
If you Google Fpc error you even get the explanation in top of your search results.
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

returner

  • Newbie
  • Posts: 5
Re: exitcode
« Reply #4 on: January 10, 2018, 07:33:57 am »
Thanx for your hints concerning exitcode 201.
I controlled my program code but could not find any reason for mismatches
 with the array definitions.  :'(

I'd be cvery happy and thank if ana body would like to have a look at my program code (88 lines) - but: all my comments are in german. My aim is to generate a 9x9 square of 1..9 numbers according to the rules of sudoku. It's just an exercise to repeat Pascal a little bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: exitcode
« Reply #5 on: January 10, 2018, 07:43:27 am »
I know, everything's confusing. If have the package fp-docs installed, you'll find them at /usr/share/doc/fp-docs/3.0.0/. Ideally, to help you more targeted, you'd post your code, especially since it's just less than a hundred lines.

Please don't refer to out of date documentation. In this case it does not matter, but this can confuse people even more.

To Returner:
A range check error means your code is NOT ok...My guess is you forgot that real programmers count from zero... e.g. it is not 1 to 10 but 0 to 9 or something.
Range check errors are easy to fix, but also a *must* fix. Although "advanced" programmers can mis-use a range on purpose (array [0..0] ) this is almost never a good idea.
« Last Edit: January 10, 2018, 08:01:27 am by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: exitcode
« Reply #6 on: January 10, 2018, 08:09:00 am »
Thanx for your hints concerning exitcode 201.
I controlled my program code but could not find any reason for mismatches
 with the array definitions.  :'(
that is because there is nothing wrong with your array definitions.... that is, as long as your code stays within their actual size (which your current code does not).

Quote
I'd be cvery happy and thank if ana body would like to have a look at my program code (88 lines) - but: all my comments are in german. My aim is to generate a 9x9 square of 1..9 numbers according to the rules of
Why don't you have a look yourself ? the error also tells in which exact line it occurs (if you have compiled with -gl)

hint:
Code: [Select]
i = 2 j = 1 k = 1 z = 1
i = 2 j = 1 k = 1 z = 2
i = 2 j = 1 k = 1 z = 3
i = 2 j = 1 k = 1 z = 4
i = 2 j = 2 k = 1 z = 4
i = 2 j = 2 k = 1 z = 5
i = 2 j = 3 k = 1 z = 5
i = 2 j = 3 k = 1 z = 6
i = 2 j = 4 k = 2 z = 6
i = 2 j = 4 k = 2 z = 7
i = 2 j = 5 k = 2 z = 7
i = 2 j = 5 k = 2 z = 8
i = 2 j = 6 k = 2 z = 8
i = 2 j = 6 k = 2 z = 9
i = 2 j = 7 k = 3 z = 9
i = 2 j = 7 k = 3 z = 10
« Last Edit: January 10, 2018, 08:19:05 am by molly »

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: exitcode
« Reply #7 on: January 10, 2018, 08:38:42 am »
Note I see your program is ISO mode. There has been a bugfix in trunk related to indexing in ISO mode this week.
Although your program is wrong anyway, maybe mollie missed that. I will test it now (I speculated about the indexing before w/o testing.)
It would have been helpful if you marked your code with {$mode iso}. Not everybody on this forum will recognize it as such.

[edit]
I tested this with -Miso on trunk... Your code still has a range check error.... and the compiler shows you where it is, just like mollie says...and I was right too: you are over-indexing...
« Last Edit: January 10, 2018, 08:46:49 am by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

Handoko

  • Hero Member
  • *****
  • Posts: 5515
  • My goal: build my own game engine using Lazarus
Re: exitcode
« Reply #8 on: January 10, 2018, 08:50:40 am »
The code hurts my eyes. %)
@returner, you should practice to format code. A beautiful code not only looks good, it also will help you debug faster.

Here is your code after code tag added and formatted:

Code: Pascal  [Select][+][-]
  1. program sudoku7 (input, output);
  2.  
  3. {Vereinbarungen}
  4. type
  5.   menge = set of 1..10;
  6.  
  7. var
  8.   i, j, k, l, z      : 1..10;
  9.   n                  : 1..100;
  10.   bh                 : array [1..9] of integer;
  11.   vm                 : array [1..99, 1..3] of integer;
  12.   qs, qk, kq, ks, kz : array [1..9, 1..9] of integer;
  13.   m1, m2, m3         : menge;
  14.  
  15. begin
  16.  
  17.   {Allgemeine Vorbesetzungen}
  18.   m1 := [1, 2, 3];
  19.   m2 := [4, 5, 6];
  20.   m3 := [7, 8, 9];
  21.   for i := 1 to 9 do
  22.     for j := 1 to 9 do
  23.     begin
  24.       qs[i, j] := 0;
  25.       kq[i, j] := 0;
  26.       kz[i, j] := 0;
  27.       ks[i, j] := 0;
  28.       if (i in m1) and (j in m1) then qk[i, j] := 1;
  29.       if (i in m1) and (j in m2) then qk[i, j] := 2;
  30.       if (i in m1) and (j in m3) then qk[i, j] := 3;
  31.       if (i in m2) and (j in m1) then qk[i, j] := 4;
  32.       if (i in m2) and (j in m2) then qk[i, j] := 5;
  33.       if (i in m2) and (j in m3) then qk[i, j] := 6;
  34.       if (i in m3) and (j in m1) then qk[i, j] := 7;
  35.       if (i in m3) and (j in m2) then qk[i, j] := 8;
  36.       if (i in m3) and (j in m3) then qk[i, j] := 9;
  37.     end;
  38.  
  39.   {Besetzung von QS samt Buchhaltung
  40.   n zählt die besetzten Felder,
  41.   i ist die Zeilennummer in QS,
  42.   j ist die Spaltennummer in QS,
  43.   k ist die Kleinqudratnummer in QS,
  44.   z ist das Zeichen in QS[i,j]}
  45.  
  46.   {Besetzung der ersten 9 Zeichen in Zeile 1 von QS}
  47.   for n := 1 to 9 do
  48.   begin
  49.     i := 1;
  50.     j := n;
  51.     z := n;
  52.     qs[i, j] := z;
  53.     k := qk[i, j];
  54.     kz[i, z] := 1;
  55.     ks[j, z] := 1;
  56.     kq[k, z] := 1;
  57.     vm[n, 1] := z;
  58.     vm[n, 2] := i;
  59.     vm[n, 3] := j;
  60.     bh[z] := 1;
  61.   end;
  62.  
  63.   {Beginn der iterativen Besetzung von QS ab Zeile 2}
  64.   i := 2;
  65.   j := 1;
  66.   k := qk[i, j];
  67.   z := 1;
  68.   n := 9;
  69.  
  70.   while n < 100 do
  71.   begin {n}
  72.     while (kz[i, z] + ks[j, z] + kq[k, z]) > 0 do
  73.       z := z + 1;
  74.     if z < 10 then
  75.     begin {Besetzen von QS[i,j] mit z samt Buchhaltung}
  76.       qs[i, j] := z;
  77.       k := qk[i, j];
  78.       kz[i, z] := 1;
  79.       ks[j, z] := 1;
  80.       kq[k, z] := 1;
  81.       bh[z] := bh[z] + 1;
  82.       n := n + 1;
  83.       vm[n, 1] := z;
  84.       vm[n, 2] := i;
  85.       vm[n, 3] := j;
  86.       if j < 9 then
  87.         j := j + 1
  88.       else
  89.       begin
  90.         i := i + 1;
  91.         j := 1;
  92.         z := 1;
  93.       end;
  94.       k := qk[i, j];
  95.     end {Besetzen von QS[i,j] mit z samt Buchhaltung}
  96.     else
  97.     begin {Frühere Besetzung ändern}
  98.       n := n - 1;
  99.       z := vm[n, 1];
  100.       i := vm[n, 2];
  101.       j := vm[n, 3];
  102.       bh[z] := bh[z] - 1;
  103.       qs[i, j] := 0;
  104.       k := qk[i, j];
  105.       kz[i, z] := 0;
  106.       ks[j, z] := 0;
  107.       kq[k, z] := 0;
  108.       if z = 9 then
  109.       begin
  110.         n := n - 1;
  111.         z := vm[n, 1];
  112.         i := vm[n, 2];
  113.         j := vm[n, 3];
  114.       end
  115.       else
  116.         z := z + 1;
  117.     end; {Frühere Besetzung ändern}
  118.   end {n};
  119.  
  120.   for i := 1 to 9 do
  121.   begin
  122.     for j := 1 to 9 do
  123.     begin
  124.       Write(qs[i, j], ' ');
  125.       if j in [3, 6] then
  126.         Write(' ');
  127.     end;
  128.     writeln;
  129.     if i in [3, 6] then
  130.       writeln;
  131.   end;
  132.   Read(i);
  133. end.

I didn't test the code, but my eye-inspection tell me there should be something wrong with:
- Line 11
- Line 70
- Line 82

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: exitcode
« Reply #9 on: January 10, 2018, 09:01:23 am »
Code: Bash  [Select][+][-]
  1. ptop sudoku7.pas sudoku7.pas

Then it won't hurt some much...
« Last Edit: January 10, 2018, 09:05:20 am by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

returner

  • Newbie
  • Posts: 5
Re: exitcode
« Reply #10 on: January 10, 2018, 03:15:53 pm »
Thank you to all who looked at my Sudoku-program and for your hints. I learned above all that I have to dive deeper into the "infrastructure" of FPC. Until now I do not yet know how to run the compiler under different options - or what the specialities of ISO-mode are. Nor can I do with adresses given when runtime exits occure. You see much work is to be done by me. The last time I wrote Pascal-programs (more than 40 years ago) I still used punchcards I had to bring to an operator where I afterwards got a listing made by a chain-printer. Nice to have you as helpful backgroung. Udo

returner

  • Newbie
  • Posts: 5
Re: exitcode
« Reply #11 on: January 11, 2018, 11:17:48 am »
Hi, thanks to molly's listing I found one (!) of my mistakes - and the program generated the wanted sudoku-square. But other bugs still exist: When I changed the numbers in the first line, a square with multiple numbers in one row was generated. But I will overcome them. Thanks again for your helpful hints for the "returner".

 

TinyPortal © 2005-2018