Running Pascal console programs results in an error lazarus / 31-LCL ---------------------------------------------------------------------- tjpren · 2012-06-01 10:38 hello, I've trying to expand my Lazarus experience, and tried running some downloaded pascal programs.  These are largely designed without a gui.  I think they are referred to as Console. I'm confused in that only some work.  Is it because the libraries Lazarus uses are different to the ones older pascal uses? As an example: Code: [Select]Circle(Random(800), Random(600), Random(400));  Works fine, but if I try Code: [Select]Rectangle(Random(800), Random(600), Random(400),Random(400));I get an error: project1.lpr(57,5) Error: Wrong number of parameters specified for call to "Rectangle" In Lazarus, I can trace the error to C:\lazarus\fpc\2.4.2\source\packages\graph\src\win32\graph.pp.  which shows that a Rectangle needs 5 parameters, not 4 as the example had. Is there another library I need to install. Not critisizing, just curious about the behaviour of Lazarus. Regards ---------------------------------------------------------------------- KpjComp · 2012-06-01 10:50 You'll probably find there multiple versions of Rectangle,  I assume the Rectangle version you want to use will be in the same Unit as your Circle, so find this out and you could either alter your uses clause so this appears as the last unit, or prefix your Circle with the unitname. eg.    ShapeUnit.Rectangle(.... ---------------------------------------------------------------------- tjpren · 2012-06-01 11:30 Hello KpjComp, I can find a reference to Circle as: procedure Circle16Win32GUI(X, Y: smallint; Radius:Word);  living in C:\lazarus\fpc\2.4.2\source\packages\graph\src\win32\graph.pp The only reference to rectangle is: Windows.Rectangle(windc,0,0,maxx,maxy); Which is why it bombs out - 5 parameters instead of 4. I note from googling that the #RTL has a Graph unit with all shapes, but my Lazerus doesn't seem to have a graph unit.  When I search the lazerus directory, I can see an rtl directory, but no graph sub directory. I'm using Laz 9.30, should I search for an update #RTL? Thanks ---------------------------------------------------------------------- KpjComp · 2012-06-01 11:50 I'm using 9.31, fpc 2.7.1 In unit graph.pp, I have -> Code: [Select]{ Linearly bounded primitives } procedure Rectangle(x1, y1, x2, y2: Integer); So yes you might need to update if this is missing. ---------------------------------------------------------------------- tjpren · 2012-06-01 12:42 Hello KpjComp, I just downloaded the most recent from the sourceforge, and it was lazarus-0.9.30.4-fpc-2.6.0-win32.exe.  Do you get your'se from a different place? I ran up the new version, and graph.pp is still the same as the previous.  I get a slightly different error, but same result.  The error refers again to 5 parameters Code: [Select]function Rectangle(_para1:HDC; _para2:longint; _para3:longint; _para4:longint; _para5:longint):WINBOOL; external 'gdi32' name 'Rectangle';      in C:\lazarus\fpc\2.6.0\source\rtl\win\wininc\func.inc ---------------------------------------------------------------------- KpjComp · 2012-06-01 12:50 Have you looked in graph.pp, I'd be surprised if there is Circle & no Rectangle. Your still using the Win32 Rectangle, and not the graph version here.  So you will continue to get the error. Could you show us your uses clause? Does,   graph.Rectangle(...   work?   If it does, just make sure graph is the last unit in your uses clause to save putting graph in front of all your Rectangle's. I'm currently using CodeTyphon 2.50, this ships with 9.3.1 & 2.7.1 ---------------------------------------------------------------------- tjpren · 2012-06-01 13:19 KPJComp, Yes you are correct, graph.rectangle(etc) works, and I only need 4 parameters.  But I am unclear why.  The circle doesn't need a prefix, and the reference in graph.pp is to Windows.Rectangle(bitmapdc,0,0,maxx,maxy); which has 5 parameters. Maybe I'm searching the wrong place? If I right click rectangle, I goto refactoring>>Find Identifyer References, I get C:\lazarus\fpc\2.6.0\source\packages\graph\src\win32\graph.pp. You are also correct about putting Graph last in the uses. I'll have to remeber that - do you know why this happens? You have been very helpful - I very much appreciate it. I've included my code - it's pretty basic.  As I said, i'm trying to get ahandlwe on console side programming. ---------------------------------------------------------------------- KpjComp · 2012-06-01 13:50 Quotedo you know why this happens? It's just that Rectangle is a very popular identifier, and because there all sharing the same global namespace we get a clash. And because there is a version in windows & graph, it has to decide which version to use.  In pascal the last defined reference it what it will decide to use, so putting graph at the end of your uses clauses means it will search Graph first / and then the other uses in reverse order.