Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 18.10.2011 21:59, schrieb Jonas Maebe: On 18 Oct 2011, at 21:55, Sven Barth wrote: type TGenArrayT = array of T; // this should work in trunk already function ConcatT(Arr1, Arr2: TGenArrayT): TGenArrayT; begin SetLength(Result, Length(aArray1) + Length(aArray2)); if

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 18.10.2011 23:08, schrieb Andrew Pennebaker: Barth, something's not quite right. I've compiled and installed the trunk version of fpc, but it won't recognize this syntax. paycheck.pas: unit Paycheck; interface type TArrayT = array of T; ... Trace: fpc example.pas Compiling example.pas

Re: [fpc-pascal] CGI under Freepascal

2011-10-19 Thread Graeme Geldenhuys
On 18/10/2011 16:51, Michael Van Canneyt wrote: You can always search for powtils, but as far as I know it is unmaintained. I use powtils (aka pwu), and it works very well. We have 3 CGI apps developed with powtils, connecting to a database backend etc. It is easy to use and relatively easy

Re: [fpc-pascal] Getting Hardware information in Linux

2011-10-19 Thread Graeme Geldenhuys
On 18/10/2011 21:44, Michael Van Canneyt wrote: use DBUS to query HAL. Normally you should get most of the info. I wrote an article on how to do this in FPC. if you want, I can send it to you. Would you mind sending me that article too, please. I'm using Turbo Power's OnGuard in our

[fpc-pascal] Stack corruption setting UnicodeString Char

2011-10-19 Thread Felipe Monteiro de Carvalho
Hello, Usually when we work with PChars we do things like this to set the final terminator: var ansistr: ansistring; begin // Copy the originating string taking into account the specified length SetLength(ansistr, len+1); System.Move(source^, ansistr[1], len); ansistr[len+1] := #0;

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Michael Fuchs
Am 18.10.2011 21:42, schrieb Sven Barth: For anonymous functions you can take a look at Embarcadero's Delphi help here: http://docwiki.embarcadero.com/RADStudio/en/Anonymous_Methods_in_Delphi The Embarcadero style of anonymous functions does not satify me. myFunc := function(x, y: Integer):

Re: [fpc-pascal] Getting Hardware information in Linux

2011-10-19 Thread Graeme Geldenhuys
On 19/10/2011 00:31, Den Jean wrote: read the output of lshw or read its source on how to do it yourself. problems with that is that to get most of the information you must run lshw as super-user (root). eg: Serial numbers, product codes, vendor names etc are all missing from the output if you

Re: [fpc-pascal] Stack corruption setting UnicodeString Char

2011-10-19 Thread Sven Barth
Am 19.10.2011 09:13, schrieb Felipe Monteiro de Carvalho: Hello, Usually when we work with PChars we do things like this to set the final terminator: var ansistr: ansistring; begin // Copy the originating string taking into account the specified length SetLength(ansistr, len+1);

Re: [fpc-pascal] Stack corruption setting UnicodeString Char

2011-10-19 Thread Tomas Hajny
On Wed, October 19, 2011 09:13, Felipe Monteiro de Carvalho wrote: Hi, Usually when we work with PChars we do things like this to set the final terminator: var ansistr: ansistring; begin // Copy the originating string taking into account the specified length SetLength(ansistr,

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Marco van de Voort
In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference-counted type. Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an array of string? copy () ? :-)

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Andrew Pennebaker
Sven, I added the {$mode delphi} macro and prefaced each type with the generic specification. I'm still getting errors. paycheck.pas: unit Paycheck; {$mode delphi} interface type generic TArrayT = array of T; generic TFnT = function() : T; ... Trace: fpc example.pas Compiling

Re: [fpc-pascal] Stack corruption setting UnicodeString Char

2011-10-19 Thread Felipe Monteiro de Carvalho
2011/10/19 Tomas Hajny xhaj...@hajny.biz: Sorry for a silly question, but why the difference between the two implementations (i.e. why not addressing the WideStr element directly without the typecast)? Actually it should be a pointer operation in the ansistring version too, because setting

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Sven Barth
Am 19.10.2011 09:31, schrieb Michael Fuchs: I would prefer a style like myfunc := @function(x, y: Integer): Integer Result := x + y; And how would you create more complex functions? In Pascal code blocks are started with begin and ended with end. I don't see a reason why anonymous methods

Re: [fpc-pascal] Stack corruption setting UnicodeString Char

2011-10-19 Thread Mattias Gaertner
Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com hat am 19. Oktober 2011 um 09:13 geschrieben: Hello, Usually when we work with PChars we do things like this to set the final terminator: var    ansistr: ansistring; begin    // Copy the originating string taking into

Re: [fpc-pascal] Getting Hardware information in Linux

2011-10-19 Thread Žilvinas Ledas
Hello, On 2011-10-18 22:44, Michael Van Canneyt wrote: use DBUS to query HAL. Normally you should get most of the info. I wrote an article on how to do this in FPC. if you want, I can send it to you. Could you send it to me as well? Regards, Žilvinas Ledas

Re: [fpc-pascal] Stack corruption setting UnicodeString Char

2011-10-19 Thread Felipe Monteiro de Carvalho
On Wed, Oct 19, 2011 at 10:11 AM, Mattias Gaertner nc-gaert...@netcologne.de wrote: I never saw such code for ansistring. Only for shortstring. Indeed, I copied some code from the RTL and it seams that I inadvertedly copied code for shortstring instead of ansistring =o I fixed this in rev 32977

[fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Lukasz Sokol
Hi Andrew, first of all my /first/ name is Lukasz. Would you /like/ me to use your surname to refer to yourself ? Second you seem to be sending the same message twice in one post (once as plain text the other as HTML) and quoted/printable encoding to make matters even worse. Please teach your

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Jonas Maebe
On 19 Oct 2011, at 09:59, Marco van de Voort wrote: In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference- counted type. Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 19.10.2011 09:59, schrieb Marco van de Voort: In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference-counted type. Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an array of

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 19.10.2011 10:01, schrieb Andrew Pennebaker: Sven, I added the {$mode delphi} macro and prefaced each type with the generic specification. I'm still getting errors. Either add {$mode delphi} XOR generic E.g. Solution 1: unit Foo; interface type generic TGenArrayT = array of T; ...

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Michael Fuchs
Am 19.10.2011 10:16, schrieb Sven Barth: I would prefer a style like myfunc := @function(x, y: Integer): Integer Result := x + y; And how would you create more complex functions? In Pascal code blocks are started with begin and ended with end. I don't see a reason why anonymous methods should

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Marco van de Voort
In our previous episode, Jonas Maebe said: Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an array of string? For-loops. copy () ? :-) copy() cannot be used to concatenate two arrays, because it is a function

Re: [fpc-pascal] Compiling sources obtained via SVN

2011-10-19 Thread Sven Barth
Am 18.10.2011 12:06, schrieb brian: The first problem I see is that there are actually two makefiles in the fpc directory, Makefile dated 31st Aug 2011 and Makefile.fpc dated 13th Aug 2011. This is normal. The Makefile.fpc basically contain the important parts of the makefile (which units are

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 19.10.2011 10:27, schrieb Jonas Maebe: On 19 Oct 2011, at 09:59, Marco van de Voort wrote: In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference-counted type. Right... I tend to forget about these... what would the correct way to copy

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Marco van de Voort
In our previous episode, Sven Barth said: Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an array of string? copy () ? :-) I thought about copy, too, but how would you implement a generic concat using copy (or even

Re: [fpc-pascal] Compiling sources obtained via SVN

2011-10-19 Thread Mark Morgan Lloyd
brian wrote: I assume there's an expectation that the sources downloaded from trunk should compile on all platforms? I've just updated to 19505, and attempting to build on Linux Mint 9 64-bit causes a few problems. The first problem I see is that there are actually two makefiles in the fpc

Re: [fpc-pascal] Compiling sources obtained via SVN

2011-10-19 Thread Mark Morgan Lloyd
Sven Barth wrote: This seems to be related to building the textmode IDE. If you don't need the textmode IDE you can try the following workaround: Open the Makefile in the base directory and search for IDE=1. Remove the 1 so that it reads IDE=. Save the file and try again. This should stop the

[fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread Graeme Geldenhuys
Hi, Just over 3 years ago I asked about FPC support for creating 3-tier database applications. The answer was basically: it's not possible (unless you roll your own Midas / Datasnap code). TClientDataset also missed some vital features, and the state of WebServices was also not complete. Here

Re: [fpc-pascal] Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Alexander Shishkin
19.10.2011 12:16, Sven Barth пишет: E.g. TIntegerFunc = reference to function: Integer; procedure SomeOtherProc(aFunc: TIntegerFunc); ... procedure Foo; var x: Integer; begin x := 42; SomeOtherProc(function: Integer; begin Result := x; end;); end; I haven't tested that, but from the

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread Marco van de Voort
In our previous episode, Graeme Geldenhuys said: Just over 3 years ago I asked about FPC support for creating 3-tier database applications. The answer was basically: it's not possible (unless you roll your own Midas / Datasnap code). - kbmMW http://components4developers.com/ the author was

RE: [fpc-pascal] Compiling sources obtained via SVN

2011-10-19 Thread Pierre Free Pascal
In function `GDBINT$_$TGDBINTERFACE_$__$$_GDB__INIT': gdbint.pp:(.text+0xfde): undefined reference to `deprecated_create_breakpoint_hook' /data2/sources/subversion/fpc/packages/gdbint/units/x86_64-linux/gdbint.o: In function `GDBINT$_$TGDBINTERFACE_$__$$_GDB_DONE': gdbint.pp:(.text+0x103f):

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread michael . vancanneyt
On Wed, 19 Oct 2011, Graeme Geldenhuys wrote: Hi, Just over 3 years ago I asked about FPC support for creating 3-tier database applications. The answer was basically: it's not possible (unless you roll your own Midas / Datasnap code). TClientDataset also missed some vital features, and the

Re: [fpc-pascal] Reopen issue 20500: TSQLParser cant Parse Statements containing as

2011-10-19 Thread Reinier Olislagers
On 18-10-2011 7:13, Reinier Olislagers wrote: On 17-10-2011 20:57, Michael Van Canneyt wrote: Would it make sense to reopen this bug? ? Eh ? If indeed it is accepted, then yes please. Quite strange, because I implemented the SQL parser based on the official Firebird server docs. And it

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread Graeme Geldenhuys
On 2011-10-19 11:23, Marco van de Voort wrote: - kbmMW http://components4developers.com/ the author was on the Lazarus day in 2010. Thanks, I'll take a look. I take 3-tier above as a general framework for 3-tier, not necessarily a Datasnap compatible layer. Correct, it doesn't need to

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread Graeme Geldenhuys
On 2011-10-19 11:36, michael.vancann...@wisa.be wrote: Out of the box: no. OK, thanks. Do you know if TClientDataset has improved at all? Midas is written in C++, so that's not going to happen. I didn't know that. OTOH the web-development part has resulted in a ready-to-use packet

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread Graeme Geldenhuys
On 2011-10-19 11:23, Marco van de Voort wrote: - kbmMW http://components4developers.com/ the author was on the Lazarus day in 2010. Strange, nowhere on the kbmMW website do I see any mention of Free Pascal Compiler or Lazarus IDE support.

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread michael . vancanneyt
On Wed, 19 Oct 2011, Graeme Geldenhuys wrote: On 2011-10-19 11:36, michael.vancann...@wisa.be wrote: Out of the box: no. OK, thanks. Do you know if TClientDataset has improved at all? Midas is written in C++, so that's not going to happen. I didn't know that. OTOH the

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread michael . vancanneyt
On Wed, 19 Oct 2011, Graeme Geldenhuys wrote: On 2011-10-19 11:23, Marco van de Voort wrote: - kbmMW http://components4developers.com/ the author was on the Lazarus day in 2010. Strange, nowhere on the kbmMW website do I see any mention of Free Pascal Compiler or Lazarus IDE support.

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread Graeme Geldenhuys
On 2011-10-19 13:34, michael.vancann...@wisa.be wrote: factor 6 when switching from XML to binary messaging. Not using HTTP but a self-made TCP/IP protocol gets you another factor. Are both the binary message format and self-made TCP/IP protocol publicly available? Maybe that might be worth

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread Leonardo M . Ramé
From: Graeme Geldenhuys graemeg.li...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Wednesday, October 19, 2011 8:25 AM Subject: Re: [fpc-pascal] 3-tier database applications with FPC On 2011-10-19 11:36,

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread michael . vancanneyt
On Wed, 19 Oct 2011, Leonardo M. Ramé wrote: From: Graeme Geldenhuys graemeg.li...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Wednesday, October 19, 2011 8:25 AM Subject: Re: [fpc-pascal] 3-tier database applications with

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread Leonardo M . Ramé
- Original Message - From: michael.vancann...@wisa.be michael.vancann...@wisa.be To: Leonardo M. Ramé martinr...@yahoo.com; FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Cc: Sent: Wednesday, October 19, 2011 11:03 AM Subject: Re: [fpc-pascal] 3-tier database

[fpc-pascal] sqldb how to find a record fast with primary key

2011-10-19 Thread Felipe Monteiro de Carvalho
Hello, I am using sqldb to connect to a postgres database. Using wiki instructions, my final object is a TSQLQuery for each table. So, this basically is a TDataset and to read fields I know that I can use First(), Next(), EOF() and RecNo But these are rather slow. Many fields in the tables refer

Re: [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-19 Thread Martin Schreiber
On Wednesday 19 October 2011 16.53:00 Felipe Monteiro de Carvalho wrote: Hello, I am using sqldb to connect to a postgres database. Using wiki instructions, my final object is a TSQLQuery for each table. So, this basically is a TDataset and to read fields I know that I can use First(),

Re: [fpc-pascal] 3-tier database applications with FPC

2011-10-19 Thread ABorka
On 10/19/2011 07:05, Leonardo M. Ramé wrote: - Original Message - ...snip... I created a FastCGI based server that handles JSON requests from a Win32/Linux GUI app, that uses a custom made ORM similar to tiOPF and it works really fast, even on slow-long distance networks. I

[fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread leledumbo
Hmm... I'm not really sure though, but I guess you could make use of array of const feature. See the documentation here: http://www.freepascal.org/docs-html/ref/refsu60.html -- View this message in context:

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Florian Klämpfl
Am 19.10.2011 10:16, schrieb Sven Barth: Am 19.10.2011 09:31, schrieb Michael Fuchs: I would prefer a style like myfunc := @function(x, y: Integer): Integer Result := x + y; And how would you create more complex functions? In Pascal code blocks are started with begin and ended with end. I

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Andrew Pennebaker
Right, I tried just {$mode delphi} and just generic, and when both failed I tried them at the same time. Maybe I'm not using a recent enough version? Free Pascal Compiler version 2.4.4 [2011/05/01] for i386 Cheers, Andrew Pennebaker www.yellosoft.us On Wed, Oct 19, 2011 at 4:34 AM, Sven Barth

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Florian Klämpfl
Am 19.10.2011 10:49, schrieb Sven Barth: Am 19.10.2011 10:27, schrieb Jonas Maebe: On 19 Oct 2011, at 09:59, Marco van de Voort wrote: In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference-counted type. Right... I tend to forget about

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Andrew Pennebaker
Practical uses for referencable anonymous functions: (map f collection) This is the prototypical way to run a function over each element in a collection, returning the results. Example: (map (lambda (x) (+ x 1)) '(1 2 3)) - (2 3 4) (sort compare collection) When dealing with complex data

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Florian Klämpfl
Am 19.10.2011 20:23, schrieb Andrew Pennebaker: Practical uses for referencable anonymous functions: For such applications one uses procedure variables in pascal. (map f collection) This is the prototypical way to run a function over each element in a collection, returning the results.

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Michael Fuchs
Am 19.10.2011 20:30, schrieb Florian Klämpfl: I still don't see why this cannot be done by procedure variables: one can easily pass a procedure reference to a compare function to any sort library call. It is maybe easier to write a anonymous function inline than declaring a function and

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-19 Thread Andrew Pennebaker
From what I gather, procedure variables can indeed be referenced and passed around, etc. However, procedures do not return anything, so it's hard to chain them. In functional languages, it's handy to do several nested map(map(map f ... calls. Cheers, Andrew Pennebaker www.yellosoft.us On Wed,