This is so embarrasing. lazarus / 61-Beginners ---------------------------------------------------------------------- TomTom · 2019-01-21 08:55 I'm preparing myself for random terrain generator. I wrote VERY basic program on my smartphone using some Pascal compilator and it work as I expected. Now I tried to write it in Lazaraus and sometimes (?) I get error... Why? What am I doing wrong ? My goal in this program is to populate 2dimensional array with 0 and 1. I use 'for' loop. Then I'm using another for loop to print my array. It's so embarrasing but I have no clue. It's strange that sometimes it works on first run after writing whole code. Code: [Select]program RandomizedArray; const   Dimension=10; var   x,y: integer;   arr: array [0..Dimension,0..Dimension] of integer; begin   Randomize();   For y:=0 to Dimension do       Begin         For x:=0 to Dimension do             Begin               arr[y,x]:=Random(2);             end;       end;   // print arr    For y:=0 to Dimension do       Begin         For x:=0 to Dimension do             Begin               Write(arr[y,x]);             end;         WriteLn();       end;   ReadLn(); end. ---------------------------------------------------------------------- marcov · 2019-01-21 09:14 Looks fine to me, but you do realize that 0..10 is a 11 element long array, so the arr array is 11x11 ? Do you get the error on the exact same program, and if so, which one? ---------------------------------------------------------------------- TomTom · 2019-01-21 09:37 [EDIT] Just 30 sec ago I worked and the next time I run my program it gave me SIGSEGV. Then it worked again.. So I'm guessing this is maybe about Randomize()/Random() part... It works on my phone and doesn't on pc. Just to be sure this is my smartphone code: Code: [Select]program randarray; const dihme = 10; uses crt; var x,y: integer tab: array[0..dihme,0..dihme] of integer; begin Randomize(); For y:=0 to dihme do       Begin         For x:=0 to dihme do             Begin               arr[y,x]:=Random(2);             end;       end;   // print arr    For y:=0 to dihme do       Begin         For x:=0 to dihme do             Begin               if arr[y,x]=0 then Write('.') else write('#'); //to see better :)             end;         WriteLn;       end;   ReadLn; ---------------------------------------------------------------------- marcov · 2019-01-21 09:38 Quote from: TomTom on January 21, 2019, 10:37:35 amIt works on my phone and doesn't on pc. What version of freepascal do you use on your smartphone? Please post the PC code that doesn't work and its associated errors. ---------------------------------------------------------------------- TomTom · 2019-01-21 09:44 I don't know what version of pascal I have on smartphone (it's Pascal N-IDE app) First code I've posted is from my PC, the last is from Smartphone Project compile without errors. Project sometime runs as expected and sometimes it shows me Message "Project project1 raised exception class 'External: SIGSEGV'." ---------------------------------------------------------------------- marcov · 2019-01-21 09:51 I ran the first code here several times and it worked fine. Then the only chance is the antivirus that does something weird, but that is unlikely as the running time is relatively low. Afaik N-ide is not freepascal based (as it states that it uses an interpreter) ---------------------------------------------------------------------- TomTom · 2019-01-21 09:53 [EDIT] I runned this program on other PC which is off the grid and program works.. So it's something with this particular PC that I'm working on . Well ... it's strange. Im writing this code at work (computers stuffed with bunch of weird anti-everything that is evil stuff) so maybe that's the case. I'll try this at home ---------------------------------------------------------------------- nouzi · 2019-01-21 10:56 try 'DCODER' compiler on smart phone basde on FreePascal https://dcoder.tech/