Re: [fpc-pascal] Re: pchar with more than 255 characters

2011-11-15 Thread Sven Barth

Am 13.11.2011 17:49, schrieb Graeme Geldenhuys:

On 13/11/2011, leledumboleledumbo_cool@  wrote:

I think the
compiler treats functions receiving array of char (or pointer to it) as
ShortString when none of the directives above exist.


Indeed, FPC defaults to ShortString if {$H+} is not specified. That is
probably the problem. I really don't know why this is still so (maybe
some performance thing inside the compiler itself). I now simply
specify $H+ in the fpc.cfg file, in case I forget to add it to the
header of a unit.


That the compiler uses ShortString for performance reasons is not 
related to the fact that ObjFPC uses them by default. In this case the 
reason is simply backwards compatibilty (note: not Delphi compatibilty 
:P ). Though its not the compiler which is the problem here as it has an 
explicit {$H-} in its define include file.


Regards,
Sven

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


Re: [fpc-pascal] Makeskel error or error behind keyboard?

2011-11-15 Thread Sven Barth

Am 14.11.2011 17:11, schrieb Reinier Olislagers:

Snippet of the code in question:
   { TCustomXMLXSDExporter }
   TCustomXMLXSDExporter = class(TCustomFileExporter)
   const
 DefaultDatasetName = 'Table1';== this is where it bombs
 // Name used for the exported table/dataset if no other name can be
found.
   private
 FANode: TDOMNode; //Just a placeholder for a node which can be reused

Am I doing something wrong or is makeskel in error?


Perhaps the parser does not yet support the declarations inside 
classes feature?


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Makeskel error or error behind keyboard?

2011-11-15 Thread michael . vancanneyt



On Tue, 15 Nov 2011, Sven Barth wrote:


Am 14.11.2011 17:11, schrieb Reinier Olislagers:

Snippet of the code in question:
   { TCustomXMLXSDExporter }
   TCustomXMLXSDExporter = class(TCustomFileExporter)
   const
 DefaultDatasetName = 'Table1';== this is where it bombs
 // Name used for the exported table/dataset if no other name can be
found.
   private
 FANode: TDOMNode; //Just a placeholder for a node which can be reused

Am I doing something wrong or is makeskel in error?


Perhaps the parser does not yet support the declarations inside classes 
feature?


It does not support this. 
I am working on it, but I need to refactor a large part of the parser.


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


Re: [fpc-pascal] CloseThread needed? still unclear

2011-11-15 Thread Sven Barth

Am 14.11.2011 02:32, schrieb nore...@z505.com:

First I thought I would post this to the mailing list to ask you what the
proper way to program with threads is. If we must call closethread on MS
Win machines but not unix machines, then something needs to change to make
the threading in the RTL more cross platform (and all the docs would need
to mention things about closethread if it is needed).


The bug was already mentioned here 
http://mantis.freepascal.org/view.php?id=13160 and fixed for 2.2.2. 
CloseThread was implemented in a cross platform way.


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Makeskel error or error behind keyboard?

2011-11-15 Thread Reinier Olislagers
On 15-11-2011 9:50, michael.vancann...@wisa.be wrote:
 On Tue, 15 Nov 2011, Sven Barth wrote:
 Am 14.11.2011 17:11, schrieb Reinier Olislagers:
 Snippet of the code in question:
TCustomXMLXSDExporter = class(TCustomFileExporter)
const
  DefaultDatasetName = 'Table1';== this is where it bombs
 Am I doing something wrong or is makeskel in error?

 Perhaps the parser does not yet support the declarations inside
 classes feature?
 
 It does not support this. I am working on it, but I need to refactor a
 large part of the parser.
 
 Michael.

Ok, thanks,
Reinier

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


Re: [fpc-pascal] parent class as a parameter type

2011-11-15 Thread Bart
On 12.11.2011 22:18, ik wrote:
 Since 2.6.0, when you write something like this:

 procedure foo(AClass : TStrings);
 foo(MyStringList); // Will return an error that TStrings is expected ...


That would be strange indeed, because then most events (onclick
handlers etc) would not compile anymore, since they are in the format
procedure(Sender: TObject) of object...

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


Re: [fpc-pascal] parent class as a parameter type

2011-11-15 Thread Felipe Monteiro de Carvalho
On Tue, Nov 15, 2011 at 10:10 AM, Bart bartjun...@gmail.com wrote:
 That would be strange indeed, because then most events (onclick
 handlers etc) would not compile anymore, since they are in the format
 procedure(Sender: TObject) of object...

It is not like that, he forgot adding var or out to the parameter. The
example which you are mentioning has no var.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] parent class as a parameter type

2011-11-15 Thread Graeme Geldenhuys
On 15/11/2011, Felipe Monteiro de Carvalho
felipemonteiro.carva...@gmail.com wrote:
 On Tue, Nov 15, 2011 at 10:10 AM, Bart bartjun...@gmail.com wrote:
 That would be strange indeed, because then most events (onclick
 handlers etc) would not compile anymore, since they are in the format
 procedure(Sender: TObject) of object...

 It is not like that, he forgot adding var or out to the parameter. The
 example which you are mentioning has no var.

Indeed. I checked my code and Delphi 5-7 compatibility. The problem I
had, wast that I specified those parameters as var.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Graeme Geldenhuys
Hi,

What exactly is the difference (if any) between the parameter modifier
when you pass a class instance to a procedure?

In the example below, I can define foo() as follows...

procedure foo(AClass: TStringList);
  or
procedure foo(var AClass: TStringList);
  or
procedure foo(const AClass: TStringList);


...and the program output is always the same. As in the first case
where I don't specify var or const, how does FPC treat the AClass
parameter?


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
program a;

{$mode objfpc}{$H+}

uses
 Classes;

procedure foo(AClass: TStringList);
begin
  AClass.Add('inside foo');
end;

var
 sl: TStringList;
begin
  sl := TStringList.Create;
  try
sl.Add('inside main');
foo(sl);
sl.Add('the end');
writeln(sl.Text);
  finally
sl.free;
  end;
end.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


Here is the program output:

$ ./a
inside main
inside foo
the end



-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: pchar with more than 255 characters

2011-11-15 Thread Graeme Geldenhuys
On 15/11/2011, Sven Barth pascaldra...@googlemail.com wrote:
 In this case the reason is simply backwards compatibilty (note: not Delphi
 compatibilty :P ).


But that's my point. I really don't think anybody is writing TP style
programs any more. So wouldn't it make sense to change the default for
the vast majority or programs written with FPC today?  Mode TP (-Mtp)
can default to shortstring and mode Delphi or mode ObjFPC can default
to longstrings?


Just like I think FPC should default to mode ObjFPC (instead of mode
fpc). Though I must admit, I have no idea what the difference are
between those modes.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Alexander Shishkin

15.11.2011 13:33, Graeme Geldenhuys пишет:

Hi,

What exactly is the difference (if any) between the parameter modifier
when you pass a class instance to a procedure?



I your example there is no difference, except that var could be ~0.01% 
slower


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


Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread michael . vancanneyt



On Tue, 15 Nov 2011, Graeme Geldenhuys wrote:


Hi,

What exactly is the difference (if any) between the parameter modifier
when you pass a class instance to a procedure?


It behaves exactly the same as if you would pass a typed pointer.

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


Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Martin Schreiber
On Tuesday 15 November 2011 10.33:13 Graeme Geldenhuys wrote:
 Hi,
 
 What exactly is the difference (if any) between the parameter modifier
 when you pass a class instance to a procedure?
 
 In the example below, I can define foo() as follows...
 
 procedure foo(AClass: TStringList);
   or

Take a copy of the AClass instance pointer.

 procedure foo(var AClass: TStringList);

Take the address of the instance variable. The instance pointer can be changed 
by the procedure, so the type of the instance variable must match TStringList 
exactly otherwise the procedure could store a wrong class into the instance 
variable. Example:

procedure foo(var AClass: TList);
begin
 aclass.free;
 aclass:= Tlist.create;
end;
[...]
var
 cl1: TStringList.
begin
 foo(cl1);   //does not compile
 //now there would be a TList in a TstringList variable

   or
 procedure foo(const AClass: TStringList);
 
Take a copy of the AClass instance pointer, AClass is readonly.

   or
 procedure foo(constref AClass: TStringList);

Take the address of the instance variable, AClass is readonly.

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

Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Graeme Geldenhuys
On 15/11/2011, Martin Schreiber mse0@g. wrote:


Thanks Martin. Extending my example by changing the body of foo() too...

  AClass.Free;
  AClass := TStringList.Create;
  AClass.Add('inside foo');

...reveals a bit more about the differences.



 procedure foo(const AClass: TStringList);

 Take a copy of the AClass instance pointer, AClass is readonly.


This one confused me a bit. I thought the whole object would be
read-only, but in fact it is just the AClass instance pointer which
cannot be modified. The properties of AClass are still read-write.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Martin Schreiber
On Tuesday 15 November 2011 11.00:34 Graeme Geldenhuys wrote:

  procedure foo(const AClass: TStringList);
  
  Take a copy of the AClass instance pointer, AClass is readonly.
 
 This one confused me a bit. I thought the whole object would be
 read-only, but in fact it is just the AClass instance pointer which
 cannot be modified. The properties of AClass are still read-write.

The wording was bad. Should be:

 procedure foo(AClass: TStringList);
   or

Take a copy of the AClass instance pointer.

 procedure foo(var AClass: TStringList);

Take the address of the instance variable. The instance pointer pointed by the 
address can be changed by the procedure, so the type of the instance variable 
must match TStringList exactly otherwise the procedure could store a wrong 
class into the instance variable. Example:

procedure foo(var AClass: TList);
begin
 aclass.free;
 aclass:= Tlist.create;
end;
[...]
var
 cl1: TStringList.
begin
 foo(cl1);   //does not compile
 //now there would be a TList in a TstringList variable

   or
 procedure foo(const AClass: TStringList);
 
Take a copy of the AClass instance pointer, AClass instance pointer is 
readonly.

   or
 procedure foo(constref AClass: TStringList);

Take the address of the instance variable, AClass instance pointer pointed by 
the address is readonly.
 
Martin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: pchar with more than 255 characters

2011-11-15 Thread Sven Barth

Am 15.11.2011 10:39, schrieb Graeme Geldenhuys:

On 15/11/2011, Sven Barthpascaldra...@googlemail.com  wrote:

In this case the reason is simply backwards compatibilty (note: not Delphi
compatibilty :P ).



But that's my point. I really don't think anybody is writing TP style
programs any more. So wouldn't it make sense to change the default for
the vast majority or programs written with FPC today?  Mode TP (-Mtp)
can default to shortstring and mode Delphi or mode ObjFPC can default
to longstrings?


The backwards compatibilty in this case is not for TP, but for FPC code 
that uses ObjFPC, but not H+.


In the end you need to discuss this with Florian, Jonas or some other 
senior dev who has the final say for this...


Note: mode Delphi already defaults to H+


Just like I think FPC should default to mode ObjFPC (instead of mode
fpc). Though I must admit, I have no idea what the difference are
between those modes.


No classes, no try/except/finally and some other things maybe

Regards,
Sven

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


Re: [fpc-pascal] pchar with more than 255 characters

2011-11-15 Thread Jonas Maebe

On 14 Nov 2011, at 22:08, Felipe Monteiro de Carvalho wrote:

 On Sun, Nov 13, 2011 at 1:39 AM, Rainer Stratmann
 rainerstratm...@t-online.de wrote:
 procedure getchars( p : pchar );
 var l : longint;
 begin
  l := length( p );
 end;
 
 You cannot do length in a PChar

length(pchar) is translated into strlen(pchar) (just like in Delphi).


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


[fpc-pascal] SQLDB Firebird port other than 3050

2011-11-15 Thread Reinier Olislagers
Hi all,

This is probably my confused week, but I couldn't find any documentation.

How do I specify the port number when connecting to Firebird/Interbase
databases with sqldb on a different port than the default (3050)?

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


Re: [fpc-pascal] SQLDB Firebird port other than 3050

2011-11-15 Thread michael . vancanneyt



On Tue, 15 Nov 2011, Reinier Olislagers wrote:


Hi all,

This is probably my confused week, but I couldn't find any documentation.

How do I specify the port number when connecting to Firebird/Interbase
databases with sqldb on a different port than the default (3050)?


Try
  /portnr:/path/to/database
in your databasename.

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


RE : [fpc-pascal] SQLDB Firebird port other than 3050

2011-11-15 Thread Ludo Brands
 
  Hi all,
 
  This is probably my confused week, but I couldn't find any 
  documentation.
 
  How do I specify the port number when connecting to 
 Firebird/Interbase 
  databases with sqldb on a different port than the default (3050)?
 
 Try
/portnr:/path/to/database
 in your databasename.
 

host/port:c:\...\data.fdb

http://www.destructor.de/firebird/multiinstance.htm

Ludo

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


[fpc-pascal] Re: RE : SQLDB Firebird port other than 3050

2011-11-15 Thread Reinier Olislagers
On 15-11-2011 16:30, Ludo Brands wrote:
 How do I specify the port number when connecting to 
 Firebird/Interbase 
 databases with sqldb on a different port than the default (3050)?

 Try
/portnr:/path/to/database
 in your databasename.
 host/port:c:\...\data.fdb
 http://www.destructor.de/firebird/multiinstance.htm
 

Thanks, you 2, that works.

In other words, RTFM (the Firebird one, that is) ;)

Time for me to get away from this keyboard ;)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal