Re: [fpc-pascal] JSON - RTTI streaming.

2011-11-18 Thread Stephane Carre

Hello Michael,
I have not received any e-mail with the testcomps unit.
Can you please make sure you send it to me ?
Thanks for your time !
Regards,
Stephane Carre

On 17/11/2011 09:16, michael.vancann...@wisa.be wrote:



On Wed, 16 Nov 2011, Stephane Carre wrote:


Hello Michael,
In the current stable release (fpc 2.4.4) the unit tests for 
fpjsonrtti fail to compile because unit testcomps is missing.
I believe this is the unit with the test classes used for the 
destreamer tests.

Where can I find this unit ?


I probably forgot to commit it. I will send it to you tonight.

Michael.


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


[fpc-pascal] Makeskel generation question

2011-11-18 Thread Reinier Olislagers
Hi list,

I've run makeskel on ibconnection.pp.

This declaration:
  protected
...
function GetHandle : pointer; override;

gets output as:
















Shouldn't the TIBConnection.GetHandle.Result function result visibility
be protected as well?
I understand that the function result is... let's say "default" with
respect to the fact that if you can call the protected function you get
the result as well, but it might make it easier for people like me (and
perhaps tools) to ignore these when writing documentation for end users...

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


Re: [fpc-pascal] Makeskel generation question

2011-11-18 Thread Graeme Geldenhuys
On 2011-11-18 12:05, Reinier Olislagers wrote:
> 
> Shouldn't the TIBConnection.GetHandle.Result function result visibility
> be protected as well?

I have no idea what "default" visibility actually means. I can add that
parameters and function results don't generate any visibility headers in
the documentation output. So from a documentation point of view you can
ignore that.  But I would be curious to know from Michael (or somebody
else) what default visibility means?

On a side note:
For the FPC documentation, only Public and Published methods &
properties are documented. So you should have generated the initial xml
file specifying only Public or higher visibility in the output makeskel
generates.

Regards,
  - Graeme -

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


Re: [fpc-pascal] Makeskel generation question

2011-11-18 Thread Reinier Olislagers
On 18-11-2011 11:13, Graeme Geldenhuys wrote:
> For the FPC documentation, only Public and Published methods &
> properties are documented. So you should have generated the initial xml
> file specifying only Public or higher visibility in the output makeskel
> generates.
> 

So apparently no help for the poor developer who wants to inherit a
class and wants to figure out how to use the protected methods &
properties ;)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Makeskel generation question

2011-11-18 Thread Graeme Geldenhuys
On 2011-11-18 13:15, Reinier Olislagers wrote:
> 
> So apparently no help for the poor developer who wants to inherit a
> class and wants to figure out how to use the protected methods &
> properties ;)

The is also no help (near zero) for poor Michael, having to write all
that documentation. Just documenting the Public and Published parts, was
already a huge undertaking - and there are still more units that are
completely undocumented (as you might know). So documenting the most
used parts first, seem like a good path to take. ;-)


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

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


Re: [fpc-pascal] Makeskel generation question

2011-11-18 Thread Reinier Olislagers
On 18-11-2011 12:23, Graeme Geldenhuys wrote:
> On 2011-11-18 13:15, Reinier Olislagers wrote:
>>
>> So apparently no help for the poor developer who wants to inherit a
>> class and wants to figure out how to use the protected methods &
>> properties ;)
> 
> The is also no help (near zero) for poor Michael, having to write all
> that documentation. Just documenting the Public and Published parts, was
> already a huge undertaking - and there are still more units that are
> completely undocumented (as you might know). So documenting the most
> used parts first, seem like a good path to take. ;-)
Oh, I completely agree that's the most sensible path.

Thought I could add some titbits while doing a search for Visibility:
public, Visibility: default and Visibility: published.
At least I tried...

Let me put it another way: when I have time, the inclination and
knowledge and if it is actually fairly easy to do, I'll propose a patch
for makeskel that changes
function result Visibility: default
into
function result Visibility: private, protected, public or published,
depending on scope of the parent function
and
argument Visibility: default
into
argument Visibility: private, protected, public or published, depending
on scope of the parent procedure/function

... unless the FPC gurus object to it

Now back to the grindstone...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Makeskel generation question

2011-11-18 Thread Michael Van Canneyt



On Fri, 18 Nov 2011, Reinier Olislagers wrote:


Hi list,

I've run makeskel on ibconnection.pp.

This declaration:
 protected
...
   function GetHandle : pointer; override;

gets output as:
















Shouldn't the TIBConnection.GetHandle.Result function result visibility
be protected as well?


No, why ? A function result has no visibility.
The comment is just a hint for the documenter, after all.

If you want to make a patch to specify the parent function's visibility, go ahead, 
but I think there are more useful things that can be done...


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


Re: [fpc-pascal] JSON - RTTI streaming.

2011-11-18 Thread Michael Van Canneyt


It is attached.

It is committed, but probably not where you expected it :-)

Michael.


On Fri, 18 Nov 2011, Stephane Carre wrote:


Hello Michael,
I have not received any e-mail with the testcomps unit.
Can you please make sure you send it to me ?
Thanks for your time !
Regards,
Stephane Carre

On 17/11/2011 09:16, michael.vancann...@wisa.be wrote:



On Wed, 16 Nov 2011, Stephane Carre wrote:


Hello Michael,
In the current stable release (fpc 2.4.4) the unit tests for fpjsonrtti 
fail to compile because unit testcomps is missing.
I believe this is the unit with the test classes used for the destreamer 
tests.

Where can I find this unit ?


I probably forgot to commit it. I will send it to you tonight.

Michael.


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

interface

uses classes, sysutils;

Type
  TEmptyComponent = Class(TComponent)
  end;

  // Simple integer, fits in 1 byte
  TIntegerComponent = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp;
  end;

  // Simple integer, fits in 2 bytes
  TIntegerComponent2 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp;
  end;

  // Simple integer, fits in 3 bytes
  TIntegerComponent3 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp;
  end;

  // Simple integer, Default value. (set)
  TIntegerComponent4 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp default 6;
  end;

  // Simple integer, Default value. (not set)
  TIntegerComponent5 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp default 6;
  end;

  // Simple Int64 property fits in a single byte.
  TInt64Component = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Simple Int64 property fits 2 bytes.
  TInt64Component2 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Simple Int64 property fits 3 bytes.
  TInt64Component3 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Simple Int64 property fits 4 bytes.
  TInt64Component4 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Int64 property with default, set.
  TInt64Component5 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp default 7;
  end;

  // Int64 property with default, not set.
  TInt64Component6 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp default 7;
  end;

  // String property.
  TStringComponent = Class(TComponent)
  private
F: String;
  Public
Constructor Create(AOwner : TComponent);  override;
  Published
Property StringProp : String Read F Write F;
  end;

  // String property, empty
  TStringComponent2 = Class(TComponent)
  private
F: String;
  Published
Property StringProp : String Read F Write F;
  end;

  // WideString property
  TWideStringComponent = Class(TComponent)
  private
F: WideString;
  Public
Constructor Create(AOwner : TComponent);  override;
  Published
Property WideStringProp : WideString Read F Write F;
  end;

  // WideString property, empty
  TWideStringComponent2 = Class(TComponent)
  private
F: WideString;
  Published
Property WideStringProp : WideString Read F Write F;
  end;

  // Single property
  TSingleComponent = Class(TComponent)
  private
F: Single;
  Public
Constructor Create(AOwner : TComponent);  override;
  Published
Property SingleProp : Single Read F Write F;
  end;

  // Double property
  TDoubleComponent = Class(TComponent)
  private
F: Double;
  Public
  

Re: [fpc-pascal] Makeskel generation question

2011-11-18 Thread Reinier Olislagers
On 18-11-2011 13:14, Michael Van Canneyt wrote:
> On Fri, 18 Nov 2011, Reinier Olislagers wrote:
>> 
>> 
>> 
>> 
>>
>> Shouldn't the TIBConnection.GetHandle.Result function result visibility
>> be protected as well?
> 
> No, why ? A function result has no visibility.
> The comment is just a hint for the documenter, after all.
Yes, in this case I & my friend grep (ok, Notepad++ in this case) are
the documenter. It's easier to just go through all visibility: public
and published properties.
> 
> If you want to make a patch to specify the parent function's visibility,
> go ahead, but I think there are more useful things that can be done...

Got you, it's certainly not one of my top priorities...

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


[fpc-pascal] Convert unix timestamp to TDateTime

2011-11-18 Thread Stathis Gkotsis
Hello,

   I would like to convert a unix timestamp to TDateTime taking into
account timezone and daylight savings. For example, timestamp:
1308666350 should be converted to: 2011/06/21 16:25:50, assuming GMT+1
timezone in the winter (GMT+2 in the summer). I would like this
conversion to work both during the summer and the winter, meaning that
if I try to convert the above timezone during the winter time, it
should work as well. So, I would like for the conversion to work
similarly to: date -d @1308666350 +%Y/%m/%d\ %H:%M:%S . Is this
something possible?

Thank you,

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


Re: [fpc-pascal] JSON - RTTI streaming.

2011-11-18 Thread Stephane Carre

Thank you Michael.
I checked before in the fpc source 2.4.4 download available from 
sourceforge, but could not find testcomps anywhere.
The version you attached does not contain TVariantComponent. Is that a 
newer, or older version than the one that should match fpc 2.4.4 ? 
Otherwise I guess I can adapt the missing pieces.

Best regards,
Stephane

On 18/11/2011 13:17, Michael Van Canneyt wrote:


It is attached.

It is committed, but probably not where you expected it :-)

Michael.


On Fri, 18 Nov 2011, Stephane Carre wrote:


Hello Michael,
I have not received any e-mail with the testcomps unit.
Can you please make sure you send it to me ?
Thanks for your time !
Regards,
Stephane Carre

On 17/11/2011 09:16, michael.vancann...@wisa.be wrote:



On Wed, 16 Nov 2011, Stephane Carre wrote:


Hello Michael,
In the current stable release (fpc 2.4.4) the unit tests for 
fpjsonrtti fail to compile because unit testcomps is missing.
I believe this is the unit with the test classes used for the 
destreamer tests.

Where can I find this unit ?


I probably forgot to commit it. I will send it to you tonight.

Michael.


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



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


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

[fpc-pascal] using functions from units & main programme

2011-11-18 Thread John Lee
I have a normal fpc unit, call it jim, with 2 functions fna & fnb . fnb
uses internally fna.

My main program, has a uses clause including jim, and also a _different_
version of fna, with same parameters as for that in jim, but no fnb.

The problem I get is that when, in main program fnb doesn't use the _new_
version in the main program of fna but still uses the version that is in
the unit. I'd thought that versions of fns in the main program are used in
place of those in the unit when they both have the same name, but maybe not
when a function is used another function?

Never seen this before - is there a way I can force fnb to use the main
program's version of fna, not the version that's in the unit?

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

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Sven Barth

Am 18.11.2011 16:49, schrieb John Lee:

I have a normal fpc unit, call it jim, with 2 functions fna & fnb . fnb
uses internally fna.

My main program, has a uses clause including jim, and also a _different_
version of fna, with same parameters as for that in jim, but no fnb.

The problem I get is that when, in main program fnb doesn't use the
_new_ version in the main program of fna but still uses the version that
is in the unit. I'd thought that versions of fns in the main program are
used in place of those in the unit when they both have the same name,
but maybe not when a function is used another function?

Never seen this before - is there a way I can force fnb to use the main
program's version of fna, not the version that's in the unit?


Without example code its hard do decide what the problem is.

Pausible causes:
* there are different parameters (maybe caused by a different $mode or 
some option), thus the compiler tries to call the best fitting function 
for the given parameters
* if the function in the program is declared below its point of calling 
then the function from "jim" will be used

* a bug in the compiler

Can you please state compiler version and platform (just so that the 
information is available)?


Regards,
Sven

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


Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Sven Barth

Am 18.11.2011 16:49, schrieb John Lee:

I have a normal fpc unit, call it jim, with 2 functions fna & fnb . fnb
uses internally fna.

My main program, has a uses clause including jim, and also a _different_
version of fna, with same parameters as for that in jim, but no fnb.

The problem I get is that when, in main program fnb doesn't use the
_new_ version in the main program of fna but still uses the version that
is in the unit. I'd thought that versions of fns in the main program are
used in place of those in the unit when they both have the same name,
but maybe not when a function is used another function?

Never seen this before - is there a way I can force fnb to use the main
program's version of fna, not the version that's in the unit?


Now I that I reread your mail I might get what is going on.

You expect "fnb" which is declared in "jim" to use the function "fna" 
declared in the main program? If so, then this isn't possible. The unit 
"jim" is already compiled, thus the call from "fnb" to "jim.fna" is 
fixed. Your only possibilty would be to use function/procedure variables 
and pass the function to call as a parameter to "fnb".


Regards,
Sven

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


Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread John Lee
Sorry for confusion, my email wasn't clear...
old fpc version, that I have to use because of availability of various
units...Free Pascal Compiler version 2.2.2 [2008/08/03] for i386

this is jim.pp---
unit jim;
interface
 function fna:string;
 function fnb:string;

implementation
function fna:string;
begin
 fna:='jim';
end;
function fnb:string;
begin
 fnb:=fna;
end;
end.

this is fred.pp---
uses jim;

function fna:string;
begin
 fna:='fred';
end;

begin
 writeln(fnb);
end.

This writeln gives jim, ie the version in jim - I'd like it to be fred &
thought that it would! What can I do please, to _force_ fnb to use the fred
version of fna?

John

On 18 November 2011 16:04, Sven Barth  wrote:

> Am 18.11.2011 16:49, schrieb John Lee:
>
>> I have a normal fpc unit, call it jim, with 2 functions fna & fnb . fnb
>>
>> uses internally fna.
>>
>> My main program, has a uses clause including jim, and also a _different_
>> version of fna, with same parameters as for that in jim, but no fnb.
>>
>> The problem I get is that when, in main program fnb doesn't use the
>> _new_ version in the main program of fna but still uses the version that
>> is in the unit. I'd thought that versions of fns in the main program are
>> used in place of those in the unit when they both have the same name,
>> but maybe not when a function is used another function?
>>
>> Never seen this before - is there a way I can force fnb to use the main
>> program's version of fna, not the version that's in the unit?
>>
>
> Now I that I reread your mail I might get what is going on.
>
> You expect "fnb" which is declared in "jim" to use the function "fna"
> declared in the main program? If so, then this isn't possible. The unit
> "jim" is already compiled, thus the call from "fnb" to "jim.fna" is fixed.
> Your only possibilty would be to use function/procedure variables and pass
> the function to call as a parameter to "fnb".
>
>
> Regards,
> Sven
>
> __**_
> fpc-pascal maillist  -  
> fpc-pascal@lists.freepascal.**org
> http://lists.freepascal.org/**mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Sven Barth

Am 18.11.2011 17:47, schrieb John Lee:

Sorry for confusion, my email wasn't clear...
old fpc version, that I have to use because of availability of various
units...Free Pascal Compiler version 2.2.2 [2008/08/03] for i386

this is jim.pp---
unit jim;
interface
  function fna:string;
  function fnb:string;

implementation
function fna:string;
begin
  fna:='jim';
end;
function fnb:string;
begin
  fnb:=fna;
end;
end.

this is fred.pp---
uses jim;

function fna:string;
begin
  fna:='fred';
end;

begin
  writeln(fnb);
end.

This writeln gives jim, ie the version in jim - I'd like it to be fred &
thought that it would! What can I do please, to _force_ fnb to use the
fred version of fna?


As I said per se this is expected, because the "jnb" in "jim" only knows 
about the "jna" in "jim", but not about the "jna" in your main program.


Possible solution:

Extend your unit "jim" the following way (this is the "function 
variable" approach I mentioned):


=== unit jim begin ===

unit jim;

interface

type
  TStringFunc = function: String;

function fna: String;
function fnb(aFunc: TStringFunc = Nil): String;

implementation

function fna: String;
begin
  fna := 'jim';
end;

function fnb(aFunc: TStringFunc): String;
begin
  if Assigned(aFunc) then
fnb := aFunc
  else
fnb := fna;
end;

end.

=== unit jim end ===

And your main program will then look like this:

=== main program begin ===

uses jim;

function fna: String;
begin
  fna := 'fred';
end;

begin
  writeln(fnb(@fna)); // will print "fred"
  writeln(fnb); // will print "jim"
end.

=== main program end ===

For further information about procedure/function variables I refer you 
to the documentation: 
http://www.freepascal.org/docs-html/ref/refse17.html#x45-520003.6


Of course you are free to ask further questions if you need help on this 
or another topic. ;)


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


Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread John Lee
Thanks for the fix, but it makes the code a bit more complicated than I'd
hoped/thought based on my (over simple?) impression that local fns are used
in place of those in units. John

On 18 November 2011 16:55, Sven Barth  wrote:

> Am 18.11.2011 17:47, schrieb John Lee:
>
>  Sorry for confusion, my email wasn't clear...
>> old fpc version, that I have to use because of availability of various
>> units...Free Pascal Compiler version 2.2.2 [2008/08/03] for i386
>>
>> this is jim.pp---
>> unit jim;
>> interface
>>  function fna:string;
>>  function fnb:string;
>>
>> implementation
>> function fna:string;
>> begin
>>  fna:='jim';
>> end;
>> function fnb:string;
>> begin
>>  fnb:=fna;
>> end;
>> end.
>>
>> this is fred.pp---
>> uses jim;
>>
>> function fna:string;
>> begin
>>  fna:='fred';
>> end;
>>
>> begin
>>  writeln(fnb);
>> end.
>>
>> This writeln gives jim, ie the version in jim - I'd like it to be fred &
>> thought that it would! What can I do please, to _force_ fnb to use the
>> fred version of fna?
>>
>
> As I said per se this is expected, because the "jnb" in "jim" only knows
> about the "jna" in "jim", but not about the "jna" in your main program.
>
> Possible solution:
>
> Extend your unit "jim" the following way (this is the "function variable"
> approach I mentioned):
>
> === unit jim begin ===
>
> unit jim;
>
> interface
>
> type
>  TStringFunc = function: String;
>
> function fna: String;
> function fnb(aFunc: TStringFunc = Nil): String;
>
> implementation
>
> function fna: String;
>
> begin
>  fna := 'jim';
> end;
>
> function fnb(aFunc: TStringFunc): String;
> begin
>  if Assigned(aFunc) then
>fnb := aFunc
>  else
>fnb := fna;
> end;
>
> end.
>
> === unit jim end ===
>
> And your main program will then look like this:
>
> === main program begin ===
>
> uses jim;
>
> function fna: String;
>
> begin
>  fna := 'fred';
> end;
>
> begin
>  writeln(fnb(@fna)); // will print "fred"
>  writeln(fnb); // will print "jim"
> end.
>
> === main program end ===
>
> For further information about procedure/function variables I refer you to
> the documentation: http://www.freepascal.org/**docs-html/ref/refse17.html#
> **x45-520003.6
>
> Of course you are free to ask further questions if you need help on this
> or another topic. ;)
>
>
> Regards,
> Sven
> __**_
> fpc-pascal maillist  -  
> fpc-pascal@lists.freepascal.**org
> http://lists.freepascal.org/**mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Bart
{file: jim.pas}
unit jim;

{$ifdef fpc}
  {$mode objfpc}{h+}
{$endif}

interface

function fna: string;
function fnb: string;

implementation

function fna: string;
begin
  fna := 'jim';
end;

function fnb: string;
begin
  fnb := fna;
end;

end.


{file: prog.pas}
Program Prog;
{$ifdef fpc}
  {$mode objfpc}{h+}
{$endif}

uses jim;

function fna: string;
begin
  fna := 'Prog';
end;

begin
  writeln('fna = ',fna);
  writeln('jim.fna = ,'jim.fna);
end.

Compiled with both TurboPascal 6.0 and fpc 2.4.4. the output in both
cases is "Prog".
To get "Jim" in the main program file (prog.pas) I have to use jim.fna
explicitely:

Turbo Pascal  Version 6.0  Copyright (c) 1983,90 Borland International
fna = Prog
jim.fna = jim

Free Pascal Compiler version 2.4.4 [2011/04/23] for i386
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Win32 for i386
Compiling prog.pas
Linking prog.exe
16 lines compiled, 0.8 sec , 26912 bytes code, 1624 bytes data

F:\TP6>prog
fna = Prog
jim.fna = jim

Bart
___
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-18 Thread Bart
On 11/16/11, Tomas Hajny  wrote:

> Indeed - TP/BP 7.0 gives the same (error) result. Unit strings (which
> might be more appropriate than unit objects included by Bart) doesn't
> change the result either.

Getting really Off-Topic ;-)
PChar is defined in objects unit in TP6, there is no strings unit in
that version.

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


Re: [fpc-pascal] JSON - RTTI streaming.

2011-11-18 Thread Stephane Carre

Hello Michael,
Finally, I also found the original testcomps.pp file in the sources (and 
at the sime time I discovered a limitation of the Windows 7 file search 
tool, which was why I did not find the file before).

As indicated below, the version that comes with the sources is not complete.
I modified testcomps.pp so that the tests fully compile with the stable 
fpc 2.4.4 version.

It is attached here, I hope it helps.
Thank you for this json library !
Best regards,
Stephane

On 18/11/2011 15:30, Stephane Carre wrote:

Thank you Michael.
I checked before in the fpc source 2.4.4 download available from 
sourceforge, but could not find testcomps anywhere.
The version you attached does not contain TVariantComponent. Is that a 
newer, or older version than the one that should match fpc 2.4.4 ? 
Otherwise I guess I can adapt the missing pieces.

Best regards,
Stephane

On 18/11/2011 13:17, Michael Van Canneyt wrote:


It is attached.

It is committed, but probably not where you expected it :-)

Michael.




unit testcomps;

interface

uses classes, sysutils;

Type

  TEmptyPersistent = class(TPersistent);

  TBooleanComponent = class(TComponent)
  private
FBooleanProp: boolean;
  published
property BooleanProp: boolean read FBooleanProp write FBooleanProp;
  end;

  TVariantComponent = class(TComponent)
  private
FVariantProp: variant;
  published
property VariantProp: variant read FVariantProp write FVariantProp;
  end;

  TStringsComponent = class(TComponent)
  private
FStringsProp: TStrings;
  Public
Constructor Create(AOwner : TComponent); override;
Destructor Destroy; override;
  Published
Property StringsProp : TStrings Read FStringsProp Write FStringsProp;
  end;

  TEmptyComponent = Class(TComponent)
  end;

  // Simple integer, fits in 1 byte
  TIntegerComponent = Class(TComponent)
  private
FIntProp: Integer;
  Public
Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp;
  end;

  // Simple integer, fits in 2 bytes
  TIntegerComponent2 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp;
  end;

  // Simple integer, fits in 3 bytes
  TIntegerComponent3 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp;
  end;

  // Simple integer, Default value. (set)
  TIntegerComponent4 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp default 6;
  end;

  // Simple integer, Default value. (not set)
  TIntegerComponent5 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp default 6;
  end;

  // Simple Int64 property fits in a single byte.
  TInt64Component = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Simple Int64 property fits 2 bytes.
  TInt64Component2 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Simple Int64 property fits 3 bytes.
  TInt64Component3 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Simple Int64 property fits 4 bytes.
  TInt64Component4 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Int64 property with default, set.
  TInt64Component5 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp default 7;
  end;

  // Int64 property with default, not set.
  TInt64Component6 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp default 7;
  end;

  // String property.
  TStringComponent = Class(TComponent)
  private
F: String;
  Public
Constructor Create(AOwner : TComponent);  override;
  Published
Property StringProp : String Read F Write F;
  end;

  // String property, empty
  TStringComponent2 = Class(TComponent)
  private
F: String;
  Published
Property 

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Alberto Narduzzi

Thanks for the fix, but it makes the code a bit more complicated than
I'd hoped/thought based on my (over simple?) impression that local fns
are used in place of those in units. John


this would be true if you declared another function fnb locally, so that 
calling fnb could eventually override the one in the unit.
As said, the unit itself doesn't (and cannot, btw) know anything about 
the program (or other units, for instance) that are using it.


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


Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Sven Barth

On 18.11.2011 18:15, Bart wrote:

{file: prog.pas}
Program Prog;
{$ifdef fpc}
   {$mode objfpc}{h+}
{$endif}

uses jim;

function fna: string;
begin
   fna := 'Prog';
end;

begin
   writeln('fna = ',fna);
   writeln('jim.fna = ,'jim.fna);
end.

Compiled with both TurboPascal 6.0 and fpc 2.4.4. the output in both
cases is "Prog".
To get "Jim" in the main program file (prog.pas) I have to use jim.fna
explicitely:


But he wants to call "fnb" in the main program and have that call "fna" 
of the main program instead of "fna" from "jim".


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


Re: [fpc-pascal] JSON - RTTI streaming.

2011-11-18 Thread Sven Barth

On 18.11.2011 19:57, Stephane Carre wrote:

Finally, I also found the original testcomps.pp file in the sources (and
at the sime time I discovered a limitation of the Windows 7 file search
tool, which was why I did not find the file before).


That's a reason to use the file search of some editor (e.g. Lazarus or 
Notepad++) for something like this. ^^


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


Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Bernd
2011/11/18 John Lee :
> Never seen this before - is there a way I can force fnb to use the main
> program's version of fna, not the version that's in the unit?
> TIA John

Your problem sounds very much like you would really want to make use
of objects, inheritance and virtual methods. Instead of passing
procedure variables to modify or specialize the behavior of Jim.fnb
you would make Jim a class with virtual methods:

You could have a class TJim (declared in the unit jim) with two
methods fna and fnb and you would declare fna as a virtual method (so
it can later be overridden). In your main program you would declare a
class TFred derived from TJim and override fna. Then when you make an
instance of TFred and call Fred.fnb the code of fnb would
automatically use the fna method of TFred.

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


Re: [fpc-pascal] Convert unix timestamp to TDateTime

2011-11-18 Thread José Mejuto
Hello FPC-Pascal,

Friday, November 18, 2011, 1:54:13 PM, you wrote:

SG>I would like to convert a unix timestamp to TDateTime taking into
SG> account timezone and daylight savings. For example, timestamp:
SG> 1308666350 should be converted to: 2011/06/21 16:25:50, assuming GMT+1
SG> timezone in the winter (GMT+2 in the summer). I would like this
SG> conversion to work both during the summer and the winter, meaning that
SG> if I try to convert the above timezone during the winter time, it
SG> should work as well. So, I would like for the conversion to work
SG> similarly to: date -d @1308666350 +%Y/%m/%d\ %H:%M:%S . Is this
SG> something possible?

You need to use something like: http://wiki.lazarus.freepascal.org/PascalTZ

-- 
Best regards,
 José

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


Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Bart
On 11/18/11, Sven Barth  wrote:

> But he wants to call "fnb" in the main program and have that call "fna"
> of the main program instead of "fna" from "jim".

You're right.
I misread the original post.

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


[fpc-pascal] Re: More fun with dynamic arrays

2011-11-18 Thread leledumbo
The correct results are obtained if 
> 1) I substitute "Var" for "Out". This leads to the warning that X is not 
initialized. 

"var" could be used to treat the parameter as in-out, so the warning is
expected if you haven't initialized the variable before. As stated in the
docs (http://www.freepascal.org/docs-html/ref/refsu57.html): "The initial
value of the parameter on function entry is discarded, and should not be
used." which is why you get 0.

> 2) I substitute "Array Of Longint" for "DataA". 

That would make X parameter to be treated as "open array of longint" not
"dynamic array of longint"


--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/More-fun-with-dynamic-arrays-tp5002872p5006382.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal