Re: [fpc-pascal] class property accessor static

2017-02-08 Thread Luiz Americo Pereira Camara
2017-02-07 23:17 GMT-03:00 Paul Ishenin :

> 07.02.2017 18:10, Mattias Gaertner wrote:
>
>> The getter/setter of a class-property must be "static" (Delphi
>> compatible).
>> If I understand "static" correctly, then "static" simply omits passing
>> the class as parameter. So a static class procedure is just a dumber
>> version of a normal class procedure.
>>
>> What is the advantage of using "static" for class property accessors?
>> Aka: Why did Delphi choose static here?
>>
> Class properties has apperared together with class constants and class
> variables (which are static by their nature). They were introduced (as I
> understand) to give access to private/protected static elements.
>


For the record, there was a discussion about the topic years ago:
https://www.mail-archive.com/fpc-devel@lists.freepascal.org/msg30511.html


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

[fpc-pascal] TJSONData.FindPath() troubles where data contains dots.

2017-02-08 Thread Graeme Geldenhuys
Hi,

I've studied the following documenation to make sure I'm using
FindPath() correctly.


http://www.freepascal.org/docs-html/3.0.0/fcl/fpjson/tjsondata.findpath.html

Now, I have the following JSON data I omitted what is not relevant.

{
   ...snip...
"VersionDependencies": {
"2.5.0": {
"packages": "master",
"framework": "3.11.0"
}
}
}


I can do Data.FindPath("VersionDependencies") and it finds the data node
without problems.

But when I try:

var
  ver: string:
begin
  ver := '2.5.0';
  ...snip...
  Data.FindPath('VersionDependencies.'+ver)

It never finds the "2.5.0" data node. I'm assuming the dots in the
version string is what is causing the problem in fcl-json. Initially I
thought I could add extra quotes around the version string. Like so:

  Data.FindPath('VersionDependencies.'''+ver+)

But that didn't work either.

Is this a bug of some sorts, or is there another way around this problem?

I guess my only option is to use TJSONenum and iterate of the
"VersionDependencies" data, and manually look for the data node I'm
interested in. Like so:

  d := Data.FindPath('VersionDependencies');

  for ItrItem in d do
if d.Key = ver then
   ...snip...


Is there another way of finding the data I'm interested in?

Regards,
  Graeme

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

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TJSONData.FindPath() troubles where data contains dots.

2017-02-08 Thread Michael Van Canneyt



On Wed, 8 Feb 2017, Graeme Geldenhuys wrote:


Hi,

I've studied the following documenation to make sure I'm using
FindPath() correctly.


http://www.freepascal.org/docs-html/3.0.0/fcl/fpjson/tjsondata.findpath.html


since . is used as a delimiter between path segments, you indeed cannot find 
paths
that contain a . in a segment.

I see no nice way out of this.

One way is to allow to escape dots in the path. 
But because every character is allowed in a javascript object property, that

would mean that \. can also be a correct property name, and so we need to
introduce \\ as an escape for \...

It could be added.

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


Re: [fpc-pascal] TJSONData.FindPath() troubles where data contains dots.

2017-02-08 Thread Graeme Geldenhuys
On 2017-02-08 16:33, Michael Van Canneyt wrote:
> One way is to allow to escape dots in the path. 
> But because every character is allowed in a javascript object property, that
> would mean that \. can also be a correct property name, and so we need to
> introduce \\ as an escape for \...
> 
> It could be added.


No, I think that will just get messy (your choice). I was just wondering
if I was doing something wrong. Either way, I managed to use TJSONenum
and it worked just fine for my needs.


Regards,
  Graeme

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

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TJSONData.FindPath() troubles where data contains dots.

2017-02-08 Thread Michael Van Canneyt



On Wed, 8 Feb 2017, Graeme Geldenhuys wrote:


On 2017-02-08 16:33, Michael Van Canneyt wrote:

One way is to allow to escape dots in the path.
But because every character is allowed in a javascript object property, that
would mean that \. can also be a correct property name, and so we need to
introduce \\ as an escape for \...

It could be added.



No, I think that will just get messy (your choice). I was just wondering
if I was doing something wrong. Either way, I managed to use TJSONenum
and it worked just fine for my needs.


Indeed. If you experiment in the browser console:

var obj = {};
undefined
obj
Object {  }
obj["1.2.3"] = 'ok';
"ok"
obj
Object { 1.2.3: "ok" }
obj['allez"na'] = 'ok';
"ok"
obj
Object { 1.2.3: "ok", allez"na: "ok" }
obj['not\nice']="beeeh"
"beeeh"
obj
Object { 1.2.3: "ok", allez"na: "ok", not
ice: "beeeh" }
obj['not\ nice']="beeeh"
"beeeh"
obj
Object { 1.2.3: "ok", allez"na: "ok", not
ice: "beeeh", not nice: "beeeh" }

Not so nice at all...

Michael.

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


Re: [fpc-pascal] TJSONData.FindPath() troubles where data contains dots.

2017-02-08 Thread Graeme Geldenhuys
On 2017-02-08 16:47, Michael Van Canneyt wrote:
> Indeed. If you experiment in the browser console:


It might just be worth adding a small note about that "gotcha" in the
FindPath documentation.


Regards,
  Graeme

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

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC 3.0.X next to 2.6.4 on Linux

2017-02-08 Thread Krzysztof
Thank you guys! Sorry for such delay but finally had time to prepare
seriously my enviromnent for FPC V3. Everything seems to work perfect
(Lazarus IDE and FPC) but just curious question: Is it possible to get
information which FPC version my project was compiled? By binary analysis
or at runtime. I want to implement --fpcversion input param for my projects
which return what it means :)

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

Re: [fpc-pascal] FPC 3.0.X next to 2.6.4 on Linux

2017-02-08 Thread Jonas Maebe

On 08/02/17 21:54, Krzysztof wrote:

Thank you guys! Sorry for such delay but finally had time to prepare
seriously my enviromnent for FPC V3. Everything seems to work perfect
(Lazarus IDE and FPC) but just curious question: Is it possible to get
information which FPC version my project was compiled? By binary
analysis or at runtime. I want to implement --fpcversion input param for
my projects which return what it means :)


http://www.freepascal.org/docs-html/prog/progsu41.html (FPCVERSION)


Jonas

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


Re: [fpc-pascal] FPC 3.0.X next to 2.6.4 on Linux

2017-02-08 Thread Krzysztof
2017-02-08 21:59 GMT+01:00 Jonas Maebe :
>
>
> http://www.freepascal.org/docs-html/prog/progsu41.html (FPCVERSION)


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

[fpc-pascal] KeyDown routine and Ctrl+Q

2017-02-08 Thread Jürgen Hestermann

I use a KEYDOWN routine in my main TFORM to check for the key Ctrl+Q:

-
procedure TForm1.FormKeyDown(Sender : TObject;
 var Key: Word;
 Shift  : TShiftState);
begin // TForm1.FormKeyDown
case key of
   VK_Q :
  begin
  if Shift=[ssCtrl] then
 begin
 
-

But when I type "Ctrl+Q" then "Key" is 17 instead of VK_Q (81).

If I now use 17 to trigger the "Q" key, then it is also triggered
when I just type the Ctrl-key (without any other key)!

This is all a bit weird.
How can I detect that "Ctrl+Q" is pressed without
getting fooled by any other key?

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


Re: [fpc-pascal] KeyDown routine and Ctrl+Q

2017-02-08 Thread Bart
On 2/8/17, Jürgen Hestermann  wrote:

>
> But when I type "Ctrl+Q" then "Key" is 17 instead of VK_Q (81).

I get $51 for the key when I press Ctrl+Q (Win32).

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

Re: [fpc-pascal] KeyDown routine and Ctrl+Q

2017-02-08 Thread Vojtěch Čihák

Hi,
when you press CTRL+Q you will obtain two OnKeyDown events. The first with 
Key=17 (it is CTRL) and the second with Key=81 (Q). Both events will have 
ssCtrl in Shift.
 
V.
__

Od: Jürgen Hestermann 
Komu: FPC-Pascal users discussions 
Datum: 08.02.2017 22:12
Předmět: [fpc-pascal] KeyDown routine and Ctrl+Q


I use a KEYDOWN routine in my main TFORM to check for the key Ctrl+Q:

-
procedure TForm1.FormKeyDown(Sender : TObject;
                         var Key    : Word;
                             Shift  : TShiftState);
begin // TForm1.FormKeyDown
case key of
   VK_Q :
      begin
      if Shift=[ssCtrl] then
         begin
         
-

But when I type "Ctrl+Q" then "Key" is 17 instead of VK_Q (81).

If I now use 17 to trigger the "Q" key, then it is also triggered
when I just type the Ctrl-key (without any other key)!

This is all a bit weird.
How can I detect that "Ctrl+Q" is pressed without
getting fooled by any other key?

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


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

Re: [fpc-pascal] FPC 3.0.X next to 2.6.4 on Linux

2017-02-08 Thread Krzysztof
Last thing. Is possible that some FPC mixed version of .ppu or .o will be
linked into my binary? I mean some third party stuff which I forgot clean
up etc, you know how it is. Just wondering if final binary file can contain
*.ppu and *.o compiled by different FPC versions
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC 3.0.X next to 2.6.4 on Linux

2017-02-08 Thread Marco van de Voort
In our previous episode, Krzysztof said:
> Last thing. Is possible that some FPC mixed version of .ppu or .o will be
> linked into my binary? I mean some third party stuff which I forgot clean
> up etc, you know how it is. Just wondering if final binary file can contain
> *.ppu and *.o compiled by different FPC versions

No. In theory it is possible to force the .o (combine .o from one build
with .ppu from another), but that is not likely to happen in practice.

The only exceptions are trunk builds from different but not TOO different
dates.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal