Re: [fpc-pascal] FP IDE sources

2024-03-14 Thread Guillermo Martínez Jiménez via fpc-pascal
Thanks, Karoly and Marco.

I thought "packages" were libraries not applications, as there is an
"utils" directory with programs.

Thankyou again,
Guillermo Martínez.

El Wed, 13 Mar 2024 22:45:19 +0100
Marco van de Voort via fpc-pascal 
escribió:
> Op 13-3-2024 om 21:34 schreef Karoly Balogh via fpc-pascal:
> > H
> >
> > Where are they?  Why aren't with the official source packages?
> > But they are. The IDE code is here:
> > https://gitlab.com/freepascal.org/fpc/source/-/tree/main/packages/ide
> >
> > It also depends on Free Vision, which is here:
> > https://gitlab.com/freepascal.org/fpc/source/-/tree/main/packages/fv
> >
> > The ASCII table code is part of Free Vision, and it's here:
> > https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/fv/src/asciitab.pas
> >  
> And the mouse-keyboard-video drivers are in package rtl-console, e.g. 
> for windows
> 
> 
> https://gitlab.com/freepascal.org/fpc/source/-/tree/main/packages/rtl-console/src/win
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] FP IDE sources

2024-03-13 Thread Guillermo Martínez Jiménez via fpc-pascal
Hi Pascaloids,

I was looking for the FP IDE sources to check how it renders the ASCII
table and manage the mouse input, but I'm not able to find them.
They're not in GitLab, not in the source packages, not in the download
pages. Lazarus Wiki has two pages "Textmode IDE" and "Textmode IDE
development" but none of them have any link or reference of how to find
the sources.

Where are they?  Why aren't with the official source packages?

Regards,
Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Nested comments.

2024-01-22 Thread Guillermo Martínez Jiménez via fpc-pascal
El Sun, 21 Jan 2024 17:27:15 +0100
Adriaan van Os via fpc-pascal 
escribió:
> 
> ($modeswitch nestedcomments-}
>
I didn't know about this switch.  Thanks, maybe I can use it.

Guillermo Martínez J.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Nested comments.

2024-01-22 Thread Guillermo Martínez Jiménez via fpc-pascal
El Sun, 21 Jan 2024 17:12:05 +0100
Tomas Hajny via fpc-pascal  escribió:

> Well, I guess that you use mode Delphi, because warning about nested 
> comments and even an error in your case (due to nested comment not 
> closed) is already issued by default. So the very simple solution is 
> using e.g. -Mobjfpc. ;-)

That's it: I'm using Delphi mode because code should work both Delphi
and FreePascal.

Thanks for the note.

Guillermo Martínez J.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Nested comments.

2024-01-21 Thread Guillermo Martínez Jiménez via fpc-pascal
Hi Pascaloids,

I'm wondering if it is possible to make FPC detect and warn (or even
stop compillation when) it has detect a nested comment.  That's because
I'm using Vim and it closes odd comments.  For example, the nex code:

{ This comment isn't closed. *)
  DoSomething ();
{ This is a nested comment. }

I know this is a silly mistake, but sometimes I comment batchs of codde
to deactivate them temporary and when un-comment they're non paired and
it result in weird runtime bugs.

A command line option that activate that functionality would be great.
Something like -wn (because -vn is used for notes).

What do you thing?

Guillermo "Ñuño" Martínez.
Piopio Juegos.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ShortString still relevant today?

2023-07-04 Thread Guillermo Martínez Jiménez via fpc-pascal
Hi,

I'm not sure but I think that CPU caches (L1, L2...) have some impact
on this example.  Also I think PChar assignation should use string
copy instead (Strings.strcopy).  Not time to do my own tests right now
though u_u) .

Regards,
Guillermo "Ñuño" Martínez

El Tue, 4 Jul 2023 11:46:42 +0700
Hairy Pixels via fpc-pascal  escribió:
> Here is my test unit I'm playing with. It's crude but can anyone
> suggest what other things I could test? 
> 
> I'm playing with a string pointer also to see how ref
> counting/finalization plays in. Making your own managed typed using
> management operators is not tested but I'm sure it will be terrible
> compared to everything else.
> 
> * test_short_string time: 143ms
> * test_ansi_string time: 115ms
> * test_mem_string time: 115ms
> 
> * test_short_string_record time: 165ms
> * test_ansi_string_record time: 75ms
> * test_mem_string_record time: 47ms
> 
> * test_short_string_mutate time: 203ms
> * test_ansi_string_mutate time: 181ms
> 
> ===
> 
> {$mode objfpc}
> 
> program string_test;
> uses
>   SysUtils, DateUtils;
> 
> const
>   ITERATIONS = 1000 * 1000;
>   TEST_STRING = 'Lorem ipsum dolor sit amet, consectetur adipiscing
> elit';
> 
> type
>   TTestProc = procedure;
> 
> procedure test_mem_string;
> 
>   procedure do_pass(const s: PString; len: Integer);
>   var
> c: Char;
> i: Integer;
>   begin
> for i := 0 to len - 1 do
>   c := s^[i];
>   end;
> 
> var
>   s: PString;
>   i, len: Integer;
> begin
>   for i := 0 to ITERATIONS - 1 do
> begin
>   len := Length(TEST_STRING);
>   s := GetMem(len);
>   s^ := TEST_STRING;
>   do_pass(s, len);
>   FreeMem(s);
> end;
> end;
> 
> procedure test_short_string;
> 
>   procedure do_pass(const s: ShortString);
>   var
> c: Char;
> i: Integer;
>   begin
> for i := 0 to length(s) - 1 do
>   c := s[i];
>   end;
> 
> var
>   s: Shortstring;
>   i: Integer;
> begin
>   for i := 0 to ITERATIONS - 1 do
> begin
>   s := TEST_STRING;
>   do_pass(s);
> end;
> end;
> 
> procedure test_ansi_string;
> 
>   procedure ansi_string_pass(const s: AnsiString);
>   var
> c: Char;
> i: Integer;
>   begin
> for i := 0 to length(s) - 1 do
>   c := s[i];
>   end;
> 
> var
>   s: AnsiString;
>   i: Integer;
> begin
>   for i := 0 to ITERATIONS - 1 do
> begin
>   s := TEST_STRING;
>   ansi_string_pass(s);
> end;
> end;
> 
> procedure test_ansi_string_mutate;
> var
>   i, j: Integer;
>   s1, s2: AnsiString;
> begin
>   for i := 0 to ITERATIONS - 1 do
> begin
>   s1 := TEST_STRING;
>   s2 := s1 + IntToStr(i);
>   for j := 1 to length(s2) - 1 do
> s2[j] := 'x';
> end;
> end;
> 
> procedure test_short_string_mutate;
> var
>   i, j: Integer;
>   s1, s2: ShortString;
> begin
>   for i := 0 to ITERATIONS - 1 do
> begin
>   s1 := TEST_STRING;
>   s2 := s1 + IntToStr(i);
>   for j := 1 to length(s2) - 1 do
> s2[j] := 'x';
> end;
> end;
> 
> procedure test_short_string_record;
> 
> type
>   TMyRecord = record
> a: ShortString;
> b: ShortString;
> c: ShortString;
>   end;
> 
> function do_pass(rec: TMyRecord): TMyRecord;
> begin
>   result := rec;
> end;
> 
> var
>   i: Integer;
>   r: TMyRecord;
> begin
>   for i := 0 to ITERATIONS - 1 do
> begin
>   r.a := TEST_STRING;
>   r.b := TEST_STRING;
>   r.c := TEST_STRING;
>   do_pass(r);
> end;
> end;
> 
> 
> procedure test_ansi_string_record;
> 
> type
>   TMyRecord = record
> a: AnsiString;
> b: AnsiString;
> c: AnsiString;
>   end;
> 
> function do_pass(rec: TMyRecord): TMyRecord;
> begin
>   result := rec;
> end;
> 
> var
>   i: Integer;
>   r: TMyRecord;
> begin
>   for i := 0 to ITERATIONS - 1 do
> begin
>   r.a := TEST_STRING;
>   r.b := TEST_STRING;
>   r.c := TEST_STRING;
> 
>   do_pass(r);
> end;
> end;
> 
> procedure test_mem_string_record;
> 
> type
>   TMyRecord = record
> a: PString;
> b: PString;
> c: PString;
>   end;
> 
> function do_pass(rec: TMyRecord): TMyRecord;
> begin
>   result := rec;
> end;
> 
> var
>   i: Integer;
>   r: TMyRecord;
>   len: Integer;
> begin
>   len := Length(TEST_STRING);
> 
>   for i := 0 to ITERATIONS - 1 do
> begin
>   r.a := GetMem(len);
>   r.b := GetMem(len);
>   r.c := GetMem(len);
> 
>   r.a^ := TEST_STRING;
>   r.b^ := TEST_STRING;
>   r.c^ := TEST_STRING;
> 
>   do_pass(r);
> end;
> end;
> 
> 
> procedure run_test(name: String; test: TTestProc);
> var
>   startTime: Double;
> begin
>   startTime := Now;
>   test;
>   writeln('* ', name,' time: ', MilliSecondsBetween(Now, StartTime),
> 'ms'); end;
> 
> begin
>   run_test('test_short_string', @test_short_string);
>   run_test('test_ansi_string', @test_ansi_string);
>   run_test('test_mem_string', @test_ansi_string);
> 
>   run_test('test_short_string_re

Re: [fpc-pascal] SDL2 Event Registration (and case statements)

2023-06-27 Thread Guillermo Martínez Jiménez via fpc-pascal
El Sun, 25 Jun 2023 13:42:00 -0300
Rafael Picanço via fpc-pascal 
escribió:
> Thanks Guilhermo,

You welcome. :)

> 
> Just to clarify, I do have a limited number of events. Lets say, 2
> events. So, using the SDL_RegisterEvents function, is it possible to
> define these two new events as normal constants so they will be known
> at compile time and will make Free Pascal case statements happy?

Yes, you can.  But be careful that no other events are registered before
yours.

> 
> Best,
> R

Regards,
Guillermo Martínez

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] SDL2 Event Registration (and case statements)

2023-06-25 Thread Guillermo Martínez Jiménez via fpc-pascal
Hi.

> The SDL2 documentation recommends you to register constants with:
> 
> Uint32 SDL_RegisterEvents(int numevents);
>numevents = the number of events to be allocated.
>Returns the beginning event number, or (Uint32)-1 if there are not
> enough user-defined events left.
> 
> The SDL_RegisterEvents result is not known at compile time, so one
> can't use them as case conditions. So, Is there a workaround for
> building these constants at compile time?
If you know how many events were registered, then you can create
constants.  Else, you can't.

> 
> Best,
> R

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] C Enum vs. Integer

2012-09-13 Thread Guillermo Martínez Jiménez
> On 12 Sep 2012, at 19:11, Johann Glaser wrote:
>
>> Can I translate this 1:1, i.e., define an Enum in Pascal and just ignore
>> the compiler warnings about reused values?
>>
>> Or should I rather define all these types as Integer and define
>> constants for all values?
>
> It depends on whether you need arithmetic or not. If you do, use integer 
> constants, otherwise you can use an enum.

Actually you cannot.  FPC optimizes enumerations in some cases (i.e.
in Delphi mode) but GCC uses 32bit for enumerations alwais.

Anyway you can still use enums, but telling to FPC that you want to
set its size by directives $PACKENUM and $ENUMSIZE.

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: DOSbox issues

2012-08-20 Thread Guillermo Martínez Jiménez
From: Reinier Olislagers
> Just for interest: are you trying out FPC for DOS for fun or do you need
> to create/support DOS (not Windows) programs?

I think I'm trying it just for fun.  Actually I was angry because my
Allegro.pas wrapper doesn't work (well, version 4.4 almost do but version 5
only does on "debug" mode), so I was wondering to write an actual port of
the library instead of a wrapper.  I did wrote a simple DOS game library in C
a lot of years ago so I think it's a good place to start with, and also
because I liked DOS a lot and Allegro dropped out it some time ago.  Also I
think that Pascal deserves its own "game library" instead of use those "C style"
ones as SDL and Allegro.

I think I'll try FreeDOS in a VM.  I hope I can remember how to mount
a FAT32 image
on Linux...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] DOSbox issues

2012-08-19 Thread Guillermo Martínez Jiménez
Hello everybody,

Has somebody used Free Pascal 2.6 in DOSbox?

I'm having problems with the installer (text looks corrupted and it
doesn't install) but I don't know if it's an issue in all DOSbox or
it's because I'm using it in a 64bit Linux (Xubuntu 12.04).

Greetings,
Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Runs correctly when debugging.

2012-05-10 Thread Guillermo Martínez Jiménez
> No, you have to use pchar.  I would also define ALLEGRO_BITMAP as an
> empty record, to be clear that it's an opaque type:
>
> {$packrecords c}
>  TAllegroBitmap = record
>  end;
>  PAllegroBitmap = ^TAllegroBitmap;
>
> Thus:
>
> function al_load_bitmap(const filename: pchar): PAllegroBitmap; cdecl;
> external ALLEGRO_LIB_NAME;
>
> Make sure you use {$packrecords c}.  Use the types in unit "ctypes",
> e.g. cint, cfloat, cdouble.  This will ensure the variables are the same
> size and work on all architectures.
>
> Henry

Ok, then I should revise all the "STRING" parameters, as well as all
pointer types and "ctypes".

Thanks for the advices.
Guillermo.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Runs correctly when debugging.

2012-05-08 Thread Guillermo Martínez Jiménez
> From: Henry Vermaak
> Subject: Re: [fpc-pascal] Re: Runs correctly when debugging.
>
> It's hard to say without seeing your function/type declarations.

Actually I don't call the function that raises the SIGSEGV signal,
since it's an internal function.  Allegro has a "driver" struct
(RECORD) that stores a pointer to this function only if OpenGL is used
(else it uses DirectX or something like that), then functions that
uses or modifies the "bitmap" struct uses it.

For example, it's used by next function:

  ALLEGRO_BITMAP *al_load_bitmap(const char *filename);

The wrapper I wrote is:

  TYPE
  (* Abstract type representing a bitmap (2D image). *)
ALLEGRO_BITMAPptr = POINTER;

  FUNCTION al_load_bitmap (CONST filename: STRING): ALLEGRO_BITMAPptr; CDECL;
  EXTERNAL ALLEGRO_LIB_NAME;

I'm concerning about the "STRING" type as it may affect the stack (I
had problems with enumerations because FPC optimised them and C
doesn't) and use "PCHAR" instead, but manual says it's not a problem
if using "-h" or "{$LONGSTRINGS ON}".
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Runs correctly when debugging.

2012-05-07 Thread Guillermo Martínez Jiménez
Thanks, Henry,

> Can you give any more information about how it fails?

It's a "SIGSEGV".  The library is the Allegro library version 5.0.6.

The error is inside an internal procedure that uploads a texture to
OpenGL context, and it is used by other Allegro functions (i.e.
loading pictures from file, building text fonts, etc.).

Initially I suspected that I didn't use the right data types, but
after revisiting and fixing some of them it I'm pretty sure I'm using
the right ones.

I don't know what can I say. :-/

> You may have to set the fpu exception mask if you're talking to c code,
> as a quick guess (search the archives for how).  Don't know why this
> works with debugging enabled, though.

I've revise the command-line options list and the only one I've find is that:

-Cf Select fpu instruction set to use, see fpc -i for possible values

I don't know how can it help. :-?

Regards,
Guillermo Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Runs correctly when debugging.

2012-05-04 Thread Guillermo Martínez Jiménez
Hello everybody,

I'm working on a wrapper of a C library.  I've found a bug, but I
can't debug it with GDB because if I compile with "-g" and link with
the debug version of the library it works correctly.

But if I compile with "-g" and link with the release version of the
library, I can't debug it because it fails inside the library.  So I
suspect there's a problem with a data conversion CPU exception
activated by FPC.

What can I do?

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Weird compilation warnings

2012-03-01 Thread Guillermo Martínez Jiménez
Oh, I see.  It has sense.  The "extra implicit parameter" part
confused me because I didn't use OOP in that project.

Thank you :)

2012/3/1  :
> From: Sven Barth 
> Subject: Re: [fpc-pascal] Weird compilation warnings
>
> Am 29.02.2012 22:53, schrieb Guillermo Martínez Jiménez:
>> Hello,
>>
>> FPC is returning the "Warning: cdecl’ared functions have no high
>> parameter" but I have no idea why.  The documentation just says
>> "Functions declared with the cdecl modifier do not pass an extra
>> implicit parameter." but the affected functions don't have any "extra
>> implicit parameter".
>>
>> I'm using FPC 2.4.2 (the one that came with Lazarus).
>>
>> Here you have some sample code:
>> ___
>>
>> UNIT a...;
>> IMPLEMENTATION
>>
>>    {$MODE FPC}
>>    {$PACKRECORDS C}
>>    {$LONGSTRINGS ON}
>>
>> { Next declaration compiles Ok. }
>>    PROCEDURE al_draw_ustr (CONST font: ALLEGRO_FONTptr; color:
>> ALLEGRO_COLOR; x, y: SINGLE; flags: LONGINT; CONST ustr:
>> ALLEGRO_USTRptr); CDECL;
>>
>> { Next one raises the "WARNING" }
>>    FUNCTION al_grab_font_from_bitmap (bmp: ALLEGRO_BITMAPptr; n:
>> LONGINT; ranges: ARRAY OF LONGINT): ALLEGRO_FONTptr; CDECL;
>> ...
>
> You are passing an open array here. open arrays are realized internally
> by passing a pointer to the start of the array and an (implicit) high
> parameter which lets the compiler deduce the length of the array. This
> is not supported with cdecl or cppdecl. If you want a cdecl function to
> receive an array you should write something like this:
>
>     FUNCTION al_grab_font_from_bitmap (bmp: ALLEGRO_BITMAPptr; n:
>  LONGINT; ranges: PLONGINT; len: LONGINT): ALLEGRO_FONTptr; CDECL;
>
> Do you want to provide this functions from inside a DLL? If so you
> should use my above variant, because other languages don't understand
> Pascal's open arrays (because of the implicit high parameter). If you
> only use the function inside your own Pascal code I suggest you to not
> use cdecl functions if it's not really necessary.
>
> Regards,
> Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Weird compilation warnings

2012-02-29 Thread Guillermo Martínez Jiménez
Hello,

FPC is returning the "Warning: cdecl’ared functions have no high
parameter" but I have no idea why.  The documentation just says
"Functions declared with the cdecl modifier do not pass an extra
implicit parameter." but the affected functions don't have any "extra
implicit parameter".

I'm using FPC 2.4.2 (the one that came with Lazarus).

Here you have some sample code:
___

UNIT a...;
IMPLEMENTATION

  {$MODE FPC}
  {$PACKRECORDS C}
  {$LONGSTRINGS ON}

{ Next declaration compiles Ok. }
  PROCEDURE al_draw_ustr (CONST font: ALLEGRO_FONTptr; color:
ALLEGRO_COLOR; x, y: SINGLE; flags: LONGINT; CONST ustr:
ALLEGRO_USTRptr); CDECL;

{ Next one raises the "WARNING" }
  FUNCTION al_grab_font_from_bitmap (bmp: ALLEGRO_BITMAPptr; n:
LONGINT; ranges: ARRAY OF LONGINT): ALLEGRO_FONTptr; CDECL;
...

IMPLEMENTATION

  PROCEDURE al_draw_ustr (CONST font: ALLEGRO_FONTptr; color:
ALLEGRO_COLOR; x, y: SINGLE; flags: LONGINT; CONST ustr:
ALLEGRO_USTRptr); CDECL;
  EXTERNAL ALLEGRO_FONT_LIB_NAME;

  FUNCTION al_grab_font_from_bitmap (bmp: ALLEGRO_BITMAPptr; n:
LONGINT; ranges: ARRAY OF LONGINT): ALLEGRO_FONTptr; CDECL;
  EXTERNAL ALLEGRO_FONT_LIB_NAME;
...

END.
_

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: How choose units names?

2010-07-21 Thread Guillermo Martínez Jiménez
> Date: Wed, 21 Jul 2010 16:55:14 -0300
> From: Marcos Douglas
>
> How you have no conflict with names of the units? Do you use some
> prefix in your units as "uwebutils.pp", "mywebutils.pp",
> "xyzWebUtils.pp", etc.

I do use descriptive names, of course. I also use a "Unit" or "U"
prefix; i. e.: "UnitConfiguration" or "UConfiguration". Also in some
projects use an unique prefix; i. e.: my Allegro.pas wrapper library
uses "al" as prefix, such as "al3d", "alfile", "albase", etc.

Guillermo "Ñuño" Martínez.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Is this if /else syntax wrong?

2010-07-01 Thread Guillermo Martínez Jiménez
> procedure TfrmHometel.SetSplitterSizes;
> var
>  i: integer;
> begin
>  for i:=3D 0 to ComponentCount - 1 do
>  begin
>   if Components[i] is TSplitter then
>   begin
>     with TSplitter(Components[i]) do
>     begin
>      if Cursor =3D crHSplit then
>        Width :=3D 7
>      else if Cursor =3D crVSplit then
>        Height :=3D 7;
>      ; // <-- removing this semicolon results in a syntax error. Is it
> syntax error some kind of extra strict compiler check.
>      Color :=3D clBlue;
>     end;
>   end;
>  end;
> end;

Compare with next:

  if Cursor =3D crHSplit then
Width :=3D 7
  else
if Cursor =3D crVSplit then
  Height :=3D 7; // <-- This semicolon is for the "if".
  ; // <-- This semicolon is for the "else".

Is like this:

IF ... THEN
BEGIN
  ...
END
ELSE BEGIN
  IF ... THEN
  BEGIN
...
  END;  // <-- This END is for the "IF".
END;  // <-- This END is for the "ELSE".

I recommend to use "BEGIN ... END" blocks in nested "IF" always to
prevent this kind of mistakes.

Regards,
Guillermo "Ñuño" Martínez.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Forum merger

2009-12-16 Thread Guillermo Martínez Jiménez
Hello.

A coincidence. Today at Club Delphi (Spanish community of Delphi
developers) some body commented about Pascal Served Pages, which aims
to create a server that allows to use Pascal as script language in a
similar way than PHP. Actually the project is 'dead' (last release
date is November 2004), is far to be complete and was developed with
Delphi and Kylix. I'm tempted to study its current status and continue
it by myself if possible. Currently it is part of the Nemesis Pascal
Framework, in SourceForge's project named npascal.

Just for your information.

Regards.
Guillermo "Ñuño" Martínez.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: BNF grammar for fpc

2009-10-16 Thread Guillermo Martínez Jiménez
> From: Marco van de Voort
> (...)
> The reason is probably more because Wirthian languages traditionally use
> recursive descent parsers.

This reminds me: there are a compiler generator named COCO/R wich has
a Pascal version (Delphi actually). It generates recursive descendent
parsers. ( search results ->
www.google.com/search?hl=es&q=%22COCO%2FR%22&btnG=Buscar&lr=).

Greetings.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Illogical automatic dereferencing

2009-10-13 Thread Guillermo Martínez Jiménez
> From: J?rgen Hestermann 
>
> (...) but Borland created these Pascal
> "extensions" and now we cannot go back (as others say) because we need
> compatibility with Delphi programs and an "easier" (which I doubt)
> convertion of C header files. So noone is willing to turn back the clock
> and remove these illogical extensions. Sadly we now have no longer a
> clean language in the spirit of Pascal but a mix of Pascal and C and we
> will have to live with it forever.

That is I mean with "Pascal can evolve", some extensions as
ANSISTRING, ASM ... END, CLASS, etc. makes Pascal better. About the
Delphi compatibility, I think that the "-Mdelphi" compiler option ( or
"{$MODE DELPHI}" as you wish ) was a great idea if that compatibility
is really needed.

I don't see what new stuff is needed for "an easier convertion of C
header files". I'm the author of the Allegro library wrapper (which is
a C library) and I hadn't problems to interface with it (except that
it has a static part and a dynamic part, but it's a different story).
Pascal has data types that can deal with the C data types and the
"CDECL" keyword does help enough.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Illogical automatic dereferencing

2009-10-13 Thread Guillermo Martínez Jiménez
Hello everybody.

My message is for both "Why use pointers to arrays?" and "Illogical
automatic deferencing".

I really don't understand why Pascal "should" include C-style stuff.
PASCAL IS DIFFERENT LANGUAGE THAN C. STOP. Actually I hate that
"C-lovers" that think all languages must use C-style stuff inside any
other languages. I'm using C right now, as well as Pascal, and I
really think that C is a great language for some tasks (i.e.
low-level) but it isn't the panacea ("the solution for everything").
You'll never add C-style stuff inside SQL, do you? So, why do you want
C-style stuff in Pascal?

As I've said, C language is useful sometimes, but it's ugly and prone
to runtime errors. A lot of that runtime errors are compilation-time
errors on Pascal, so they're easer to find and to fix for me (just the
opposite that somebody said in this discussion). That's why I love to
use Pascal. It's less frustrating. A lot.

If you have "p: PINTEGER" then you're assuming you're accessing to ONE
integer. If you need to access to an array of integer then use a
pointer to an array. What's the problem with "p^[3]"? I think it is
better because you see you're accessing to a pointer to an array, and
in most cases it's important to don't forget it.

When I use C, I try to do not use pointers as arrays. I write something as:

/* Useless example function. */
  char Fn (int Ndx)
  {
char AnArray[500];
char *Pointer;

Pointer = &(AnArray[0]);
return *(Pointer + Ndx);  /* instead of "return Pointer[Ndx];" */
  }

This is more readable, because "*(Pointer + Ndx)" remembers me that
it's a pointer, not an array, so may be it wasn't assigned and may be
it needs some test before to use it (i.e. "if ( ! Pointer) return
EXIT_FAILURE;" or something).

As conclusion: I think that Pascal is good as it is. Of course it can
evolve to be better, but I think it doesn't need that C-style stuff
(i.e. Object Pascal has it's own approach to OOP keeping the original
"Pascal-style" and I like it much more than C++ and C# [can't say the
same about Objective C ;) ]).

Greetings,
Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: New Allegro.pas release

2009-07-06 Thread Guillermo Martínez Jiménez
There are an error in my last message.  The actual Allegro.pas'
 project website is at http://allegro-pas.sourceforge.net/

Sorry

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] New Allegro.pas release

2009-07-06 Thread Guillermo Martínez Jiménez
I've uploaded two now releases of Allegro.pas.

Allegro.pas is a wrapper to use Allegro with Pascal compilers (Delphi,
Free Pascal, etc). Allegro is a cross-platform library intended for
use in computer games and other types of multimedia programming.

The new release (4.4.0 Alpha2) fixes a bug, adds new functionality
(mainly a 3D software based renderer) and new documentation and
examples. Two of the improvements applies also to the stable versions
and since the newest one lost Delphi compatibility (which will be
hopefully restored in version 5, with the new API) I decided to
release a new 4.2 release too.

The Allegro.pas' project website is at
http://allegro.pas.sourceforge.net/. You can download any release file
from that site.

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: GRAPHICS HELP : PLEASE PLEASE????

2009-06-29 Thread Guillermo Martínez Jiménez
> From: Zachary Marlow 
> Subject: Re: [fpc-pascal] GRAPHICS HELP : PLEASE PLEASE
> To: FPC-Pascal users discussions 
> Message-ID: <491787.41572...@web35505.mail.mud.yahoo.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Well =
>
> =A0=A0=A0=A0=A0 Like How to draw a circle , I just need some example code p=
> lease =
>
> =A0
> PS THANKS FOR READING AND REPLYING

There are a lot of ways to draw a circle. It depends why and where you
need to draw a circle. There are a lot of differences if you need to
draw it using X11 or using a graphical library. For example, using the
Allegro.pas library:

(* Draw circle using Allegro (http://allegro-pas.sourceforge.net/) *)
PROGRAM circle;

USES
  allegro;

BEGIN
  IF NOT al_init THEN
  BEGIN
WriteLn ('Error initialising Allegro');
EXIT;
  END;
  IF al_set_gfx_mode (AL_GFX_AUTODETECT, 320, 240, 0, 0) THEN
  BEGIN
al_install_keyboard;
al_circle (al_screen, 160, 100, 50, al_makecol (255, 255, 255));
al_readkey;
al_exit;
  END
  ELSE
WriteLn ('Error setting graphics');
END.

Another way, using Lazarus add a TPaintBox to the TForm and set the
"onDraw" event of the TPaintBox to this:

PROCEDURE TForm1.PaintBox1Paint(Sender: TObject);
VAR
  Tmp: TForm1;
BEGIN
  Tmp := SELF;
  WITH (Sender AS TPaintBox).Canvas DO
  BEGIN
Ellipse (0, 0, Tmp.Width - 1, Tmp.Height - 1);
  END;
END;
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Link libglx library

2009-05-16 Thread Guillermo Martínez Jiménez
Michalis Kamburelis wrote:

>Note also your error message:
>
> ./exbasic: symbol lookup error: /usr/local/lib/libagl.so: undefined
> symbol: glXQueryExtension
>
> This says something strange, the linker for some reason is looking for
> glXQueryExtension inside libagl.so. What exactly is
> /usr/local/lib/libagl.so? (It couldn't come from Ubuntu packages.) How
> (and why) are you linking with glX?

"libagl.so" is an add-on of the Allegro library that I'm trying to
use. I did wrote a wrapper for Allegro (allegro-pas.sourceforge.net)
and it works nice but I want to add that add-on to add OpenGL support.
I'm not linking GLX directly, that is used by the library.

> If you don't fear to modify the FPC's sources, you can also try to
> change rtl/unix/dynlibs.inc to pass RTLD_GLOBAL to dlopen call, then
> recompile rtl and packages. Then the symbols from libGL (this includes
> glX symbols) should be available to libagl.so too.

That's not possible. I'm trying to do it for public release. If it's
necessary to modify FPC then the it will be hard to be used by other
developers.

Guillermo "Ñuño" Martínez.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Link libglx library.

2009-05-14 Thread Guillermo Martínez Jiménez
Jonas Maebe wrote:
> -klglx (note the extra "l").

I tried that:

fpc -02 -Sh -FUlib/ -klglx /exbasic.pp -oexbasic

But it returns that error:

/usr/bin/ld: lglx: No such file: No such file or directory

I look for a dev package for GLX (libgl1-mesa-glx-dev?) but I can't
find it. Which packages should I install on Ubuntu?

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Link libglx library.

2009-05-13 Thread Guillermo Martínez Jiménez
Hello.

I'm working on a project that needs the GLX library. It compiles but
when running it returns that error:

./exbasic: symbol lookup error: /usr/local/lib/libagl.so: undefined
symbol: glXQueryExtension

In other forum a colleague suggest that it doesn't links with the
libglx.so . I'm trying to force it using the command line but it
returns that error on compiling time:
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Link libglx library.

2009-05-13 Thread Guillermo Martínez Jiménez
Hello.

I'm working on a project that needs the GLX library. It compiles but
when running it returns that error:

./exbasic: symbol lookup error: /usr/local/lib/libagl.so: undefined
symbol: glXQueryExtension

In other forum a colleague suggest that it doesn't links with the
libglx.so . I'm trying to force it using the command line but it
returns that error on compiling time:

fpc -02 -Sh -kglx examples/agl/exbasic.pp -oexamples/agl/exbasic
...
Target OS: Linux for i386
Compiling examples/agl/exbasic.pp
Linking examples/agl/exbasic
/usr/bin/ld: glx: No such file: No such file or directory

How should I do it?

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] RE: Getmem -> Move -> Freemem

2009-04-26 Thread Guillermo Martínez Jiménez
> Both are .dat and fdata are points. IOW you are moving "fsize" bytes from
> the place where the 4 byte of the pointer dat is stored to the place where
> the 4 bytes of the pointer fdata is stored. Since you probably move more
> than 4 bytes you totally corrupt what is behind "fdata" in memory.
>
> Try  .dat^ and fdata^ in the move line.

Thanks.  That fixes it partially.

Now it fails trying to copy 998846 bytes. If I put an "IF fSize <
90 THEN..." to prevent move more than 90 bytes it does work
and I'm sure it moves up to 206737 bytes. But "size" is LONGINT so
IIRC it should be able to copy ~2Gib of data.

Does it have a size limit? If so,  is there a way to copy all that
data  without doing it byte-by-byte?

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: How to use fpcmake

2009-04-26 Thread Guillermo Martínez Jiménez
> From: Graeme Geldenhuys 
> Subject: Re: [fpc-pascal] How to use fpcmake
>
> Hi Guillermo,
>
> I struggled with it as well. Henry Vermaak then created an example for
> me and showed how to use it. The example he did was for the fpGUI
> Toolkit project.

I did read Vermaak's example and I've found some documentation at the
wiki (http://wiki.lazarus.freepascal.org/FPMake) but I can't
understand it. That's the program I wrote:


PROGRAM fpmake;
USES
  fpmkunit;
VAR
  I: TCustomInstaller;
  P: TPackage;
  T: TTarget;
  UnitsList: ARRAY [0..8] OF STRING = (
'albase', 'alblend', 'alfile', 'alfixed', 'alflic', 'algl', 'allegro',
'alvga', 'alvtable'
  );
  IncList: ARRAY [0..1] OF STRING = (
'alkeyid'. 'alsysdrv'
  );
  Cnt: INTEGER;
BEGIN
  I := Installer;
  P := I.AddPackage ('allegro.pas');
  P.Version := '4.3.0-SVN';
  P.UnitPath.Add ('lib');
  FOR Cnt := 0 TO 8 DO
  BEGIN
T := P.Targets.AddUnit (UnitsList[Cnt]+'.pas');
  END;
{ How do I do to add included files?
  FOR Cnt := 0 TO 1 DO
  BEGIN
T := P.Targets.AddUnit (IncList[Cnt]+'.inc');
  END;
}
  I.Run;
END.


It compiles but when I run "./fpmake archive" it returns a lot of
"Warning: source file * not found for *" but they actually exists(!).

The idea is to install all files from "UnitsList" and "IncList" in the
FPC's unit directory so they're accessible to any project. Optionally
there's also documentation (build from sources using "pasdoc"), some
examples, a complex demonstration (with data) and two tools.

Can somebody help me to understand it?

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Getmem -> Move -> Freemem

2009-04-26 Thread Guillermo Martínez Jiménez
Hello.

I'm using FPC 2.2.2 on Xubuntu 8.10.

I need to reserve dynamic memory to store raw binary data. I tried the
next code:

  fSize := aObject^.size;
  GetMem (fData, fSize);
  Move (aObject^.dat, fData, fSize);

Both "fData" and "dat" are untyped POINTER but the program returns an
"Segment violation" at the Move procedure. I've checked the pointers
and both are valid (I mean not NIL) and size is always more than zero.

I've read some documentation about the heap memory but I can't
understand why my code doesn't works.

Any idea?

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Getmem -> Move -> Freemem

2009-04-26 Thread Guillermo Martínez Jiménez
Hello.

I'm using
I need to reserve dynamic memory to store raw binary data. I tried the
next code:

  fSize := aObject^.size;
  GetMem (fData, fSize);
  Move (aObject^.dat, fData, fSize);

Both "fData" and "dat" are untyped POINTER but the program returns an
"Segment violation" at the Move procedure. I've checked the pointers
and both are valid (I mean not NIL) and size is always more than zero.

I've read some documentation about the heap memory but I can't
understand why my code doesn't works.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: How to use fpcmake

2009-04-16 Thread Guillermo Martínez Jiménez
> From: Graeme Geldenhuys
>
> Hi Guillermo,
>
> I struggled with it as well. Henry Vermaak then created an example for
> me and showed how to use it. The example he did was for the fpGUI
> Toolkit project.
>
>Usage:
>  - Compile fpmake.pas as follows:
> fpc fpmake.pas
>
>  - To find out more about what fpmake can do and see some help
> fpmake --help
>
>  - Build and install fpGUI
> fpmake install
>
>Note that if you installed FPC in a non-standard location on you
>system you need to tell fpmake which compiler and units to use. The
>following is all in one line:
> fpmake.exe -r c:\fpc\2.2.3\bin\i386-win32\ppc386.exe
>-UG c:\fpc\2.2.3\units\i386-win32
>  or
> ./fpmake -v build -UG /opt/fpc/lib/fpc/2.2.3/units/i386-linux/
>
>
> To view the actual fpmake.pas file, you can check-out fpGUI from
> SourceForge, or view the specific file via the following url.
>
> http://fpgui.git.sourceforge.net/git/gitweb.cgi?p=fpgui;a=blob;f=src/fpmake.pas;h=80e0be3d69132ae12b2c4c970fe29e14c500cb14;hb=67f8fcc69fec98c12d2dac11980ed97d12d380c6
>
> If you have problems with the full URL, you can also use this one:
>
>http://tinyurl.com/ce8s52
>
> I have not read the documentation of fpmake for some time, but when I
> did, it was not clear as to how to compile and use it. I'll download a
> new copy of the documentation to see if things are improved - and
> contribute some "newbie" help if nothing has changed.
>
> Regards,
>  - Graeme -

Actually I was asking for fpCmake...

Anyway, I'll test your suggestion.  Thanks.

Guillermo "Ñuño" Martínez.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Allegro.pas 4.3.0 Alpha released

2009-04-16 Thread Guillermo Martínez Jiménez
This is an old note.  I forgot to post it. Few days ago I released the
second Alpha of Allegro.pas 4.3.0

Allegro.pas is a wrapper to allow Pascal programmers to use the
Allegro game library (http://alleg.sourceforge.net/).

This new version introduces support for GNU/Linux (at cost drop drop
the Delphi compatibility, but I'll try to get it back in a future
version) and adds a lot of new functionality, as low-level functions
to help writting add-ons, extensions and OpenGL support (currently
under development).  There's also some tools under development.

The project page is at http://allegro-pas.sourceforge.net/

There's a mailing list where you can send your questions, suggestions
and proposal at
https://sourceforge.net/mailarchive/forum.php?forum_name=allegro-pas-main

SVN snapshots are published at http://allegro-pas.sourceforge.net/svn-snapshots/

To download directly from SVN read the "Downloads" section at the project page.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] How to use fpcmake

2009-04-13 Thread Guillermo Martínez Jiménez
Hi.

I did read the documentation, I look for more information on the
Internet and I've read some Makefile.fpc files on the FPC sources, but
I can't create a Makefile.fpc file for my project. I can't understand
most of the options and the project is pretty complex: it's a package
that includes a bunch of examples, two demos, several tools and
"pasdoc-style" documentation.

Isn't a "fpcmake For Dummys" somewhere? I really need it.

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] RE: fpc-2.2.2.i386-win32 on XP: Can't find unit GL used by ...

2009-04-13 Thread Guillermo Martínez Jiménez
> From:
> Dear FPC forum,
>
> I am a total novice to FPC.
>
> I am using fpc-2.2.2.i386-win32 on XP
>
> Compiling Bounce.pp
>
> I Get the message: "Can't find unit GL used by bounce"
>
> Please: Where do I go from here ?
>
> Thank you,
>

I'm not sure but may be the OpenGL are optional on Windows installer
as in Ubuntu. Run the installer again, select "Modify" and check if
OpenGL units are optional and they're installed.

Guillermo "Ñuño" Martínez.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Problems linking C library on Linux (*.so & *.a files)

2009-02-22 Thread Guillermo Martínez Jiménez
Right now I can load the library manually, using "dynlibs" unit.  I'll
work that way. Thanks.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Problems linking C library on Linux (*.so & *.a files)

2009-02-21 Thread Guillermo Martínez Jiménez
2009/2/21 Jonas Maebe
>
> On 21 Feb 2009, at 19:35, Guillermo Martínez Jiménez wrote:
>
>> I've tried your suggestion about the symbol stripping and had the same
>> result.
>
> Did you also disable smart linking? (-XX-)
>

I didn't.

Is there more things I can disable and test? *_*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: fpc-pascal Digest, Vol 56, Issue 21

2009-02-21 Thread Guillermo Martínez Jiménez
Hi.

I've tried your suggestion about the symbol stripping and had the same
result. Thanks anyway.

I'll load the library manually.

> From: Jonas Maebe
>
>>> Link time error, I guess. But according to your original message,
>>> the name
>>> of the library is liballeg_unshareable.a. So you would have to use -k
>>> liballeg_unshareable.a, not "-klalleg_unshareable.a". The linker only
>>> prepends "lib" if you use "-k-lalleg_unshareable.a" (note the extra
>>> "-").
>>> And if you use it with {$l } in the source, you also need the full
>>> exact
>>> name: {$l liballeg_unshareable.a} (because you are linking like a
>>> regular
>>> object file in that case, not as a library).
>>>
>>
>> I've used this command line:
>>
>> fpc test.pp -Fu../lib/ -k/usr/local/lib/liballeg_unsharable.a
>>
>> Not link time error but run time error. Tried also {$l
>> liballeg_unsharable.a} at sources and the same: not link time error
>> but run time error.
>
> Maybe the problem is that the default FPC config file enables symbol
> stripping. So even though the routines from the library are in your
> program, dynamically loaded libraries won't be able to find them since
> the symbol names are gone. Try compiling the program with -Xs- to
> disable symbol stripping.
>
>
> Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Problems linking C library on Linux (*.so & *.a files)

2009-02-13 Thread Guillermo Martínez Jiménez
> From: Jonas Maebe
>
> Maybe the problem is that the default FPC config file enables symbol
> stripping. So even though the routines from the library are in your
> program, dynamically loaded libraries won't be able to find them since
> the symbol names are gone. Try compiling the program with -Xs- to
> disable symbol stripping.

That's a good tip. That's logic, because I don't use that symbol directly.

Thanks. I'll try it. Unfortunately I can't do it until Wednesday.

Guillermo "Ñuño" Martínez.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Problems linking C library on Linux (*.so & *.a files)

2009-02-13 Thread Guillermo Martínez Jiménez
> Perhaps I missed it, but are you sure you declared the
> functions/procedure in the library you are using cdecl?
> That would explain a runtime error instead of linker error.

I'm sure I've used "cdecl" to declare the procedure I'm using to test it.

By the way, Allegro's developers confirm me the requested symbol isn't
in the shared librery but it's in the static one and they're now
looking for a way to have all the library in one shared file. It is
one of the objectives for their next release.

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Problems linking C library on Linux (*.so & *.a files)

2009-02-12 Thread Guillermo Martínez Jiménez
>
> Link time error, I guess. But according to your original message, the name
> of the library is liballeg_unshareable.a. So you would have to use -k
> liballeg_unshareable.a, not "-klalleg_unshareable.a". The linker only
> prepends "lib" if you use "-k-lalleg_unshareable.a" (note the extra "-").
> And if you use it with {$l } in the source, you also need the full exact
> name: {$l liballeg_unshareable.a} (because you are linking like a regular
> object file in that case, not as a library).
>

I've used this command line:

fpc test.pp -Fu../lib/ -k/usr/local/lib/liballeg_unsharable.a

Not link time error but run time error. Tried also {$l
liballeg_unsharable.a} at sources and the same: not link time error
but run time error.

Now I'm trying using dynlibs unit.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Problems linking C library on Linux (*.so & *.a files)

2009-02-12 Thread Guillermo Martínez Jiménez
Thanks for the advices, Jonas. I've tried all the combinations but
allways it returns the same runtime error.

The library developers tells me it is a known issue and it should be
fixed on the next stable release.

I think I must use the dynlibs unit, which seems to work.

Thanks anyway. I somebody finds another workarround, please tell me.

Greetings.

Guillermo Martinez.

>
> On 10 Feb 2009, at 19:30, Guillermo Martínez Jiménez wrote:
>
>> I tried to link that library using "{$linklib alleg_unsharable}". It
>> linked without error but it raises the same runtime error. Then I
>> tried deleting the "{$...}" and adding "-klalleg_unsharable" at
>> command line but then it said:
>>
>> ...
>> /usr/bin/ld: lalleg_unsharable: No such file: No such file or
>> directory
>> test.pp(17,1) Error: Error while linking
>> ...
>
> Linking with a static library works the same way as linking with an
> object file: Either -k/full/path/to/library.a, or {$l library.a} in
> combination with -Fo/full/path/to/library.
>
> In principle, {$linklib xxx} or -klxxx in combination with -Fl would
> also work if you use the -Xt parameter (so the linker looks for static
> libraries -- but then it will try to link every single library
> statically, which is probably not what you want).
>
>
> Jonas
>
> --
>
> Message: 2
> Date: Tue, 10 Feb 2009 15:36:41 -0700
> From: "Ken G. Brown" 
> Subject: [fpc-pascal]   documentation for file handling, reset, rewrite,
>errors?
> To: fpc-pascal@lists.freepascal.org
> Message-ID: 
> Content-Type: text/plain; charset="us-ascii"
>
> I cannot seem to find the good docs for the file handling routines assign, 
> rewrite and reset in the pdf's that came with fpc-2.2.2. Where might the best 
> ones be?
> I have:
> User's Manual.pdf
> Units Reference Guide.pdf
> Programmer's Manual.pdf
> Language Reference Guide.pdf
> Free Component Library.pdf
> Compiler Switches.pdf
> Code Documented.pdf
>
> I would like to find good descriptions of how they work, along with error 
> handling and examples of how to how to best use them.
>
> eg. can an internal memory based file be set to be written and read at the 
> same time? Is the file read position independent of the write position?
>
> If the internal file has been written to the end and the write operation is 
> finished but the file is still open for writing, what needs to be done in 
> order to start reading the file from the beginning?
>
> Are streams available for reading and writing and are they preferable to 
> while not eof (inFi) read(inFi) then write(outFi)?
>
> Are exceptions useful?
>
> Examples?
>
> My goal is to create an internal file then dump it to a system usb printer.
>
> I've found an example of writing to a pipe using assignlst (f,'|/usr/bin/lpr 
> -m'); that seems to sorta work,
> from here: <http://ubuntuforums.org/showthread.php?t=656110>, 2nd message.
> Is that a good way to do output to a printer?
>
> Thx again for any pointers.
> Ken G. Brown
>
>
> --
>
> Message: 3
> Date: Wed, 11 Feb 2009 09:37:09 +0100 (CET)
> From: Michael Van Canneyt 
> Subject: Re: [fpc-pascal] documentation for file handling, reset,
>rewrite,errors?
> To: FPC-Pascal users discussions 
> Message-ID: 
> Content-Type: TEXT/PLAIN; charset=US-ASCII
>
>
>
> On Tue, 10 Feb 2009, Ken G. Brown wrote:
>
>> I cannot seem to find the good docs for the file handling routines assign, 
>> rewrite and reset in the pdf's that came with fpc-2.2.2. Where might the 
>> best ones be?
>> I have:
>> User's Manual.pdf
>> Units Reference Guide.pdf
>
> Normally, the routines are documented here.
>
>> Programmer's Manual.pdf
>> Language Reference Guide.pdf
>> Free Component Library.pdf
>> Compiler Switches.pdf
>> Code Documented.pdf
>>
>> I would like to find good descriptions of how they work, along with error 
>> handling and examples of how
>> to how to best use them.
>>
>> eg. can an internal memory based file be set to be written and read at the 
>> same time?
>
> Yes.
>
>> Is the file read position independent of the write position?
>
> This kind of thing is not explained.
>
>>
>> If the internal file has been written to the end and the write operation is 
>> finished but
>> the file is still open for writing, what needs to be done in order to start 
>> reading the file from the beginning?
>
> With standard file I/O, this is not pos

[fpc-pascal] Problems linking C library on Linux (*.so & *.a files)

2009-02-10 Thread Guillermo Martínez Jiménez
Hello.

I'm trying to link a library written in C (Allegro 4.2) on Linux. The
testing program (which is minimal) links without problems but it
raises a runtime error:

#~/test: ./test
./test: symbol lookup error: /usr/local/lib/liballeg.so.4.2: undefined
symbol: _blender_trans24
#~/test:

I've emailed to the library developers and they said "You'll have to find some
way to work around it, e.g. link your bindings with liballeg_unshareable.a and
make sure when you dlopen() it can resolve those symbols.".

I tried to link that library using "{$linklib alleg_unsharable}". It
linked without error but it raises the same runtime error. Then I
tried deleting the "{$...}" and adding "-klalleg_unsharable" at
command line but then it said:

...
  /usr/bin/ld: lalleg_unsharable: No such file: No such file or directory
  test.pp(17,1) Error: Error while linking
...

The file "liballeg_unsharable.a" exists at "/usr/local/lib" so I added
"-Fl/usr/local/lib" at command line but it returns the same error.

What can I do?

I'm using FPC 2.2.2 on Xubuntu 8.04. No Lazarus nor make.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Porting linux to pascal, would it be possible ?

2008-12-05 Thread Guillermo Martínez Jiménez
> Are you sure?

Yes, I am.

> doesn't older MacOS's versions where written in Object Pascal?

Yes, it does, but as I said I think it wasn't the better options.

> I think the problem here (again) is not the language, it's the critical mass 
> of users of the language. Using C for Linux was a good bet, not because the 
> language is good (Pascal is way better for me), but because C has a wider 
> user base who can fix/add features.

I disagree.  C is better for write operating systems *by definition*:
C was created to write UNIX, Pascal was created to learn good
programming techniques.  C is low/mid-level language, Pascal is
high-level (and Object Pascal is even higher):  OS are the lowest
software level.

I'm not saying it's impossible:  here you have MacOS and Toro. I'm
just saying that _I think_ it isn't the best option.  Of course a
better option is to write the kernel in C and Assembler and the
utilities in Pascal and Object Pascal.

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Porting linux to pascal, would it be possible ?

2008-12-05 Thread Guillermo Martínez Jiménez
> Would translating/porting linux to pascal be possible ?

Possible?  Yes it is.  Worth of...?  I'm afraid not.

By the way, Linux is good as it is now and Pascal isn't the best
option to create an operating system.

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Use Free Pascal on Pandora handheld game console

2008-09-29 Thread Guillermo Martínez Jiménez
> From: Florian Klaempfl
>
> I've only one arm box so I can't work well on oabi and eabi. My box
> still runs oabi (multi boot is not possible with the Thecus). If someone
> offers me reliable access to a fast >=500 MHz, >=128 MB eabi box, some
> GB HD, I'll fix the needed stuff.
>

Unfortunately I haven't funds enough to made a donation.

Anyway I'll buy a Pandora soon (pre-order starts today) and I'll try i
t by myself even that I haven't experience with ARM (I have a few with
Z-80, 8046 and 8088/8086).
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Use Free Pascal on Pandora handheld game console

2008-09-19 Thread Guillermo Martínez Jiménez
Thanks for your messages.

By the way, I've read at Free Pascal's download site that there's two
ARM versions for the compiler, one of them is for Linux. Pandora will
use a Linux distro (www.freepascal.org/down/arm/linux.var). Does
somebody use that one?

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Use Free Pascal on Pandora handheld game console

2008-09-18 Thread Guillermo Martínez Jiménez
2008/9/16 Jonas Maebe <[EMAIL PROTECTED]>:
>
> On 16 Sep 2008, at 15:36, Guillermo Martínez Jiménez wrote:
>
>> Did somebody planned to compile, test and release FPC for the Pandora
>> handgeld game console? (www.openpandora.org)
>
> I've not heard of anyone wanting to this. Looking at the specs it will
> probably require ARMEL with eabi support though, which afaik is at best very
> shaky currently.

I see. So, I'm "wanting to this".

I don't know what's ARMEL or "eabi" support. Where can I find
documentation to compile FPC on a new ARM platform?

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Use Free Pascal on Pandora handheld game console

2008-09-16 Thread Guillermo Martínez Jiménez
Hello.

I was looking in the maillist archive but I didn't find an answer.

Did somebody planned to compile, test and release FPC for the Pandora
handgeld game console? (www.openpandora.org)

I will try to buy one when it comes to be available (pre-order on
September 30) so if nobody else will I would try, but I have not
experience with cross-compiling and I never compiled a compiler :S
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Allegro.pas version 4.2.2 released

2008-06-24 Thread Guillermo Martínez Jiménez
A new version of Allegro.pas was released yesterday. Allegro.pas is a
wrapper to allow Pascal compilers (such as Free Pascal) to use the
Allegro library in games or multimedia programs.

This version introduces new functions that allows to create, write and
read files using the LZSS compression algorithm.

Also I've created a public mailing list, but it needs some hours to be
active so be patient if you find an error page.

That's all today. Don't forget to download and test it.

http://allegro-pas.sourceforge.net/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Can I store an object reference in C as void pointer?

2008-05-20 Thread Guillermo Martínez Jiménez
Hello.

I'll create a library in Object Pascal. I'll compile it in a
DLL/so/dynlib and want to define a public interface to be used in any
language so I decided to define it as "C public functions".

I'll use objects so some functions of the library should return or
receive object references but I'm not sure which C data type should I
use.

As example, in pseudo Object Pascal:
___

LIBRARY theLib;

USES
  unitObject;

  EXPORT FUNCTION CreateObject: TTheObjectClass; CDECL;
  EXPORT PROCEDURE UseObject (Obj: TTheObjectClass; Param: INTEGER); CDECL;
  EXPORT PROCEDURE DestroyObject (Obj: TTheObjectClass); CDECL;
END.


And the pseudo C header:


/* theLib.h */
typedef TTheObjectReference void*;

extern TTheObjectReference CreateObject (void); pragma __DLL__ ("theLib");

extern void UseObject (TTheObjectReference Obj, long int Param);
pragma __DLL__ ("theLib");

extern void DestroyObject (TTheObjectReference Obj); pragma __DLL__ ("theLib");


Then, in a pseudo C program:


#include "theLib.h"

void main (void)
{
  TTheObjectReference Object;

  Object = CreateObject ();
  UseObject (Object, 1);
  DestroyObject (Object);
}
_

Is this correct or should I use a different approach?

Thanks.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: help: converting windows API to linux

2008-04-11 Thread Guillermo Martínez Jiménez
May be you can use the Wine library. It is a library created to help
porting applications from Windows to *NIX. Visit www.winehq.org

Regards.
Ñuño Martínez.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Interfacing with the free pascal compiler ?

2008-02-12 Thread Guillermo Martínez Jiménez
Esteemed Skybuck,

I've read your messages and I think you didn't understood what Free
Pascal is (or may be I didn't understood your questions).

Free Pascal is an Object Pascal compiler, like Delphi, so it's mostly
compatible with it but they're quite different since FP doesn't
include a RAD IDE nor a component library. They have also some
internal differences as compilers; i.e. Delphi creates GUI
applications by default while FPC creates console applications by
default, also FPC doesn't support the  construction, Delphi can't manage exported
variables from dynamic linking modules (DLL, so, dylib...) but FPC
does it, etc.

If you're looking for a cross-platform RAD IDE with a component
library to use with it you should try Lazarus
(http://www.lazarus.freepascal.org/), which is a RAD IDE that uses
Free Pascal and includes a library which is similar than the VCL. But
remember that Lazarus isn't Delphi. There are libraries you can use
with Delphi that are compatible with FPC/Lazarus (such as Indy,
JEDI/SDL or Allegro.pas) but there are a lot of them that aren't.

There's also a copyright problem. Most of the Delphi Library is open
sourced, but the license forces to use that sources only with
Borland/Code Gear's compilers. So it isn't "possible to pass Delphi
classes to Free pascal libraries" (well, it is possible but you
mustn't). The other way (use FPC/Lazarus libraries and classes in
Delphi) YES IT IS possible.

I hope that helps in your quest.

Guillermo "Ñuño" Martínez

> Hello,
>
> Is there a special way to interface with the free pascal compiler, for
> example via a DLL/API ?
>
> Or is an IDE supposed to interface via the FPC executable, command line
> parameters, and input files and console output with possibly output
> re-direction to files or so ?
>
> For example, I build a small IDE and now I would like to do something for
> example:
>
> 1. Get a list of files tried by the compiler so I don't have to compile
> those again.
>
> 2. Get a list of error messages, possibly per tried file, or simply one big
> file for chronological programming mistakes.
>
> Bye,
>   Skybuck.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] EControlC exception

2008-02-06 Thread Guillermo Martínez Jiménez
Hi.

Recently I discovered that Delphi can detect [Ctrl]+C keys using the
EControlC exception. I was curious so I decided to test it in Linux
using Free Pascal. The program I wrote:
_

PROGRAM ExControlC;
(* How to capture [Ctrl+C] in Object Pascal.  *)

{$mode objfpc}{$H+}

USES
  SysUtils;

VAR
  Tmp: STRING;
BEGIN
  TRY
WriteLN ('Press [Enter] or [Ctrl+C].');
ReadLN (Tmp);
WriteLN ('You pressed [Enter].');
  EXCEPT
ON EControlC DO WriteLN ('You pressed [Ctrl+C].');
  END;
  WriteLN ('Have a nice day.');
END.
_

That's simple. I tested it on Linux but it doesn't worked. It compiles
and run, but if you press [Ctrl]+C the program exits without the "You
pressed [Ctrl+C]." message. Is it an issue or a bug? May be it's not
possible to detect [Ctrl]+C in Linux?

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: ncurses extra package

2008-01-18 Thread Guillermo Martínez Jiménez
On Fri, 18 Jan 2008, Michael Van Canneyt wrote:

>CgpPbiBGcmksIDE4IEphbiAyMDA4LCBHdWlsbGVybW8gTWFydMOtbmV6IEppbcOpbmV6IHdyb3Rl
>OgoKPiBIZWxsbyBldmVyeWJvZHkuCj4gCj4gUmVjZW50bHkgSSBhc2tlZCBteXNlbGYgaWYgRnJl
> ...

Er... Pardon?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] ncurses extra package

2008-01-18 Thread Guillermo Martínez Jiménez
Hello everybody.

Recently I asked myself if Free Pascal has support for ncurses and
I've found it as an extra package.

I've take a peek at the ncurses.pp file and I've found it uses a lot
of external functions. That means this package will not compile on
platforms that haven't a previous ncurses implementation (NDS,
GP32/2X, etc.). I think if the ncurses package uses the RTL (Crt,
keyboard, gpm, etc.) it would be more portable, if the platform can't
support Crt, keyboard, mouse, etc. they can be emulated.

Then I decided to write my own ncurses.pp alternative using only the
RTL. I will not claim "official declaration" or support, and may be it
will not be so complete and successful as Michael Van Canneyt's
implementation, but any comment or advice will be welcome.

See you,

Guillermo "Ñuño" Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Librería para videojuegos Allegro .pas

2007-10-27 Thread Guillermo Martínez Jiménez
Hola gente.

Además de congratularme por la existencia de esta lista de correos, os
escribo para daros a conocer este proyecto en el que llevo metido
desde hace ya un año.

Se trata de Allegro.pas, que busca crear una envolvente para poder
utilizar la librería Allegro con compiladores Pascal. Allegro es una
librería multiplataforma para hacer juegos escrita en C con modesto
pero merecido éxito. Aunque actualmente necesita una extensión
(llamada AllegroGL) para manejar gráficos 3D, en la próxima versión
van a unir ambos proyectos (Allegro+AllegroGL).

Mi envolvente da algún problemilla con Delphi, pero funciona bien con
Free Pascal, y la documentación está incompleta y en inglés. De todas
formas, la primera versión mínimamente estable la publiqué hace más o
menos un mes y la documentación la estoy trabajando día a día.

Ya estoy recibiendo ayuda del Club Delphi (www.clubdelphi.com), pero
si a alguno le interesa el mundo de los juegos de ordenador, que le
eche un vistazo. Contestaré a todas las preguntas encantado.

Versión BETA del juego de demostración (incluye fuentes pero ya está
compilada. No es una demostración "tecnológica" sino más bien una
referencia para principiantes):
http://212.34.137.175/%7Eburdjia/proyecto/demo.Allegro.pas.071022.zip (~1.1Mb)

La página del proyecto:
http://allegro-pas.sourceforge.net/index-es.html

Saludos.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal