[fpc-pascal] Does GetLastError in WinCE work?

2009-10-29 Thread epergola
Hello I get strange results form GetLasError in WinCe; something like 1449435930, for example; I use this: {$include d:\lazarus\fpc\2.2.4\source\rtl\wince\wininc\coredll.inc} function GetLastError:DWORD; external KernelDLL name 'GetLastError'; var err: dword; begin MutexHandle := CreateM

Re: [fpc-pascal] X, Y co-ordinate system under OS/2

2009-10-29 Thread Paul Nicholls
- Original Message - From: "Graeme Geldenhuys" To: "FPC-Pascal users discussions" Sent: Thursday, October 29, 2009 7:51 PM Subject: Re: [fpc-pascal] X, Y co-ordinate system under OS/2 On 29/10/2009, Juha Manninen wrote: If done right, the code doing coordinate conversion should be

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Graeme Geldenhuys
On 29/10/2009, Marco van de Voort wrote: > > > No, probably mixed sysutils and strings(?) use. pstring is defined in both > TP and Delphi. Once to short, once to ansistring That that must be FPC that is getting confused. In Lazurus I when "Project > New > Free Pascal application". That's as bas

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Marco van de Voort
In our previous episode, Henry Vermaak said: > > > > Trying what you suggested, I get the following compiler error. > > > > project1.lpr(20,11) Error: Incompatible types: got "PString" expected > > "PChar" > > This is probably dependant on compiler modes? No, probably mixed sysutils and strings(

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Graeme Geldenhuys
2009/10/29 Mattias Gaertner : > > I hope you mean {$mode objfpc}{$H+} :-) Yes. -- Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ ___ fpc-pasc

Re: [fpc-pascal] How to set LCL widgetset for my project?

2009-10-29 Thread Henry Vermaak
2009/10/29 Mattias Gaertner : > On Thu, 29 Oct 2009 22:28:39 +0800 > 章宏九 wrote: > >> Thank you for all your detailed answers. I read information about >> lazbuild, but I think using Lazarus is much more easier. Since I am >> used to vim, it might cost me some time to get familiar with it. > > Mayb

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Mattias Gaertner
On Thu, 29 Oct 2009 16:42:23 +0200 Graeme Geldenhuys wrote: > 2009/10/29 Mattias Gaertner : > > > > It compiles here. Probably you use some special units. > > Weird... As I mentioned, I'm using FPC 2.3.1 (64bit) under Linux and > $mode objfpc. I hope you mean {$mode objfpc}{$H+} Mattias

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Graeme Geldenhuys
2009/10/29 Mattias Gaertner : > > It compiles here. Probably you use some special units. Weird... As I mentioned, I'm using FPC 2.3.1 (64bit) under Linux and $mode objfpc. > > Graeme, why don't you just change the type of 'Text' to string? That's the plan - eventually. But the code is large and

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Graeme Geldenhuys
2009/10/29 Henry Vermaak : > > This is probably dependant on compiler modes? I'm using: $mode objfpc > You may have to do it like this: > > StrDispose(Text); > Text := StrAlloc(length(s) + 1); > StrPCopy(Text, s); Ah, now it works plus no memory leaks. Thanks! :-) Wow, something as simple as

Re: [fpc-pascal] How to set LCL widgetset for my project?

2009-10-29 Thread Mattias Gaertner
On Thu, 29 Oct 2009 22:28:39 +0800 章宏九 wrote: > Thank you for all your detailed answers. I read information about > lazbuild, but I think using Lazarus is much more easier. Since I am > used to vim, it might cost me some time to get familiar with it. Maybe if you ask Martin in the right way he w

Re: [fpc-pascal] How to set LCL widgetset for my project?

2009-10-29 Thread 章宏九
Thank you for all your detailed answers. I read information about lazbuild, but I think using Lazarus is much more easier. Since I am used to vim, it might cost me some time to get familiar with it. Thanks again. 2009/10/27 Mattias Gaertner : > On Tue, 27 Oct 2009 09:55:03 +0200 > Graeme Geldenhu

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Henry Vermaak
2009/10/29 Graeme Geldenhuys : > On 29/10/2009, Mattias Gaertner wrote: >> >> >> Text:=strnew(PChar(s)); > > You read my mind. I was going to ask if it's ok to cast a PString to a PChar. > > Trying what you suggested, I get the following compiler error. > > project1.lpr(20,11) Error: Incompatible

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Mattias Gaertner
On Thu, 29 Oct 2009 15:44:09 +0200 Graeme Geldenhuys wrote: > On 29/10/2009, Mattias Gaertner wrote: > > > > > > Text:=strnew(PChar(s)); > > You read my mind. I was going to ask if it's ok to cast a PString to > a PChar. Yes. But it will not change the reference count. > Trying what you sugg

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Graeme Geldenhuys
On 29/10/2009, Mattias Gaertner wrote: > > > Text:=strnew(PChar(s)); You read my mind. I was going to ask if it's ok to cast a PString to a PChar. Trying what you suggested, I get the following compiler error. project1.lpr(20,11) Error: Incompatible types: got "PString" expected "PChar" Changi

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Mattias Gaertner
On Thu, 29 Oct 2009 13:20:42 + Henry Vermaak wrote: > 2009/10/29 Mattias Gaertner : > > On Thu, 29 Oct 2009 15:00:53 +0200 > > Graeme Geldenhuys wrote: > > > >> Hi, > >> > >> Do I create a memory leak if I cast a PChar it a AnsiString. Then > >> append text to the AnsiString and then cast it

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Henry Vermaak
2009/10/29 Mattias Gaertner : > On Thu, 29 Oct 2009 15:00:53 +0200 > Graeme Geldenhuys wrote: > >> Hi, >> >> Do I create a memory leak if I cast a PChar it a AnsiString. Then >> append text to the AnsiString and then cast it back to the original >> PChar? >> >> eg: >> var >>   Text: Pchar;    <--

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Mattias Gaertner
On Thu, 29 Oct 2009 15:00:53 +0200 Graeme Geldenhuys wrote: > Hi, > > Do I create a memory leak if I cast a PChar it a AnsiString. Then > append text to the AnsiString and then cast it back to the original > PChar? > > eg: > var > Text: Pchar;<-- global var containing text. > > procedure

Re: [fpc-pascal] Re: PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Vincent Snijders
Graeme Geldenhuys schreef: The reason why I'm not sure, is because I created a simple console test application. Initially, running the program, I got the correct output. Then I thought I would enable 'heaptrc' (-gh compiler parameter) to make sure I am not leaking memory in the application. Now w

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Henry Vermaak
2009/10/29 Graeme Geldenhuys : > Hi, > > Do I create a memory leak if I cast a PChar it a AnsiString. Then > append text to the AnsiString and then cast it back to the original > PChar? > > eg: > var >  Text: Pchar;    <-- global var containing text. > > procedure AppendText(const AText: string); >

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Martin Schreiber
On Thursday 29 October 2009 14:00:53 Graeme Geldenhuys wrote: > Hi, > > Do I create a memory leak if I cast a PChar it a AnsiString. Then > append text to the AnsiString and then cast it back to the original > PChar? > > eg: > var > Text: Pchar;<-- global var containing text. > > procedure Ap

[fpc-pascal] Re: PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Graeme Geldenhuys
On 29/10/2009, Graeme Geldenhuys wrote: > > Without heaptrc enabled > tmp $ ./project1 > t=hello > Text=hello > Text=hello world Crap, I forgot to explain the output. t: string; Text: PChar The last line is the result of Text after AppendText() was called. A

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Martin
Graeme Geldenhuys wrote: Hi, Do I create a memory leak if I cast a PChar it a AnsiString. Then append text to the AnsiString and then cast it back to the original PChar? eg: var Text: Pchar;<-- global var containing text. procedure AppendText(const AText: string); var s: string; begin

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Mattias Gaertner
On Thu, 29 Oct 2009 15:00:53 +0200 Graeme Geldenhuys wrote: > Hi, > > Do I create a memory leak if I cast a PChar it a AnsiString. Then > append text to the AnsiString and then cast it back to the original > PChar? > > eg: > var > Text: Pchar;<-- global var containing text. > > procedure

[fpc-pascal] Re: PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Graeme Geldenhuys
The reason why I'm not sure, is because I created a simple console test application. Initially, running the program, I got the correct output. Then I thought I would enable 'heaptrc' (-gh compiler parameter) to make sure I am not leaking memory in the application. Now with heaptrc enabled, I get so

Re: [fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Aleksa Todorovic
On Thu, Oct 29, 2009 at 14:00, Graeme Geldenhuys wrote: > Hi, > > Do I create a memory leak if I cast a PChar it a AnsiString. Then > append text to the AnsiString and then cast it back to the original > PChar? > > eg: > var >  Text: Pchar;    <-- global var containing text. > > procedure AppendTe

[fpc-pascal] PChar -> AnsiString -> PChar = memory leak?

2009-10-29 Thread Graeme Geldenhuys
Hi, Do I create a memory leak if I cast a PChar it a AnsiString. Then append text to the AnsiString and then cast it back to the original PChar? eg: var Text: Pchar;<-- global var containing text. procedure AppendText(const AText: string); var s: string; begin s := Text + AText; Text

Re: [fpc-pascal] X, Y co-ordinate system under OS/2

2009-10-29 Thread Graeme Geldenhuys
On 29/10/2009, Juha Manninen wrote: > > If done right, the code doing coordinate conversion should be in library > Canvas class, not in application code. That's how I would have implemented in it fpGUI as well. The higher level code uses x, y as normal. The drawing backend code does conversions

Re: [fpc-pascal] X, Y co-ordinate system under OS/2

2009-10-29 Thread Juha Manninen
Hi, > I'm making a simple GUI system for a game, and I needed to have screen > origin independant input coordinates for the GUI (simpler to think about > when using), and can be used in different world coordinate systems. If done right, the code doing coordinate conversion should be in library C

Re: [fpc-pascal] writing to syslog from FreePascal

2009-10-29 Thread Michael Van Canneyt
On Wed, 28 Oct 2009, Bruce Bauman wrote: We are porting an application which needs to write to the system log via syslog. We are running under Red Hat Enterprise Linux. Is there an existing mechanism to do this, or do we need to interface to C code ourselves? TEventLog in the eventlog uni

Re: [fpc-pascal] writing to syslog from FreePascal

2009-10-29 Thread luca_manganelli
fpc-pascal-boun...@lists.freepascal.org scritti il 29/10/2009 00.38.25 > We are porting an application which needs to write to the system log > via syslog. We are running under Red Hat Enterprise Linux. > Is there an existing mechanism to do this, or do we need to > interface to C code ourselves?