Re: [Lazarus] fcl-web or BrookFramework queryfields array

2016-04-15 Thread silvioprog
On Fri, Apr 15, 2016 at 4:37 PM, Leonardo M. Ramé 
wrote:
[...]

> Sorry, nevermind. I've found a way to configure KendoUi Grid to send
> queries as POST using JSON, so, problem solved.


Awesome. :-)

tip: you can use jQuery $.param before sent the JSON filter to
FCL-web/Brook, and decode it with HTTPDecode()+FPJson in the server. :-)

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] fcl-web or BrookFramework queryfields array

2016-04-15 Thread silvioprog
On Fri, Apr 15, 2016 at 4:33 PM, silvioprog <silviop...@gmail.com> wrote:
[...]

> This filter can be easily parser ...
>

I meant: "This filter can be easily parsed ... ".

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] fcl-web or BrookFramework queryfields array

2016-04-15 Thread silvioprog
On Fri, Apr 15, 2016 at 4:25 PM, Leonardo M. Ramé 
wrote:
[...]

> It works pefectly por param=value&..., but I don't know how to parse array
> type values.
>
> example: ?filters[0]['filter']=name[0]['value']=john


This filter can be easily parser if you send it as:

?filters[0].filter=name[0].value=john

The parser can populate a class structure like:

=== code ===

  TYourObject = class
  published
property filter: string ...;
property value: string ...;
  end;

  TFilters = class(TFPGMapObject)
  end;

=== /code ===

--
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] fcl-web or BrookFramework queryfields array

2016-04-15 Thread silvioprog
On Fri, Apr 15, 2016 at 2:47 PM, Leonardo M. Ramé 
wrote:

> Hi, I need to extract the field values of a GET query of type:
>
> http://127.0.0.1/cgi-bin/test.cgi?fields[1]=f1value[2]=f2value
>
> Is there a way to handle this apart from HttpRequest.QueryFields?
>

Yes.

Supposing you have an object called "TQuery" with the published property
"Fields", you can do it easily with the "TBrookParser" object. Take a look
at this demo:

http://pastebin.com/QEh5Hnen

I've been using the "Fields" property as "TStringList", but you can use any
list type, just creating a list adapter for that.

Feel free to use the Brook community
 too! :-)

Regards,
> --
> Leonardo M. Ramé
> http://leonardorame.blogspot.com


-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [FEATURE REQUEST] Source Editor: jump to the marked line by clicking on it

2016-04-14 Thread silvioprog
On Thu, Apr 14, 2016 at 12:27 PM, Ondrej Pokorny <laza...@kluug.net> wrote:

> On 14.04.2016 17:22, silvioprog wrote:
>
>> The new Source Editor shows small marks as illustrated in the attached
>> picture. These marks are put in the exactly source line when it has
>> warning, hints, errors, notes etc. However, in the current trunk version,
>> you need to roll the scrollbar to go to the marked line.
>>
>> It would be nice if these marks could accept clicks, allowing the
>> programmer to jump to the marked line just by clicking on it.
>>
>> Is anybody interested in this feature too? If so, I can issue it at
>> bugtracker.
>>
>
> Looks like a nice enhancement. You are welcome to take initiative :)


Great! :-)

Done: #30012 <http://bugs.freepascal.org/view.php?id=>.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] [FEATURE REQUEST] Source Editor: jump to the marked line by clicking on it

2016-04-14 Thread silvioprog
Hello,

The new Source Editor shows small marks as illustrated in the attached
picture. These marks are put in the exactly source line when it has
warning, hints, errors, notes etc. However, in the current trunk version,
you need to roll the scrollbar to go to the marked line.

It would be nice if these marks could accept clicks, allowing the
programmer to jump to the marked line just by clicking on it.

Is anybody interested in this feature too? If so, I can issue it at
bugtracker.

Thank you!

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [fpc-pascal] PDF generator: please test

2016-04-09 Thread silvioprog
On Fri, Apr 8, 2016 at 3:22 PM, Michael Van Canneyt 
wrote:
[...]

> Graeme has fixed a number of errors that should hopefully solve the
> problems with
> codepages;  Changes have been tested on windows/linux/bsd but on Windows
> only
> with a system that has an english locale.


After this update, it worked fine here on my PC (Windows 7 pt-BR), I just
changed the demo to using arial.ttf instead of freessans.

The demo should have an IFDEF to using Arial instead of FreeSans on
Windows, this would avoid problems for beginners. :-)

The generated PDF after the changes:
https://dl.dropboxusercontent.com/u/135304375/test.pdf.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Wed, Apr 6, 2016 at 2:14 PM, Michael Van Canneyt 
wrote:
[...]

> Why is this patch needed ? It should not be needed at all ?
>

Sorry, I sent a wrong patch, please consider this new one in attachment.

My patch just fix wrong chars in the generated PDF, eg, before the apply
it, I got:

...
English: Hello, World!
Greek: Ge?? s?? ??s
Polish: Witaj swiecie
Portuguese: Ol? mundo
...

After apply it:

...
Languages: English: Hello, World!
Greek: Γειά σου κόσμος
Polish: Witaj świecie
Portuguese: Olá mundo
...

I needed to apply it even after update my FPC to rev. 33428.

In each case it will not be applied, since it assumes use of lazarus, and
> that is not acceptable in the FCL.


Indeed.

ps. about the hints/warnings, see the compiler log below:

Compile Project, Target: testfppdf.exe: Success, Warnings: 3, Hints: 4
fppdf.pp(1049,28) Hint: Local variable "Buffer" does not seem to be
initialized
fppdf.pp(1028,3) Note: Local variable "I" not used
fppdf.pp(3194,31) Warning: Implicit string type conversion from
"AnsiString" to "WideString"
fppdf.pp(3195,35) Warning: Implicit string type conversion from
"AnsiString" to "WideString"
fppdf.pp(808,44) Hint: Parameter "EmbeddedFontNum" not used
fppdf.pp(808,70) Hint: Parameter "FontDef" not used
fppdf.pp(3308,37) Warning: Implicit string type conversion with potential
data loss from "WideString" to "AnsiString"

-- 
Silvio Clécio


0001-fix-wrong-chars.patch
Description: Binary data
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Wed, Apr 6, 2016 at 1:57 PM, silvioprog <silviop...@gmail.com> wrote:

> On Thu, Mar 31, 2016 at 1:13 PM, Michael Van Canneyt <
> mich...@freepascal.org> wrote:
>>
>> On Thu, Mar 31, 2016 at 11:18 AM, silvioprog <silviop...@gmail.com>
>>> wrote:
>>
>> [...]
>
>> Greek: Ge?? s?? ??s
>>> Polish: Witaj swiecie
>>> Portuguese: Ol? mundo
>>> Russian:  ???
>>> Vietnamese: Xin ch?o th? gi?i
>>
>>
> This attached patch definitely fixes this error on Windows. :-)
>

Oops, I forgot the test using the attached patch result:

https://dl.dropboxusercontent.com/u/135304375/test.pdf

It was generated on Windows 7 (using Arial instead of FreeSans).

Thanks for this awesome and promising library!

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Thu, Mar 31, 2016 at 1:13 PM, Michael Van Canneyt <mich...@freepascal.org
> wrote:
>
> On Thu, Mar 31, 2016 at 11:18 AM, silvioprog <silviop...@gmail.com> wrote:
>
> [...]

> Greek: Ge?? s?? ??s
>> Polish: Witaj swiecie
>> Portuguese: Ol? mundo
>> Russian:  ???
>> Vietnamese: Xin ch?o th? gi?i
>
>
This attached patch definitely fixes this error on Windows. :-)

-- 
Silvio Clécio


0001-fix-wrong-characters.patch
Description: Binary data
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Thu, Mar 31, 2016 at 1:17 PM, Michael Van Canneyt  wrote:
[...]

> Please, don't do {%H-} etc:
>
> procedure CreateTTFCIDSystemInfo(const {%H-}EmbeddedFontNum:
> integer;{%H-}FontDef: TFontDef);virtual;
>

{$HINTS OFF} instead of it?


> Typecasts like this should also not be done:
>
> +FontDef.FDiffs := WideString(lFontDef.Diffs);
> +FontDef.FCharWidth := WideString(lFontDef.CharWidths);
>

Because the FontDef.FCharWidth is a WideString.


> -  Arr.AddIntArray(FontDef.FCharWidth);
> +  Arr.AddIntArray(string(FontDef.FCharWidth));
>

Because Arr.AddIntArray() is AnsiString (string) and FontDef.FCharWidth
WideString.


> We need to investigate why you think this typecast is needed.
>

It just stop hints/warnings from compiler.


> The buffer initialization is good, though.
>
> I will not apply this patch, this needs deeper investigation.


It just remove unused variables and apply some cast fixes.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Thu, Mar 31, 2016 at 1:26 PM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:
[...]

> On 2016-03-31 17:13, Michael Van Canneyt wrote:
>
> I had a look at your PDF. I did not extract the embedded FreeSans font
> you have embedded, so don't know the font file version, but based on its
> size (264KB) it is a very old FreeSans.ttf file. The one I tested with
> is 1.56MB in size.
>
> If I must, I can extract your embedded FreeSans font to query it further
> and see the version and glyph count it defines.


Hm... I'll try Arial instead of FreeSans.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Thu, Mar 31, 2016 at 1:13 PM, Michael Van Canneyt  wrote:
[...]

> No, I have one of ~1Mb. But probably logical if the file is not there ?
>
> It's not quite clear what to think of your report ?
>
> For me
>
> "PDF was succefully generated"
>
> does not compute with
>
> "Unable to open file "fonts\FreeSans.ttf".
>
> :-)


Oops, I meant: "PDF was succefully generated but with some issues". :-D

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread silvioprog
On Thu, Mar 31, 2016 at 12:45 PM, silvioprog <silviop...@gmail.com> wrote:

> On Thu, Mar 31, 2016 at 11:18 AM, silvioprog <silviop...@gmail.com> wrote:
>
>> On Thu, Mar 31, 2016 at 11:02 AM, Michael Van Canneyt <
>> mich...@freepascal.org> wrote:
>>>
>>> Hello
>>>
>>> In revision 33401 of FPC subversion, a lot of fixes have been committed
>>> for Font
>>> handling in the PDF generator: e.g. Unicode fonts should now render
>>> correctly.
>>
>> [...]
>>
>> Great news! :-)
>>
>> I'm going to re-test it ...
>>
>
> Finally the PDF was succefully generated on Windows! \o/
>

The attached patch remove some compile hints/warnings.

-- 
Silvio Clécio


0001-Remove-hints-warnings.patch
Description: Binary data
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread silvioprog
On Thu, Mar 31, 2016 at 11:18 AM, silvioprog <silviop...@gmail.com> wrote:

> On Thu, Mar 31, 2016 at 11:02 AM, Michael Van Canneyt <
> mich...@freepascal.org> wrote:
>>
>> Hello
>>
>> In revision 33401 of FPC subversion, a lot of fixes have been committed
>> for Font
>> handling in the PDF generator: e.g. Unicode fonts should now render
>> correctly.
>
> [...]
>
> Great news! :-)
>
> I'm going to re-test it ...
>

Finally the PDF was succefully generated on Windows! \o/

I have some observations:

. The demo print a lot of lines if the font is not found:

Exception at 0041F4B7: EFOpenError:
Unable to open file "fonts\FreeSans.ttf".
Exception at 0041F4B7: EFOpenError:
Unable to open file "fonts\FreeSans.ttf".
Exception at 0041F4B7: EFOpenError:
Unable to open file "fonts\FreeSans.ttf".
Exception at 0041F4B7: EFOpenError:
Unable to open file "fonts\FreeSans.ttf".
... infinitely ...

. The PDF was generated with some wrong chars (you can download it here:
https://dl.dropboxusercontent.com/u/135304375/test.pdf):

Greek: Ge?? s?? ??s
Polish: Witaj swiecie
Portuguese: Ol? mundo
Russian:  ???
Vietnamese: Xin ch?o th? gi?i

In the previous fppdf version, the PDF was generated about ~650KB, after
update it I get a PDF ~381KB. Is it OK?

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread silvioprog
On Thu, Mar 31, 2016 at 11:02 AM, Michael Van Canneyt <
mich...@freepascal.org> wrote:
>
> Hello
>
> In revision 33401 of FPC subversion, a lot of fixes have been committed
> for Font
> handling in the PDF generator: e.g. Unicode fonts should now render
> correctly.

[...]

Great news! :-)

I'm going to re-test it ...

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator

2016-03-05 Thread silvioprog
On Sat, Mar 5, 2016 at 3:19 PM, Michael Van Canneyt <mich...@freepascal.org>
wrote:

> On Sat, 5 Mar 2016, silvioprog wrote:
>
>> On Sat, Mar 5, 2016 at 2:27 PM, Michael Van Canneyt <
>> mich...@freepascal.org>
>> wrote:
>> [...]
>>
>>>
>>> Optionally:
>>> - PDF Forms ?
>>> - Archive format ?
>>> - Signatures ?
>>>
>>
>>
>> - File attachments? [1]
>>
>> [1] https://github.com/libharu/libharu/blob/master/demo/attach.c
>>
>
> I have added it to the list in the readme file :-)


Awesome! :-)

The PDF encryption seems optionally a nice feature too, but I don't know if
everyone agrees.

Here is a demo (password: owner ):

https://github.com/libharu/libharu/raw/master/demo/encryption.pdf

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Terminal Output window: problem with Crt unit on Linux

2016-03-05 Thread silvioprog
Hello,

Open your (useful) "Terminal Output" window (Ctrl+Alt+O), now compile and
run the example below:

=== code ===

program project1;

{$mode objfpc}{$H+}

//uses Crt;

begin
  WriteLn('Hello world');
end.

=== /code ===

OK, it will print:

Hello world

However, uncomment the line "//uses Crt", compile and run it again, that
will print:

[6n [H [mHello world

Does anybody have same problem like this?

My environment: Lazarus 1.7 r51665 FPC 3.1.1 x86_64-linux-gtk 2 (Xubuntu
14.04)

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator

2016-03-05 Thread silvioprog
On Sat, Mar 5, 2016 at 2:27 PM, Michael Van Canneyt 
wrote:
[...]
>
> Optionally:
> - PDF Forms ?
> - Archive format ?
> - Signatures ?


- File attachments? [1]

[1] https://github.com/libharu/libharu/blob/master/demo/attach.c

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator

2016-03-05 Thread silvioprog
On Sat, Mar 5, 2016 at 2:27 PM, Michael Van Canneyt 
wrote:

> Hi,
>
> I have committed a PDF generator to FPC Subversion: fcl-pdf.


Great news of this weekend.

I'm going to test that ...

Congrats for your job!

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Is there any alternative to PPL (Parallel Programming Library) on FPC?

2016-02-26 Thread silvioprog
On Thu, Feb 25, 2016 at 9:55 PM, Kostas Michalopoulos <
badsectorac...@gmail.com> wrote:

> Check the MTProcs unit in the multithreadprocs package (part of Lazarus,
> but you need to manually install it from the Install/Uninstall Packages
> box). This wiki page describes how to use it:
>
> http://wiki.freepascal.org/Parallel_procedures
>

Awesome!

I didn't know that this package existed. I'll test it tonight.

Thanks a lot for share this link! :-)

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Is there any alternative to PPL (Parallel Programming Library) on FPC?

2016-02-25 Thread silvioprog
Hello,

Just a quote from Embarcadero doc

:

The RTL provides the Parallel Programming Library (PPL), giving your
> applications the ability to have tasks running in parallel taking advantage
> of working across multiple CPU devices and computers. The PPL includes a
> number of advanced features for running tasks, joining tasks, waiting on
> groups of tasks, etc. to process. For all this, there is a thread pool that
> self tunes itself automatically (based on the load on the CPU’s) so you do
> not have to care about creating or managing threads for this purpose.


To check it, we can take a small example (full source here
)
that looks for prime numbers using a classic for loop:

var
  I, Tot: Integer;
  SW: TStopwatch;
begin
  Tot := 0;
  SW := TStopwatch.Create;
  SW.Start;
  for I := 1 to Max do
if IsPrime(I) then
  Inc(Tot);
  SW.Stop;
  WriteLn
(Format('Sequential For loop. Time (in milliseconds): %d - Primes
found: %d',
[SW.ElapsedMilliseconds, Tot]));
end;

The result:

Sequential For loop. Time (in milliseconds): 764 - Primes found: 348513

Now, a similar example however using PPL:

var
  Tot: Integer;
  SW: TStopwatch;
begin
  try
Tot := 0;
SW := TStopwatch.Create;
SW.Start;
TParallel.For(2, 1, Max,
  procedure(I: Int64)
  begin
if IsPrime(I) then
  TInterlocked.Increment(Tot);
  end);
SW.Stop;
WriteLn
  (Format('Parallel For loop. Time (in milliseconds): %d - Primes
found: %d',
  [SW.ElapsedMilliseconds, Tot]));
  except
on E: EAggregateException do
  ShowMessage(E.ToString);
  end;
end;

Result:

Parallel For loop. Time (in milliseconds): 315 - Primes found: 348513

Awesome, I got a nice performance using PPL and it seems a nice feature,
but where can I get anything like this for FPC?

Thank you!

--
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Lazarus Release 1.6

2016-02-18 Thread silvioprog
On Thu, Feb 18, 2016 at 12:16 PM, Mattias Gaertner <
nc-gaert...@netcologne.de> wrote:

> The Lazarus team is glad to announce the release of Lazarus 1.6.

[...]

Great job! \o/

(SF still "Looking for the latest version? Download
lazarus-1.4.4-fpc-2.6.4-win32.exe")

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Lazarus on my ancient computer?

2016-02-14 Thread silvioprog
On Sun, Feb 14, 2016 at 4:10 PM, silvioprog <silviop...@gmail.com> wrote:
[...]

> [2] https://img42.com/B9Y5b
> [3] https://img42.com/U3hnt
>

Oops, it seems that img42 is offline now. I meant:

[2] http://i.imgur.com/Ifd4vft.png
[3] http://i.imgur.com/SDYg6Pi.png

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Lazarus on my ancient computer?

2016-02-14 Thread silvioprog
On Sun, Feb 14, 2016 at 12:14 PM, leledumbo 
wrote:

> > So, do you have tips on which Linux flavour to install on this machine?
>
[...]

> Anything with a WM instead of DE. I suggest Manjaro as it's Arch rolling
> release philosophy managed under Debian style package repository
> versioning,
> try the Fluxbox, JWM or PekWM flavour from here:
> https://sourceforge.net/projects/manjarolinux/files/community/


+1.

Bart,

I have two basic machines, both with 1.2 GHz CPU and 2 GB RAM. In the first
one, I have installed Xubuntu, that's a very light OS, but after replace it
with Manjaro with XFCE [1], I noticed that the machine never crashes, and I
don't got more problems with broken dependencies as I had with DEBs.

In the second machine I replaced Linux Mint with Manjaro (with XFCE too),
and Manjaro is as light as Mint, however IMHO Majaro's GUIs are more
intuitive and clear than Mint.

Some days ago I tested Manjaro with KDE, and I'm suprised with its GUI
quality and stability, probable I'll replace the Windows 10 (I need it to
use Delphi Seattle here in the company) of my development machine to use
Manjaro KDE, moving Windows to a VM.

But I have a personal suggestion: try to test at least three popular Linux
distributions, I tried six (*Ubuntu[I hate Unity], Fedora[nice, but...],
openSUSE[very nice, but hard for my environment], FreeBSD[very fast for my
environment, but...], CentOS[nothing to declare] and ArchLinux[perfect with
Manjaro customizations]) in a VM with same reqisities of my two real basic
machines, so the VM showed me a similar scennario of the real environment,
and this test helped me a lot to choose the ideal distribution for my real
machines.

Good luck! :-)

ps. Take a look at this two pictures [2][3], there is Lazarus running on
Manjaro KDE. In my case it prefer to install it from a package manager
instead of using external third party scripts, and in Manjaro I just did "#
pacman -S lazarus-qt" to install FPC 3.0.0 and Lazarus Qt 1.4.4.

[1] https://manjaro.github.io/
[2] https://img42.com/B9Y5b
[3] https://img42.com/U3hnt

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] [ISSUE] Lazaus doesn't work on Windows with the latest FPC version from trunk

2016-01-30 Thread silvioprog
Hello,

Issued as #29545 .

That problem... -.-'

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Is the TTabControl.OnDrawTab working on Windows?

2016-01-30 Thread silvioprog
On Sat, Jan 30, 2016 at 10:55 AM, silvioprog <silviop...@gmail.com> wrote:

> On Sat, Jan 30, 2016 at 10:34 AM, Bart <bartjun...@gmail.com> wrote:
>
>> On 1/29/16, silvioprog <silviop...@gmail.com> wrote:
>>
>> > Now set True in the TabControl1.OwnerDraw and try the tests above again,
>> > you can't see any message btw.
>> >
>> > So, is the OnDrawTab event working on Windows?
>> >
>> > PS. I did this same test on GTK and I found same problem there too.
>>
>> I commented out the entire definition of (F)OnDrawTab and the LCL
>> still compiled fine.
>> So, it seems this eventhandler is never invoked at all.
>> (Tested on Windows)
>
>
> Hm... I'm going to issue that ...
>

Done. #29543 <http://bugs.freepascal.org/view.php?id=29543>

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Is the TTabControl.OnDrawTab working on Windows?

2016-01-30 Thread silvioprog
On Sat, Jan 30, 2016 at 10:34 AM, Bart <bartjun...@gmail.com> wrote:

> On 1/29/16, silvioprog <silviop...@gmail.com> wrote:
>
> > Now set True in the TabControl1.OwnerDraw and try the tests above again,
> > you can't see any message btw.
> >
> > So, is the OnDrawTab event working on Windows?
> >
> > PS. I did this same test on GTK and I found same problem there too.
>
> I commented out the entire definition of (F)OnDrawTab and the LCL
> still compiled fine.
> So, it seems this eventhandler is never invoked at all.
> (Tested on Windows)


Hm... I'm going to issue that ...

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Is the TTabControl.OnDrawTab working on Windows?

2016-01-29 Thread silvioprog
Hello,

Just try the following steps:

. Open Lazarus IDE with its empty Form1;
. Put a TabControl1 in the Form1 and add one or more tabs;
. Implement the OnDrawTab event with this code:

  procedure TForm1.TabControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; AActive: Boolean);
  begin
ShowMessage('OK');
  end;

. Compile and run the project.

You can't see any message.

Now set True in the TabControl1.OwnerDraw and try the tests above again,
you can't see any message btw.

So, is the OnDrawTab event working on Windows?

PS. I did this same test on GTK and I found same problem there too.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-27 Thread silvioprog
On Wed, Jan 27, 2016 at 9:30 AM, Fabrício Srdic <fabricio.sr...@gmail.com>
wrote:

> 2016-01-27 0:19 GMT-02:00 silvioprog <silviop...@gmail.com>
>
>> To summarize my opinion: if I am java programmer, would be better if I
>>> can solve my problem via Java classes than using C library binds. If i am a
>>> Pascal programmer, i prefer to solve my problem via Pascal classes instead
>>> of C binds.  Add an external dependency to the code may be a good option in
>>> short term, however may become a big problem in long term. Perhaps, if the
>>> Lazarus GUI framework was developed using pure pascal ( like fpGUI) instead
>>> of using external libraries and frameworks, we could develop mobile apps
>>> using Lazarus today.
>>>
>> Me too, but Java programmers mostly time use external C libraries when it
>> hasn't already implemented some feature yet, it is a good choice, and you
>> can use that Java classes without knowing that it make calls to an external
>> C library. The Free Pascal and Delphi do it too, for example, when you
>> access a database using SQLdb, it uses an external C library (the database
>> client), that is made in C, and many Pascal programmers uses SQLdb with
>> pure Pascal interfaces (headers) without knowing that the main
>> implementation is in the external C library.
>>
> I undertand this. I know it is virtually impossible to drop all the
> dependency on external C libs on all platforms and programming languages.
> It is not feasible and such goal is all about waste of time and reinventing
> the wheel. I wouldn't do this even in my projects.
>
> Let me explain in another way: nowadays, Lazarus doesn't provide a GUI
> framework for Android. Perharps, there is a C framework that can solve the
> problem now. However, although implementing C binds requires relative
> little time and efforts, join efforts in projects like LCL Custom Draw
> and FpGUI may result in many benefits on long-term so, that may be the
> best choice.
>

I understood. :-)

I love coding with pure Pascal code too, however as Greame said, there is a
lot of users that already made something in C and exported it as a library,
and Pascal programmers can *enjoy it responsibly*. :-)

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [OT] Why Mantis doesn't notify the changes?

2016-01-27 Thread silvioprog
On Wed, Jan 27, 2016 at 2:47 PM, Dmitry Boyarintsev <
skalogryz.li...@gmail.com> wrote:

> On Wed, Jan 27, 2016 at 12:43 PM, silvioprog <silviop...@gmail.com> wrote:
>
>> I can't receive any Mantis notification, even using this configuration:
>>
>
> Maybe Mantis is not configured to notify the Reporter?
> You might want to add yourself to Monitor list.
>

Strange, I receive all notifications in other places where I open issues,
even without monitore it. :/

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [OT] Why Mantis doesn't notify the changes?

2016-01-27 Thread silvioprog
On Wed, Jan 27, 2016 at 2:50 PM, Juha Manninen <juha.mannine...@gmail.com>
wrote:

> On Wed, Jan 27, 2016 at 7:43 PM, silvioprog <silviop...@gmail.com> wrote:
> > For example, I can't receive any notification related to this issue:
> > http://bugs.freepascal.org/view.php?id=29483
> > And I think that Juha can't receive any notification too. :-/
>
> In fact I did not receive notifications about that issue. I receive
> them about many other issues though. I don't know what is the logic
> here.
>
> Anyway, I have noticed your patches. I am about to apply them. Don't
> worry. :)


Awesome.

I send more patches, thanks a lot for fix them! :-)

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [OT] Why Mantis doesn't notify the changes?

2016-01-27 Thread silvioprog
On Wed, Jan 27, 2016 at 4:57 PM, Bart  wrote:

> On 1/27/16, Juha Manninen  wrote:
>
> > In fact I did not receive notifications about that issue. I receive
> > them about many other issues though. I don't know what is the logic
> > here.
>
> I get notifications of issues that are assigned to me.


Hm... I'm just a `Report` user buddy. u.u

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] [OT] Why Mantis doesn't notify the changes?

2016-01-27 Thread silvioprog
Hello,

I can't receive any Mantis notification, even using this configuration:

https://img42.com/l8Nog

For example, I can't receive any notification related to this issue:

http://bugs.freepascal.org/view.php?id=29483

And I think that Juha can't receive any notification too. :-/

So, is Mantis e-mail notification working fine?

--
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-26 Thread silvioprog
On Tue, Jan 26, 2016 at 9:17 AM, Fabrício Srdic <fabricio.sr...@gmail.com>
wrote:

> 2016-01-25 23:09 GMT-02:00 silvioprog <silviop...@gmail.com>:
>
>> But, unfortunatelly, even with this pros, Pascal programmers avoid to use
>> external libraries, that's a real fact. :-/
>>
>>
> This issue is not restricted to Pascal programmers, this problem is
> inherent in any development platform.
>

Well, I disagree. I'm working with other languagens (C - libs, Java -
3rdparty things, and NodeJS - compiled modules), I joined on their
communities, and I find many programmers adopting C libraries there.

The root problem of using an external library is: when you add an external
> dependency on your code, your code becomes constrained by the limitations
> of that external dependency. For example, let's suppose you are writing a
> code that handles an exotic file format. Your code are supposed to run on
> windows. Then you find an external library which solves your problem. Three
> months after, your project's requirements changes. The new requirement is
> that your code shall run on Linux. However, that external library runs only
> on windows. So, your code are constrained by this limitation. Now, you need
> to find an alternative solution. Sometimes, none of them are feasible and
> this fact can lead your project to fail.
>

As I said: "... But the one of the basic steps before chosing a library
(from any language) is read its specification, and know if it provides the
needed features, works in the expected SOs, and provides a good
documentation with a stable support. I need to make a device and it need a
microcontroller, so I found that the best choice is a PIC16F64A because its
datasheet shows all the features and the basic hardware that I need".

...

"... Well, the mostly C libraries work fine in many OSs. One that I use
works in the popular systems (currently I need it just for Windows and
Linux) like GNU/Linux, FreeBSD, OpenBSD, NetBSD, Android, OS X, Win32/64
and special systems like Symbian and z/OS, and it's already available in
some tools like apt, yum, npm, maven, pacman...".


> By other side, if you find a solution in pascal, your code are constrained
> only by the limitations of the compiler.
>

IMHO this isn't a reason, I also can find Pascal code that works only on a
specific SO, and hard to be implemented in other systems, so I prefer to
get some C library that already do it instead of spending a long time
trying to implement it just because "oh, I can't work with libraries". :-)

The main a real reason that I find is: mostly Pascal programmers can't
debug a C libraries. And many Pascal programmers can't use or don't know
how to use shared/static libraries by themselves and can't find time to
know it, but anyway they use external libraries implicitly, when they
declare Pascal units that uses them.

Imagine if Lazarus developers think this same way, they probably would not
have created Lazarus for GTK and Qt. :-)

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-26 Thread silvioprog
On Tue, Jan 26, 2016 at 1:01 PM, Fabrício Srdic <fabricio.sr...@gmail.com>
wrote:

> Em 26/01/2016 11:30, "silvioprog" <silviop...@gmail.com> escreveu:
> >
> > As I said: "... But the one of the basic steps before chosing a library
> (from any language) is read its specification, and know if it provides the
> needed features, works in the expected SOs, and provides a good
> documentation with a stable support. I need to make a device and it need a
> microcontroller, so I found that the best choice is a PIC16F64A because its
> datasheet shows all the features and the basic hardware that I need".
> >
> > ...
> >
> > "... Well, the mostly C libraries work fine in many OSs. One that I use
> works in the popular systems (currently I need it just for Windows and
> Linux) like GNU/Linux, FreeBSD, OpenBSD, NetBSD, Android, OS X, Win32/64
> and special systems like Symbian and z/OS, and it's already available in
> some tools like apt, yum, npm, maven, pacman...".
> >
>
> You are right. However, often we can't prevent when the requirements of
> our project will change and what will change. As i have said, you can find
> a library that address your problem today, but after some time, your
> project's requirements changes and that external dependency becomes a
> problem. The problem of cross-platform availability was just an example. A
> particular library may have many other kinds of limitations. Very often,
> you can't just figure out  which of that limitations may become a problem
> in the future.
>
There is no a language/compiler/library that can prevent all
possible future problems or customers needs. :-)

> > IMHO this isn't a reason, I also can find Pascal code that works only on
> a specific SO, and hard to be implemented in other systems, so I prefer to
> get some C library that already do it instead of spending a long time
> trying to implement it just because "oh, I can't work with libraries". :-)
>
> I am not against the use of libraries. What i am trying to say is, when
> you add an external dependency to your code, your code becomes constrained
> by the limitations of that external dependency so, would be better if you
> can solve the problem without add a new level constraints to your code.
>
Any choice must be done carefully for everything, language, compiler,
library, Pascal component etc.

Sometimes is better to reuse codes that already exit, instead of spending a
long time trying to solve the problem alone. For example, I still can't
find a pure Pascal package to build a HTTP 2.0 server, but I can create a
Pascal header to reuse some C library that already does it properly.

> > The main a real reason that I find is: mostly Pascal programmers can't
> debug a C libraries. And many Pascal programmers can't use or don't know
> how to use shared/static libraries by themselves and can't find time to
> know it, but anyway they use external libraries implicitly, when they
> declare Pascal units that uses them.
> >
> > Imagine if Lazarus developers think this same way, they probably would
> not have created Lazarus for GTK and Qt
>
> Why i can't make an Android app using Lazarus, as the free pascal compiler
> provides support to it? Is it because there is no GTK to android? And if
> the lazarus GUI framework did not depends on external libraries?
>
> The lazarus team did the right thing. They did not stopped to develop the
> Lazarus for Unix because "they couldn't use libraries". However, how would
> be the actual scenario if the GUI framework of the Lazarus was developed
> using just Pascal? Perhaps, I would not currently facing the problem of not
> being able to develop an android app using Lazarus provided frameworks.
>
I couldn't understand what you meant.

--
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-26 Thread silvioprog
On Tue, Jan 26, 2016 at 9:54 PM, Marc Santhoff <m.santh...@web.de> wrote:

> On Mo, 2016-01-25 at 22:09 -0300, silvioprog wrote:
>
> > But, unfortunatelly, even with this pros, Pascal programmers avoid to use
> > external libraries, that's a real fact. :-/
>
> Speaking of the core team, you may be right. And speaking about people
> writing cross plattform programm it presumably is a wise decision to
> translate things to pascal. Once done it reduces efforts of updating
> external libs to newer versions, oddities when compiling for multiple
> platforms, etc.
>

I agree. And using lib I can use the modularization concept with Free
Pascal.


> But besides that I'm not hesitating to use external libraries to get
> things done. I had some USB access code from a third party and no time
> to translate before the release, so it was a bliss to compile some cut
> out C functions into objects and link them to the pascal program. Works,
> still in use.


Awesome!

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-26 Thread silvioprog
On Tue, Jan 26, 2016 at 10:51 PM, Fabrício Srdic <fabricio.sr...@gmail.com>
wrote:

> Em 26/01/2016 23:23, "silvioprog" <silviop...@gmail.com> escreveu:
> >
> > On Tue, Jan 26, 2016 at 1:01 PM, Fabrício Srdic <
> fabricio.sr...@gmail.com> wrote:
> >>
> >> Em 26/01/2016 11:30, "silvioprog" <silviop...@gmail.com> escreveu
> >> Why i can't make an Android app using Lazarus, as the free pascal
> compiler provides support to it? Is it because there is no GTK to android?
> And if the lazarus GUI framework did not depends on external libraries?
> >>
> >> The lazarus team did the right thing. They did not stopped to develop
> the Lazarus for Unix because "they couldn't use libraries". However, how
> would be the actual scenario if the GUI framework of the Lazarus was
> developed using just Pascal? Perhaps, I would not currently facing the
> problem of not being able to develop an android app using Lazarus provided
> frameworks.
> >
> > I couldn't understand what you meant.
> >
> > --
> > Silvio Clécio
>
> To summarize my opinion: if I am java programmer, would be better if I can
> solve my problem via Java classes than using C library binds. If i am a
> Pascal programmer, i prefer to solve my problem via Pascal classes instead
> of C binds.  Add an external dependency to the code may be a good option in
> short term, however may become a big problem in long term. Perhaps, if the
> Lazarus GUI framework was developed using pure pascal ( like fpGUI) instead
> of using external libraries and frameworks, we could develop mobile apps
> using Lazarus today.
>
Me too, but Java programmers mostly time use external C libraries when it
hasn't already implemented some feature yet, it is a good choice, and you
can use that Java classes without knowing that it make calls to an external
C library. The Free Pascal and Delphi do it too, for example, when you
access a database using SQLdb, it uses an external C library (the database
client), that is made in C, and many Pascal programmers uses SQLdb with
pure Pascal interfaces (headers) without knowing that the main
implementation is in the external C library.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-25 Thread silvioprog
On Mon, Jan 25, 2016 at 8:54 AM, Jy V <jyv...@gmail.com> wrote:

> On Mon, Jan 25, 2016 at 4:59 AM, silvioprog <silviop...@gmail.com> wrote:
>
>>
>> Yes, it can be easily implemented in TP comps. ASA nghttp2 get a pascal
>> header, BTW with a ng header in hands, you can use this one with any pascal
>> code. :-)
>>
>
> Instead of relying on external libraries such as nghttp2,
>
[...]
>

Hm... I don't understand why many Pascal users hates external libraries,
even when it's written in C, one of the best languages to create fast and
stable libraries, with a lot of users around the world provinding support
for that. :-/

Many units in Free Pascal and Delphi uses C libraries... when aren't using
a C library (an API system call, an third party library call, etc.), are
using assembly, ie, mostly time Pascal is used as a high-level language to
consume some low-level code written in C or assembly.

Just an example, the Embarcadero Delphi provides support for BJSON and
MongoDB, so you can find libraries like `libbson-1.0.dll` and
`libmongoc-1.0.dll` in the Delphi directory, and it was a very nice choice,
because these libraries implements a lot of features and they are
maintained for many programmers. I saw some Pascal libraries for MongoDB,
but they seem have been abandoned by their maintainers before being
concluded.

I use Pascal for high-level logic and sometimes for low-level logic using
pointers, but when I need a feature that Pascal hasn't implemented yet, I
search a C library to solve it, so I don't see a problem in using external
libraries. :-)

--
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-25 Thread silvioprog
Oops,

On Mon, Jan 25, 2016 at 11:56 AM, silvioprog <silviop...@gmail.com> wrote:
[...]

> Just an example, the Embarcadero Delphi provides support for BJSON
>

I meant:

"... provides support for BSON ..."

.. so I don't see a problem
>

"... I don't have problem ..."

Sorry. ^^'

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-25 Thread silvioprog
On Mon, Jan 25, 2016 at 5:08 PM, Michael Van Canneyt <mich...@freepascal.org
> wrote:

> On Mon, 25 Jan 2016, silvioprog wrote:
>>
>> Many units in Free Pascal and Delphi uses C libraries... when aren't using
>> a C library (an API system call, an third party library call, etc.), are
>> using assembly, ie, mostly time Pascal is used as a high-level language to
>> consume some low-level code written in C or assembly.
>>
>
> There is a simple reason: Debugging and bugfixing is a lot easier if all
> the code is in pascal.
>

I agree. Using external libraries has pros and cons.

Most libraries are a black box. I don't think I've purchased a
> library/package that didn't contain bugs,
> which I had to debug manually and fix.
>

Sad but true. :-/

The best advantage is that mostly C libraries have a lot of users and
active maintainers. I'm using three of them, and I got bugs on them, but I
fixed some of them by myself, and others I got help on theirs bugtracker.

Old timers as X, libc, pthreads and more such oldtimers will generally be
> bug-free, but there is lots of code out there with a less good track record.


Yes.

I'm using (and indicating) third party GNU C libraries, but before adopt
them, I check theirs ecosystem, how many programmers are involved on theirs
development, the commit history, how long an issue remains open, and if the
libraries are still active. :-)

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-25 Thread silvioprog
On Mon, Jan 25, 2016 at 7:02 PM, Dmitry Boyarintsev <
skalogryz.li...@gmail.com> wrote:

> On Mon, Jan 25, 2016 at 3:08 PM, Michael Van Canneyt <
> mich...@freepascal.org> wrote:
>
>> On Mon, 25 Jan 2016, silvioprog wrote:
>>
>>>
>>> Many units in Free Pascal and Delphi uses C libraries... when aren't
>>> using
>>> a C library (an API system call, an third party library call, etc.), are
>>> using assembly, ie, mostly time Pascal is used as a high-level language
>>> to
>>> consume some low-level code written in C or assembly.
>>>
>>
>> There is a simple reason: Debugging and bugfixing is a lot easier if all
>> the code is in pascal.
>>
>
> Here's another reason - cross-platform availability.
> FPC is cross platform. To some extent (Java?) is more cross-platform that
> C is.
>

Indeed. But the one of the basic steps before chosing a library (from any
language) is read its specification, and know if it provides the needed
features, works in the expected SOs, and provides a good documentation with
a stable support. I need to make a device and it need a microcontroller, so
I found that the best choice is a PIC16F64A because its datasheet shows all
the features and the basic hardware that I need.
Well, the mostly C libraries work fine in many OSs. One that I use works in
the popular systems (currently I need it just for Windows and Linux) like
GNU/Linux, FreeBSD, OpenBSD, NetBSD, Android, OS X, Win32/64 and special
systems like Symbian and z/OS, and it's already available in some tools
like apt, yum, npm, maven, pacman... :-) ... (and if I have a chance from
FPC team, I can make it also installable via fppkg tool too! :-D )


> When using an external library, there might be a risk that the library is
> not *easily* available for another platform that is targeted. It's common
> for open-source projects, not to provide any binary builds, requiring a
> library user to build the library themselves. Luckily, the most common
> projects do have some satellite projects that actually provide binaries.
>

That was the main problem that I also had, unfortunatelly. :-(

For example:

https://github.com/libharu/libharu/issues/118

Mostly Pascal programmers don't like C libraries they get boring because of
the bugs like this, and can't fix the problem (lack time; doesn't have a C
environment, or doesn't know C etc.). But, why not try to understand the
problem? Is C so hard that a Pascal programmer can't understand that? I
don't think so, if you already use pointers and played with low-level
programming in standard Pascal, you can learn C too.

Building C (C++) library could be a real pain for some Pascal users.
> (Pascal spoils!)
>

Sad but true. :-(

But they should try to get support from the library list. Some days ago I
fixed a lot a problems in a C library (that's already a FPC/Delphi header)
and now it works like a charm on Windows, Linux and OS X. But first time, I
thought: "oh ktulu, why it doesn't compile plz..." ... but after trying to
fix it by myself, finally I can fix common bugs in any C library, because
complex bugs usually are already fixed by its maintainers.

Building C/C++ library for a desired target platform, could be even more
> painful, specifically if some sort of cross-tools required or when building
> configuration needs to be changed.
>

Well, in mostly cases I just use the ./configure && make && make
install-strip hehehe... On Windows I use MinGW, so I can compile C
libraries easily, and when I got any problem to compiled that, I solve it
easily too, by myself or getting support in the Pascal or C communities. :-)


> Thus a pure pascal library would be a number one choice for most users.
> With though it might be outdated and/or slower than its C-counterpart (i.e.
> paszlib vs zlib)
>

I agree, but I can't find a hard problem that makes a Pascal programmer
(beginner or veteran) not to use a C library even if it has already a
solution that's not implemented in Pascal yet. :-)

These days I took a look at FPC/Laz examples finding some solution to
control keyboard/mouse remotely, something like a VNC, but just the
control, without the server, and I found that, the
components/MouseAndKeyInput package, that uses external libraries. On
Windows and OS X it uses theirs APIs (they are external libraries), on
Linux it uses the libxTst library, and I don't have problem to use this
component just because it's using a third party external GNU library. After
installing it via apt, the only problem that I got was create the library
link on the /lib folder.

But, unfortunatelly, even with this pros, Pascal programmers avoid to use
external libraries, that's a real fact. :-/

--
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-24 Thread silvioprog
On Sat, Jan 23, 2016 at 8:37 AM, Jy V  wrote:

> Hello Silvio,
>
> Are you considering to use TurboPower HTTP components to implements HPACK
> and HTTP/2 ?
>

Hello Jy,

Yes, it can be easily implemented in TP comps. ASA nghttp2 get a pascal
header, BTW with a ng header in hands, you can use this one with any pascal
code. :-)

I took a look at the IpHtmlPanel comp. on Windows, it's a nice component...
it prints some basic HTML/CSS, but it needs patches to fix some bugs (eg: I
can't see a HTML form on it), so I'm going to send that ASAP.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-22 Thread silvioprog
Hello,

Issue ID: #29483. [1]

This patch implements the HTTP support in the TurboPower IPro component.

Thank you!

[1] http://bugs.freepascal.org/view.php?id=29483

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] MouseAndKeyInput package and scroll up/down with whell button

2016-01-17 Thread silvioprog
On Sun, Jan 17, 2016 at 12:37 AM, silvioprog <silviop...@gmail.com> wrote:
[...]

> So, I think that MouseAndKeyInput package should implement the scroll
> support (triggered via up/down whell button).
>

Patch sent to: http://bugs.freepascal.org/view.php?id=29437.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] MouseAndKeyInput package and scroll up/down with whell button

2016-01-16 Thread silvioprog
Hello,

First, thanks to Tom Gregorovic for sharing this awesome package! :-)

So, I think that MouseAndKeyInput package should implement the scroll
support (triggered via up/down whell button).

I took a look at its code, and it seems implemented to compile on Linux,
Mac OS and Windows. Nice! :-) I can help to implement the scroll method for
Linux and Windows, because I don't have Mac OS here, but I believe that can
be easily implemented too.

On Windows the packed uses the Windows API, declaring the JwaWinUser unit,
so, I did a small test in a console program and the scrolling draft worked
fine here in my Windows 7 and 10:

=== begin code ===

program project1;

uses JwaWindows;

{  mouseData:
. enable the global scrolling (nil for local scrolling)
. up: WHEEL_DELTA
. down: dword(-WHEEL_DELTA) }

var VInput: TInput;
begin
  VInput := Default(TInput); // good bye FillChar :-)
  VInput.type_ := INPUT_MOUSE;
  VInput.mi.dwFlags := MOUSEEVENTF_WHEEL;
  VInput.mi.mouseData := WHEEL_DELTA;
  while True do begin
SendInput(1, @VInput, SizeOf(VInput));
Sleep(1000);
  end;
end.

=== end code ===

It's very easy to test it, just compile and run the project above and set
the SO cursor in a window with the vertical scroll enabled that the magic
happens. The WHEEL_DELTA flag allows this project to scroll any window.

On Linux the package uses the libXtst, that is very easy to implement the
scrolling feature too, we just:

=== begin code ===

// Ubuntu users: perform the `# ln -s
/usr/lib/x86_64-linux-gnu/libXtst.so.6 /usr/lib/libXtst.so` and check if
the Xtst link was created.

program project1;

{$linklib Xtst}

uses xlib, sysutils;

{ button:
. up: 4
. down: 5 }

// it just a test, the XTestFakeButtonEvent is already declared in the
MouseAndKeyInput package hehe :-)
function XTestFakeButtonEvent(dpy: PDisplay; button: dword;
  is_press: Boolean; delay: dword): longint; cdecl; external;

var  VDisplay: PDisplay;
begin
  VDisplay := XOpenDisplay(nil);
  while True do begin
// I got this idea from the Linux `xte` command line tool [1]
XTestFakeButtonEvent(VDisplay, 5, True, 0);
XTestFakeButtonEvent(VDisplay, 5, False, 0);
XSync(VDisplay, 0);
Sleep(1000);
  end;
  XCloseDisplay(VDisplay);
end.

=== end code ===

It's same to perform `$ while true; do xte 'mouseclick 5'; sleep 2; done`.

I don't know it the MouseAndKeyInput depends on LCL, if so I think that it
should be implemented depending only FCL, allowing the package to be used
in daemon programs (e.g as a micro vnc service).


[1] xte.c
...
218. void mouse_click( Display *d, XDevice *device, int button ) {
219. dmsg( 1, "Clicking mouse button %d\n", button );
*220. xte_FakeButtonEvent( d, device, button, True, CurrentTime );*
*221. xte_FakeButtonEvent( d, device, button, False, CurrentTime );*
222. }
...

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to find out the public IP in code?

2015-11-07 Thread silvioprog
On Sat, Nov 7, 2015 at 12:13 PM, fecske fecske  wrote:

> or see  this
>
> http://forum.lazarus.freepascal.org/index.php/topic,17506.msg110917.html#msg110917


If you just want to get your external IP using some service like dyndns,
you should use pure FCL:

=== begin code ===

uses fphttpclient, RegExpr;

procedure TForm1.Button1Click(Sender: TObject);
begin
  with TRegExpr.Create('[0-9.]+') do try
if Exec(TFPHTTPClient.SimpleGet('http://checkip.dyndns.org')) then
  ShowMessage(Match[0])
  finally Free; end;
end;

=== end code ==

However, if you can use other service like echoip.com, just:

=== begin code ===

uses  fphttpclient;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(TFPHTTPClient.SimpleGet('http://echoip.com/'));
end;

=== end code ===

HTH

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] An online package manager

2015-08-10 Thread silvioprog
On Sat, Aug 8, 2015 at 10:27 AM, Aradeonas aradeo...@operamail.com wrote:

 [Cross posted on forum so if you want answer there 
 :http://forum.lazarus.freepascal.org/index.php/topic,29284.0.html 
 http://forum.lazarus.freepascal.org/index.php/topic,29007.0.html]


 Hi,

 I saw Embarcadero's Getit
 http://docwiki.embarcadero.com/RADStudio/XE8/en/GetIt that introduced
 in Delphi XE8 and I think it can help Lazarus and it's community very well.
 As you know these days more IDE's make this systems and its
 good,collecting all packages and make it easy to use like a store.
 Is there any work on this subject until now or any one like to work on
 this subject? If yes I want to help.

 Regards,
 Ara


Very nice idea!

I use something like this in other languages and it is very useful (NPM,
Gradle, Maven, APT, Yum etc). The NPM project uses a nice approach: keep
your project in your repository (Github, Bitbucket etc) that we will
publish it as-is, see an example: https://www.npmjs.com/package/express
(although you found Express in NPM, this package is hosted in Github
https://github.com/strongloop/express).

So you can install a new package localy in your project just performing
npm install some-packe (even a new project, npm install new-project,
and you can start it too, npm start), or global, performing npm install
some-package -g, and to init a new packages.json, just perform npm
init. In Lazarus, the local installation could be in the project's folder,
and the global installations could be done in the lazarus/components
folder, eg: lpm install -g synapse, or lpm install
some-project-or-package-hosted-in-github --save (--save saves all sources
of you package). =)

Some times ago I saw a online package in CodeTyphon project too, but I
don't remember how it does that, but you can take a look on it. =)

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Compiler Options - Conditionally add a package dependency?

2015-07-09 Thread silvioprog

 On Thu, Jul 9, 2015 at 2:58 PM, Michael Van Canneyt mich...@freepascal.org
  wrote:

[...]

 We have support for dotted unit names. The only thing missing is a
 namespace directive.


Is there any plan for implementing the -NS[1] compiler parameter? This
option allows to use scoped unit names, that is very good for dotted unit
names, e.g:

MyCompany.SysUtils; // scope.unitname

...

uses
  SysUtils; // this is an 'alias' for my 'MyCompany.SysUtils' unit ...

$ fpc -NSMyCompany (it could be enabled via Lazarus package too)

This option also enables the 'UseUnitScopeNames' directive, so you can use
a unit declaration like 'uses {$IFNDEF
UseUnitScopeNames}MyCompany.{$ENDIF}SysUtils'.

P.S.: you can pass two or more scopes via this options, e.g:
-NSMyCompany;OtherCompany;SomeLib

[1] http://docwiki.embarcadero.com/RADStudio/XE8/en/Delphi_Compiler

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Compiler Options - Conditionally add a package dependency?

2015-07-09 Thread silvioprog
On Thu, Jul 9, 2015 at 4:05 PM, silvioprog silviop...@gmail.com wrote:
[...]

 This option also enables the 'UseUnitScopeNames' directive, so you can use
 a unit declaration like 'uses {$IFNDEF
 UseUnitScopeNames}MyCompany.{$ENDIF}SysUtils'.


Oops,

... so you can use an unit declaration like 'uses {$IFNDEF
UseUnitScopeNames}MyCompany.{$ENDIF}SysUtils', that is very useful for
keep support for legacy codes.

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] LazReport - Feature questions

2015-07-09 Thread silvioprog
On Thu, Jul 9, 2015 at 4:45 PM, Michael Van Canneyt mich...@freepascal.org
wrote:
[...]

 I think Lazreport's design contains some fundamental flaws, which can only
 be remedied by re-implementing a reporting engine from scratch.


This is a very good new! I smell TFPReport in the air... =)

--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [TIP] LazSqlX!

2015-06-03 Thread silvioprog
On Wed, Jun 3, 2015 at 12:22 PM, Michael Van Canneyt mich...@freepascal.org
 wrote:

 On Wed, 3 Jun 2015, silvioprog wrote:

 Hello,

 Do you know LazSqlX?:

 https://lazsqlx.wordpress.com/

 I found it yesterday on Google, and now it will be one of my working
 tools, because its quality is very high.

 See some print screens here:

 http://sourceforge.net/projects/lazsqlx/

 Enjoy it!


 I would like to, but without source files and/or setup for my platform
 that will be difficult.

 Michael.


From a brazilian member (Valmadson Santos):

https://github.com/flakron-shkodra/LazSqlX

HTH =D

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] [TIP] LazSqlX!

2015-06-03 Thread silvioprog
Hello,

Do you know LazSqlX?:

https://lazsqlx.wordpress.com/

I found it yesterday on Google, and now it will be one of my working tools,
because its quality is very high.

See some print screens here:

http://sourceforge.net/projects/lazsqlx/

Enjoy it!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Base64 broken in json?

2015-05-30 Thread silvioprog
On Sat, May 30, 2015 at 12:14 PM, Leonardo M. Ramé l.r...@griensu.com
wrote:

 On 30/05/15 05:48, Michael Van Canneyt wrote:


 On Fri, 29 May 2015, Leonardo M. Ramé wrote:

  Hi, does anyone know if when adding a base64 encoded string to an
 TJsonObject and calling AsJson method, the base64 is broken?


 Normally not.

  I did try to decode (with base64 -d command) and I'm getting errors
 when trying to decode the base64 string contained in the json. Btw,
 this is the 1nst time I get errors, the file encoded is about 1.5mb.


 If you write the json with AsJSON to file and try to decode this file,
 that will obviously not work.
 You need to get the value of the member with the base64 using the
 AsString method. The result of AsString should be decodable

 I have used JSON with Base64 repeatedly and never had problems.

 Michael.



 Michael, obviously I decode the value of the member. Anyway, in this
 particular case using AsJson the result is broken some way.

 I just concatenated a string like:

 myString := '{ var1: ' + Base64EncodedString + ' }';

 And it worked perfectly, while doing:

 myJson.Add('var1', Base64EncodedString);

 and

 myJson.AsJson results in errors while trying to decode var1.


Hm... it works fine here (fpc 2.6.4 and trunk):

procedure TForm1.Button1Click(Sender: TObject);
var
  j: TJSONObject;
  b64: String;
begin
  b64 := EncodeStringBase64('leonardo');
  j := TJSONObject.Create;
  j.Add('var1', b64);
  ShowMessage(j.AsJSON + ' - ' + DecodeStringBase64(j.Strings['var1']));
  j.Free;
end;

Result:

[Window Title]
project1

[Content]
{ var1 : bGVvbmFyZG8= } - leonardo

[OK]

But after take a look at your code, it seems better to use as:

myString := '{ var1: ' + StringToJsonString(Base64EncodedString) + ' }'

Because function StringToJsonString will encode string in a JSON-escape
string.

--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Getting common documents folders

2015-05-27 Thread silvioprog
On Wed, May 27, 2015 at 6:21 PM, Michael Van Canneyt mich...@freepascal.org
 wrote:


 On Wed, 27 May 2015, Glaucos Ginez wrote:

  Hi, you can use GetEnvironmentVariable('LocalAppData')

 2015-05-27 14:53 GMT-04:00 Richard Mace richard.m...@gmail.com:
   Hi All,
 I need to use/get a common windows folder (in Win XP,Vista,7,8 and 8.1)
 that all users will have
 read/write access to by default.
 I think it is CSIDL_COMMON_DOCUMENTS

 Any ideas how I can code this in Lazarus?


 You can use the shfolder unit. It contains the necessary constants and
 calls to retrieve the location.

 Michael.


Here in Brazil, on Lazarus-BR group, an member (Joao Marcelo Vaz) sent an
very nice tip:

uses
  windirs;

...

  ShowMessage(GetWindowsSpecialDir(CSIDL_COMMON_DOCUMENTS));

=)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] New preprocessor directive

2015-05-24 Thread silvioprog
On Sun, May 17, 2015 at 5:50 AM, Michael Van Canneyt mich...@freepascal.org
 wrote:


 Hello,

 As you probably know, it is possible to include source filename, line
 number, date etc. in your source
 with the following directives:
 {$I %FILENAME%}
 {$I %LINE%}
 {$i %DATE%}

 At my request, Florian added

 {$I %CURRENTROUTINE%}

 to the list of possibilities, which means you can do nifty things as:

 program testcr;

 {$mode objfpc}

 Type
   TMyClass = Class(TObject)
   Public
 Procedure MyMethod;
   end;

 Var
   Indent : Integer;

 Procedure MethodEnter(Const AMethod : String);
 begin
   Writeln(StringOfChar(' ',Indent),'Entering ',AMethod);
   Inc(Indent,2);
 end;

 Procedure MethodExit(Const AMethod : String);
 begin
   Dec(Indent,2);
   if Indent0 then Indent:=0;
   Writeln(StringOfChar(' ',Indent),'Exiting ',AMethod);
 end;

 Procedure Debug(Const AMsg : String);

 begin
  Writeln(StringOfChar(' ',Indent),AMsg);
 end;

 Procedure DoSomething;

   Procedure DoNested;

   begin
 MethodEnter({$I %CURRENTROUTINE%});
 Debug('Nested handling in '+{$I %CURRENTROUTINE%});
 MethodExit({$I %CURRENTROUTINE%});
   end;

 begin
   MethodEnter({$I %CURRENTROUTINE%});
   Debug('Doing something in '+{$I %CURRENTROUTINE%}+' at line '+{$I
 %LINE%});
   DoNested;
   MethodExit({$I %CURRENTROUTINE%});
 end;

 Procedure TMyClass.MyMethod;

   Procedure DoNested;

   begin
 MethodEnter({$I %CURRENTROUTINE%});
 Debug('Nested handling in '+{$I %CURRENTROUTINE%});
 MethodExit({$I %CURRENTROUTINE%});
   end;

 begin
   MethodEnter({$I %CURRENTROUTINE%});
   Debug('Doing some things in '+{$I %CURRENTROUTINE%}+' at line '+{$I
 %LINE%});
   DoNested;
   MethodExit({$I %CURRENTROUTINE%});
 end;


 Var
   T : TMyClass;

 begin
   MethodEnter({$I %CURRENTROUTINE%});
   DoSomething;
   T:=TMyClass.Create;
   try
 T.MyMethod;
   finally
 T.Free;
   end;
   MethodExit({$I %CURRENTROUTINE%});
 end.

 Which produces something like

 Entering $main
   Entering DoSomething
 Doing something in DoSomething at line 44
 Entering DoNested
   Nested handling in DoNested
 Exiting DoNested
   Exiting DoSomething
   Entering MyMethod
 Doing some things in MyMethod at line 61
 Entering DoNested
   Nested handling in DoNested
 Exiting DoNested
   Exiting MyMethod
 Exiting $main

 Kudos to Florian.

 Michael.


Thanks for this nice feature! =)

I'll use it in a new logger class that I'm implementing.

(y)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Feature request/inquiry

2015-04-30 Thread silvioprog
On Sun, Apr 26, 2015 at 5:07 PM, Dmitry Boyarintsev 
skalogryz.li...@gmail.com wrote:

 On Sun, Apr 26, 2015 at 3:17 PM, silvioprog silviop...@gmail.com wrote:


 I implemented this feature in an old project that I maintain,
 LazSolutions, and it was cross-platform.


 Nice!  EM_SETCUEBANNER doesn't have Ansi version, it only accepts
 WideChars (even for Ansi windows)
 But, why was cross-platform? Is it broken now?

 thanks,
 Dmitry


Oops, I'm sorry for fast typing. =)

It is cross-platform, and it works in more popular widgets like Windows,
GTK and Qt.

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Feature request/inquiry

2015-04-26 Thread silvioprog
On Sun, Apr 26, 2015 at 3:18 PM, Dmitry Boyarintsev 
skalogryz.li...@gmail.com wrote:

 On Sun, Apr 26, 2015 at 1:35 PM, luiz americo pereira camara 
 luiz...@oi.com.br wrote:


 I implemented here long time ago:
 https://code.google.com/p/luipack/source/browse/trunk/luicontrols/searchedit.pas

 If agreed i can add to LCL as TEdit.TextHint


 Two notes here:

 #1
 for the case of TSearchEdit - it should be (optionally) a stand alone
 widget, rather than a hard-coded pure LCL control.
 otherwise it would not be rendered properly for OSX

 https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/ControlsText.html#//apple_ref/doc/uid/2957-CH51-SW5

 and maybe (https://developer.gnome.org/gtk3/stable/GtkSearchBar.html)
 gtk3 ?

 Win32 as well as Qt doesn't seem to have native controls, thus having
 LCL-level wrapper is a good solution for them.

 #2
 Is luipack being moved to other source hosting service? (i.e. github,
 sourceforge). code.google is closing.

 thanks,
 Dmitry


In Windows:

uses
  Windows;

procedure TForm1.FormCreate(Sender: TObject);
const
  ECM_FIRST = $1500;
  EM_SETCUEBANNER = ECM_FIRST + 1;
begin
  SendMessage(Edit1.Handle, EM_SETCUEBANNER, 0,
LParam(PWideChar(WideString('My placeholder on Windows';
end;

I implemented this feature in an old project that I maintain, LazSolutions,
and it was cross-platform.

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [Release 1.4.0]: is the Identifier Completation compatible with generic?

2015-04-22 Thread silvioprog
Oops...

On Wed, Apr 22, 2015 at 2:49 AM, silvioprog silviop...@gmail.com wrote:

 [...]

In Lazarus 1.2.4 it works fine.


... In Lazarus 1.2.6 ...

I'd downgrade while I not get why it does not work. XD

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] [Release 1.4.0]: is the Identifier Completation compatible with generic?

2015-04-21 Thread silvioprog
Hello,

Please try the test below:

[code]
uses
  Forms, fgl;

type
  TForm1 = class(TForm)
  end;

  { TTest }

  TTest = class(specialize TFPGListTObject)
  public
property Test: strin|  try Identifier Completation here [Ctrl+Space]
...
  end;
[/code]

It will see an:

unit1.pas(16,17) Error: identifier not found: specialize

In Lazarus 1.2.4 it works fine.

Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to write an eficient lexical scanner/parser?

2015-03-13 Thread silvioprog
On Wed, Mar 11, 2015 at 6:38 AM, leledumbo leledumbo_c...@yahoo.co.id
wrote:

  However, I have a question: is there any article about 'how to write
 lexical parsers' using Object Pascal?

 First, you need to differentiate them correctly. Lexical scanner (or simply
 lexer) and parser, not lexical parser :)

 I've written some simple languages, generating GraphViz, LLVM or C code,
 using both self learning reference from the almighty Prof. Niklaus Wirth's
 articles, Jack Crenshaw's, the legendary dragon book and many others plus
 my
 compiler course in college.

 I really really suggest Prof. Niklaus Wirth's one
 (http://www.inf.ethz.ch/personal/wirth/, click the Compiler Construction
 link) as it's concise, simple, doesn't use stupid generator (i.e.: easy to
 implement by hand) while covering most important parts of the subject.
 While
 he didn't use or stress or even discourage the usage of abstract syntax
 tree, he did explain it that's good enough to understand.

 Here's what I've written in the past and is publicly available:
 - https://bitbucket.org/leledumbo/erd-maker (generates GraphViz code for
 ERD
 visualization)
 - https://bitbucket.org/leledumbo/linguc (generates LLVM code that can be
 compiled as a library for a mathematically provable language focusing in
 database driven application)

 I don't use the direct code generation approach anymore as I found the
 abstract syntax tree to be usable for more than just code generation.


Buddy, thanks alot for that information. I'll take a look at this! =)

--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to write an eficient lexical scanner/parser?

2015-03-10 Thread silvioprog
On Fri, Mar 6, 2015 at 3:15 PM, Kostas Michalopoulos 
badsectorac...@gmail.com wrote:

 This is a classic series of articles that show how to write a very simple
 compiler in Turbo Pascal. The fundamentals when it comes to scanning are
 the same:

 http://compilers.iecc.com/crenshaw/

 I've also written a BASIC implementation for Free Pascal and Lazarus. The
 scanner should be straightforward to understand:


 http://runtimelegend.com/rep/rbasic/artifact/2350e85c36a77e4d2d76adde23fd7d45731b5b22

 The compiler code shows how it can be used:

 http://runtimelegend.com/rep/rbasic/artifact/93859f52fd424edfc1e0d5dfd16a92ed8ac04855

 But you may also find the formatter code simpler. Although it is a bit too
 simple:

 http://runtimelegend.com/rep/rbasic/artifact/f3e9fb2d1ed8e60d36b50754c2d9a7d7c109fc40

 For general theory you can look on recursive descent parsers (they're the
 simplest to implement and AFAIK most compilers use them, either to build
 the token list or directly).


I downloaded the PDF with all articles.

Thank you very much!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to write an eficient lexical scanner/parser?

2015-03-10 Thread silvioprog
On Fri, Mar 6, 2015 at 4:21 PM, Anthony Walter sys...@gmail.com wrote:

 Here is something I originally wrote in 2001. I had a product briefly for
 converting pascal code into documentation and it quite fast. Do with it as
 you will.

 http://pastebin.com/qXJdHwGM


Nice parser. I had some ideas after seeing your code. Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to write an eficient lexical scanner/parser?

2015-03-10 Thread silvioprog
On Fri, Mar 6, 2015 at 3:29 PM, aradeonas aradeo...@operamail.com wrote:

  Hi Silvio,

 About this parsing subject maybe looking at BeniBela Xidel and
 InternetTools help you or talking to Benito Aurthur of them.
 He is a very good developer and kind person like you.
 http://videlibri.sourceforge.net/xidel.html
 http://www.benibela.de/sources_en.html#internettools

 Ara


I think that it uses regex as parser. I'll check when I have a free time.
Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Play video from memory

2015-03-08 Thread silvioprog
On Fri, Mar 6, 2015 at 2:32 PM, aradeonas aradeo...@operamail.com wrote:

  Dear Silvio I checked them before and I couldn't find out way for
 opening from memory.

 Ara


FFVCL (from the link that I sent in previous message) offer support to
video stream (FPC/Dephi):

http://www.delphiffmpeg.com/downloads/

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] bittorrent

2015-03-06 Thread silvioprog
On Fri, Mar 6, 2015 at 9:30 AM, Anthony Walter sys...@gmail.com wrote:

 Does anyone know of a good bittorrent protocol implementation written in
 Pascal?

 I think Lazarus might really make strides the programming community if a
 top notch bittorrent client were written using it.

 Related: Popular windows torrent client μTorrent heads further down the
 toilet with each new release:


 http://forum.utorrent.com/topic/95041-warning-epicscale-riskware-silently-installed-with-latest-utorrent/


I know a Bit-Torrent GUI, called Transmission Remote GUI:

https://code.google.com/p/transmisson-remote-gui/

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] How to write an eficient lexical scanner/parser?

2015-03-06 Thread silvioprog
Hello,

I'm planning to write three parsers, and googling, I found some entries
talking about lexical parsers.

After that, I did a 'find in files' in FPC sources, and I found many
parsers (eg: jsonparser (jsonscanner), JSParser (JSScanner), fpsqlparser
(fpsqlscanner), PParser (PScanner), fpexprpars etc.) that use lexical
scanner.

Below, three possible string that I need to parse:

1)

${someVariable} -- 4 tokens

or

${a + b} -- 8 tokens - 1 expression

or

${fn:lenght('abc') * 3} -- 11 tokens - 1 function - 1 expression

2)

c:forEach var=contact items=${contactDao.list}
${contato.name}, ${contato.email}
/c:forEach

3)

contacts[0].name=abc
contacts[0].email=abc@def
contacts[1].name=def
contacts[2].email=def@ghi

So my parser will allow to register dynamic variables, functions (to be
called via script) and plugins (to extend the parser).

However, I have a question: is there any article about 'how to write
lexical parsers' using Object Pascal?

I need any material about this subject, and I'm very grateful for any tip.

Thanks in advance!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Play video from memory

2015-03-06 Thread silvioprog
On Fri, Mar 6, 2015 at 2:02 PM, aradeonas aradeo...@operamail.com wrote:

  Anyway if anyone know a way or library please tell me.

 Ara


You can get some video libraries here:

http://wiki.freepascal.org/Video_Playback_Libraries

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] How can I configure unit scope names in Lazarus?

2015-02-26 Thread silvioprog
Hello,

In Delphi, I can create a unit called Foo.Bar.pas, after that, in Delphi
Compiler | Unit scope names project option, I can add Foo to the unit
scope names list, so I can declare my unit in two ways:

- uses Foo.Bar;

or:

- uses Bar;

It is very useful for retro-compatibility (eg.: FPC 3.0.0 accepts Foo.Bar,
but 2.6.4 only Bar), or useful if someone prefer to declare the units
without the scope name (SysUtils instead of System.SysUtils).

Is this feature - unit scope names - implemented in FPC? If so, the Lazarus
IDE has a window to configure that in my project?

Thank you!

--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How can I configure unit scope names in Lazarus?

2015-02-26 Thread silvioprog
On Thu, Feb 26, 2015 at 5:57 PM, Sven Barth pascaldra...@googlemail.com
wrote:

 On 26.02.2015 21:50, silvioprog wrote:

 Is this feature - unit scope names - implemented in FPC? If so, the
 Lazarus IDE has a window to configure that in my project?


 FPC does not support that yet.

 Regards,
 Sven


Thank you! (y)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] [OT] HTTP/2 is Done!

2015-02-19 Thread silvioprog
Just sharing:

https://www.mnot.net/blog/2015/02/18/http2

Enjoy reading! =)

--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Inversion of control (IoC) and Dependency injection (DI)

2015-01-11 Thread silvioprog
On Mon, Jan 5, 2015 at 5:07 PM, luiz americo pereira camara 
luiz...@oi.com.br wrote:

 Starting a new thread.

 2015-01-05 15:16 GMT-03:00 silvioprog silviop...@gmail.com:

 On Mon, Jan 5, 2015 at 12:54 PM, Marco van de Voort mar...@stack.nl
 wrote:


 As a first step in the 3.0.0 release process the stable branch was
 branched
 off to branches/fixes_3_0 and the version number was updated to 3.0.1

 The version in trunk was raised to 3.1.1

 Scripts might need modification accordingly.


 Good news!

 Chances of custom attributes[1] (or something like this) in release 3.0?
 I have plans to use IoC[2] and DI using this feature.


 I created a IoC Container that can be found at
 https://code.google.com/p/luipack/source/browse/trunk/luicomponents/luiioccontainer.pas
 . It has no dependencies.


Awesome!

With it is possible to implement Service Locator and Property Injection
 patterns. Constructor Injection is not possible due to lacking of Extended
 RTTI support in fpc.


Can you send a small (and isolated) sample showing how to use it?


 While the C# crowd  praises the Constructor Injection pattern (
 http://www.devtrends.co.uk/blog/how-not-to-do-dependency-injection-the-static-or-singleton-container
 ), i had hard times figuring how it would work in real world / Lazarus
 projects. Also, polluting the constructor  signature is not something that
 i like. And finally with Constructor Injection is not possible to use with
 TComponent / TForm

 So in the end, i use the service locator and have plans to use Property
 Injection pattern

 BTW: Custom Attributes support would help to have a nicer Property
 Injection implementation


I've plan to use something like this (CDI inspirations: http://cdi-spec.org
):

The model:

uses
  My.Company.MySDK.EntityAttributes, My.Company.MySDK.TableAttributes ...;
type
  [Entity]
  [Table('products')]
  TProduct = class(TObject)
  public
[Id][GeneratedValue]
property Id: LongInt ...;
[ManyToOne][JoinColumn('OrderId')]
property OrderId: LontInt ...;
[NotNull][NotEmpty][Size(1, 10)][Unique]
property Name: String ...;
[Nulls][Lenght(100)][Unique]
property Description: String ...;
[MyCustomCurrConversion(TypeInfo(Currency), TypeInfo(String), ',0.00')]
[MyCustomMinMax('Price must be = %d and = %d.', [1, 1000])]
property Price: Currency ...;
  end;


The DAO:

type
  [RequestScoped]
  TProductDao = class(TObject)
  private
[Inject] property Session: TSession ... ;
[Transational] procedure Add(AProduct: TProduct);
...
  end;
...procedure TProductDao.Add(AProduct: TProduct);begin
  Session.Save(AProduct);end;


The *produces* (to use external libs like *JCore*):

type
  [ApplicationScoped]
  TSessionCreator = class(TObject)
  private
[Inject] property SessionFactory: TJCoreSession ... ;
[Produces] function GetSession: TSession;
...
  end;
...
TSessionCreator.GetSession: TSession;begin
  Result := ASessionFactory.OpenSession;end;

TSessionCreator.Close([Disposes]ASession: TSession) {begin  if
ASession.IsOpenASession.Close;end;


The controller:

uses
  My.Company.ControllerAttributes ... ;
type
  [Controller]
  TProcuctController = class(TObject)
  public
[Post][Transational] procedure Add([Valid] AProduct: TProduct); //
[Valid]: to validade properties
[Get][Path('./product')][Transational] procedure
List([Pagination('page={[0-9]}rows={[0-9]}')] AProducts:
TArrayListTProduct); // to paginate products
[Inject] property ProductDao: TProductDao ...; // inject DAO
[Inject] property Result: TResponse ...; // inject Response
  end;
...
procedure TProcuctController.Add(AProduct: TProduct);begin
  ProductDao.Add(AProduct);
  Result.SetAttribute(AProduct,
'product').RedirectTo(TProductController).List;end;
procedure TProcuctController.List(AProducts: TArrayListTProduct);begin
  Result.SetAttribute(AProducts, 'products'); // to create a variable
products in my BSP viewend;


The view:

html
ul
c:forEach items=${products} var=product
li ${product.name} - fmt:currency value=${product.price}
mask=R$ ,0.00//li
/c:forEach
/ul
/html


But I think that I'll still wait some years to make it possible in Free
Pascal hehe ...

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] HEADS UP: FPC 3.0.1 stable branched off.

2015-01-05 Thread silvioprog
On Mon, Jan 5, 2015 at 12:54 PM, Marco van de Voort mar...@stack.nl wrote:


 As a first step in the 3.0.0 release process the stable branch was branched
 off to branches/fixes_3_0 and the version number was updated to 3.0.1

 The version in trunk was raised to 3.1.1

 Scripts might need modification accordingly.


Good news!

Chances of custom attributes[1] (or something like this) in release 3.0? I
have plans to use IoC[2] and DI using this feature.

Thank you!

[1] - http://forum.codecall.net/topic/76463-introducing-attribute/
[2] - http://martinfowler.com/articles/injection.html
--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Is FPDoc Editor working?

2014-12-22 Thread silvioprog
On Mon, Dec 22, 2014 at 5:10 AM, Yann Mérignac yann.merig...@gmail.com
wrote:

 This works for me (Lazarus 1.26 + Linux 32 + Gtk) :

 - create a 'doc' directory in your project directory
 - open Project  Project Options
 - In FPDoc Editor options add 'doc' to the search path

 Now I can place the cursor on FooBar and click the 'Create Help Item'
 button in FPDoc Editor.


Yes!

Following this steps it worked fine here.

Thanks alot! (y)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Is FPDoc Editor working?

2014-12-21 Thread silvioprog
Lazarus list rejected my e-mail because my attachments  100 KB. ¬¬'

Attachment 1: http://tinypic.com/r/zko60n/8 ;
Attachment 2: http://tinypic.com/r/2yo77v6/8

Please see my message below:

On Sat, Dec 20, 2014 at 6:33 PM, silvioprog silviop...@gmail.com wrote:

 On Sat, Dec 20, 2014 at 5:38 AM, Mattias Gaertner 
 nc-gaert...@netcologne.de wrote:

 On Fri, 19 Dec 2014 18:26:33 -0300
 silvioprog silviop...@gmail.com wrote:

  Hello,
 
  I'm trying to use the FPDoc Editor following this steps below:
 
  . In Lazarus IDE, open the FPDoc Editor from View menu;
  . In the Lazarus source code editor, move the cursor to some code
 element.
 
  However, the Create help item button is never enabled for me
 
  How to use it? I saw the (wrong) step by step in this link:
  http://wiki.lazarus.freepascal.org/LazDoc.

 It works here. You have to place the cursor on the identifier of an
 declaration. For example:
 property Foo|Bar: string;

 On what identifier does it not work?


 It still does not working for me. =(

 My all steps:

 . Open Lazarus;
 . Save the current project (Project1);
 . Declare a property FooBar: string in your current main form (TForm1);
 . Place the cursor on the Foo|Bar identifier.

 Please see a screen shot from my desktop in attachment.

 Tested in latest Lazarus beta version (downloaded from Source Forge) and
 Lazarus trunk version (downloaded from Github), same problem in both.

 My SO: Windows 7, 64 bits.


-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] FPDoc Editor vs Lazarus Documentation Tool

2014-12-20 Thread silvioprog
On Sat, Dec 20, 2014 at 8:18 AM, Graeme Geldenhuys 
mailingli...@geldenhuys.co.uk wrote:

 On 2014-12-19 21:58, silvioprog wrote:
  What is the most recomended tool to make documentation?:

 I simply use my favourite text editor (EditPad Pro) and code templates.
 I don't use indentation in the XML files because unfortunately that
 screws with some fpdoc output formats where spaces are kept in the
 documentation. Lazarus's built-in doc editor doesn't allow for this as
 far as I know.

 You can obviously use Lazarus IDE's editor itself for editing those XML
 files too.

 EditPad Pro has the advantage that code templates can be better
 organised, file navigation structures can be defined for easy
 navigation, custom highlighting can be defined (though the default XML
 highlighting is just fine), and EditPad Pro can do automatic
 spell-checking on the content itself (ignoring XML tags).

 jEdit is another very good and free (and cross platform) text editor.


I use three editors (Intellij IDEA, Eclipse and Notepad++), but I want to
use a tool distributed with Lazarus, because I'll make a screencast of my
component installed in Lazarus IDE. :-/

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] FPDoc Editor vs Lazarus Documentation Tool

2014-12-20 Thread silvioprog
On Sat, Dec 20, 2014 at 9:18 AM, Graeme Geldenhuys 
mailingli...@geldenhuys.co.uk wrote:

 On 2014-12-20 11:29, Mattias Gaertner wrote:
  What does it not allow exactly?

 The built-in editor does very weird indentation, and there is no option
 to switch indentation off completely. Here is a quick example I just
 created with the built-in editor. Also note that the built-in editor
 simply appends to the end of the file. So the module description is
 somewhere in the middle of the file because I didn't write it first (I
 know it doesn't matter to fpdoc, but it does to me).

 
 ?xml version=1.0 encoding=UTF-8?
 fpdoc-descriptions
   package name=project1
 module name=mycomponent
   element name=TMyComponent
 shortMy short description/short
 descrprintshort id=TMyComponent/. My long description goes
 here./descr
 seealsoTObject/seealso
   /element
 descrpThis unit contains my cool component./ppIt is just
 what I wanted./p
   /descrelement name=TMyComponent.NameshortDescribes the
 name of the object/short
   /element
 /module
   /package
 /fpdoc-descriptions
 =

 I would have written it manually as follows to make sure fpdoc doesn't
 get whitespace errors, plus I have more control over ordering the
 documentation (not that it really makes a difference to fpdoc).

 ==
 ?xml version=1.0 encoding=UTF-8?
 fpdoc-descriptions
 package name=project1

 module name=mycomponent
 descrpThis unit contains my cool component./ppIt is just what I
 wanted./p/descr

 element name=TMyComponent
 shortMy short description/short
 descrprintshort id=TMyComponent/. My long description goes
 here./descr
 seealsoTObject/seealso
 /element

 element name=TMyComponent.Name
 shortDescribes the name of the object/short
 /element
 /module

 /package
 /fpdoc-descriptions
 ==


 Doing it manually with code templates, I'm just as fast as the built-in
 editor, so it's note a speed thing. ;-)


So why not add this option in the built-in editor? It seems a nice
alternative to who want work using only Lazarus IDE. =)

--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] FPDoc Editor vs Lazarus Documentation Tool

2014-12-20 Thread silvioprog
On Sat, Dec 20, 2014 at 3:25 PM, leledumbo leledumbo_c...@yahoo.co.id
wrote:

  I'm writting a new component and I want to use a doc creator tool
 available in own Lazarus

 My recommendation:
 fpdoceditor.png
 
 http://free-pascal-lazarus.989080.n3.nabble.com/file/n4039867/fpdoceditor.png
 

 I don't really care about the generated XML as long as it's compilable. I
 edit from this editor and it's nice to have IDE integrated one. I can both
 document and code at the same time without the need to switch app.


Yes, I want it too, and this is a very nice option (I use a similar
approach in other IDEs).

The documentation generated by the FPDoc is not responsive (e.g:
http://goo.gl/bCJoPM), i.e., it does not open well on a mobile device.

But I believe that the FPC team can accept a patch to apply the Bootstrap (
http://getbootstrap.com/) in FPDoc and all generated documentation could
have a better appearance and be compatible with any device that can render
HTML. =)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] FPDoc Editor vs Lazarus Documentation Tool

2014-12-20 Thread silvioprog
On Sat, Dec 20, 2014 at 7:21 PM, Graeme Geldenhuys 
mailingli...@geldenhuys.co.uk wrote:

 On 2014-12-20 22:06, silvioprog wrote:
  The documentation generated by the FPDoc is not responsive (e.g:
  http://goo.gl/bCJoPM), i.e., it does not open well on a mobile device.

 That's down to your choice of CSS style sheets - not a fault of FPDoc.
 Simply specify a different stylesheet and the magic will start
 happening. :) If you don't specify your own stylesheet, FPDoc will give
 you the generic/default one. You are not forced to use the default
 stylesheet.


Wooow, I'll use that!

Now I want to do the built-in editor work here in my PC ...

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] [ISSUE] Complete Code does not work with dotted unit

2014-12-20 Thread silvioprog
Hello,

Please see in:

http://bugs.freepascal.org/view.php?id=27193

Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Is FPDoc Editor working?

2014-12-19 Thread silvioprog
Hello,

I'm trying to use the FPDoc Editor following this steps below:

. In Lazarus IDE, open the FPDoc Editor from View menu;
. In the Lazarus source code editor, move the cursor to some code element.

However, the Create help item button is never enabled for me

How to use it? I saw the (wrong) step by step in this link:
http://wiki.lazarus.freepascal.org/LazDoc.

Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] FPDoc Editor vs Lazarus Documentation Tool

2014-12-19 Thread silvioprog
Hello,

What is the most recomended tool to make documentation?:

1. http://wiki.lazarus.freepascal.org/LazDoc;
2. http://wiki.lazarus.freepascal.org/Lazarus_Documentation_Editor.

I'm writting a new component and I want to use a doc creator tool
available in own Lazarus.

Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Thanks to FPC team: Record helper for primitive types!

2014-11-29 Thread silvioprog
Hello,

Today I compiled my FPC from trunk and saw the following possibility:

  { TIntegerHelper }

  TIntegerHelper = record helper for Integer
function ToString: string;
  end;

...

{ TIntegerHelper }

function TIntegerHelper.ToString: string;
begin
  Result := IntToStr(Self);
end;

...

var
  I: Integer = 123;
begin
  WriteLn(I.ToString); // Prints 123
end.

Or:

  { TStringHelper }

  TStringHelper = record helper for String
function ToUpperCase: string;
  end;

...

uses
  LazUTF8;

{ TStringHelper }

function TStringHelper.ToUpperCase: string;
begin
  Result := LazUTF8.UTF8UpperCase(Self);
end;

...
var
  S: UTF8String = 'atenção';
begin
  WriteLn(S.ToUpperCase); // Prints ATENÇÃO
  // or
  WriteLn('atenção'.ToUpperCase); // Prints ATENÇÃO
end.

It's evolution, baby! =)

Thanks alot for this great implementation, FPC team! (and special thanks to
Sven!) =D

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Thanks to FPC team: Record helper for primitive types!

2014-11-29 Thread silvioprog
On Sat, Nov 29, 2014 at 4:54 PM, Michael Van Canneyt mich...@freepascal.org
 wrote:

 On Sat, 29 Nov 2014, silvioprog wrote:

 On Sat, Nov 29, 2014 at 2:04 PM, Sven Barth pascaldra...@googlemail.com
 wrote:
   On 29.11.2014 16:54, silvioprog wrote:
 Hello,

 Today I compiled my FPC from trunk and saw the following
 possibility:


   This feature is available since February 2013 already, you just had
 to use {$modeswitch typehelpers}
   (I even announced that on fpc-devel, fpc-pascal and fpc-announce
 back then). What I committed
   yesterday was simply to allow them by default in mode Delphi as
 that mode is simply a collection of
   features supported by the current Delphi version (in so far they
 are already implemented in FPC). You
   still have to use the modeswitch in other modes and in all modes
 except the Delphi ones it's type
   helper instead of record helper.

   Regards,
   Sven


 Awesome. I'll use type helper. =)

 Plans to implement the currently XE helpers? (TIntegerHelper,
 TStringHelper etc.)


 Definitely, as soon as I find time.
 But initial patches welcome.

 Michael.


Nice. To implement it we can need to enable the {$modeswitch typehelpers}.
Can you enable it in SysUtils?

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Thanks to FPC team: Record helper for primitive types!

2014-11-29 Thread silvioprog
On Sat, Nov 29, 2014 at 5:55 PM, silvioprog silviop...@gmail.com wrote:

 On Sat, Nov 29, 2014 at 4:54 PM, Michael Van Canneyt 
 mich...@freepascal.org wrote:

 On Sat, 29 Nov 2014, silvioprog wrote:

 On Sat, Nov 29, 2014 at 2:04 PM, Sven Barth pascaldra...@googlemail.com
 wrote:
   On 29.11.2014 16:54, silvioprog wrote:
 Hello,

 Today I compiled my FPC from trunk and saw the following
 possibility:


   This feature is available since February 2013 already, you just
 had to use {$modeswitch typehelpers}
   (I even announced that on fpc-devel, fpc-pascal and fpc-announce
 back then). What I committed
   yesterday was simply to allow them by default in mode Delphi as
 that mode is simply a collection of
   features supported by the current Delphi version (in so far they
 are already implemented in FPC). You
   still have to use the modeswitch in other modes and in all modes
 except the Delphi ones it's type
   helper instead of record helper.

   Regards,
   Sven


 Awesome. I'll use type helper. =)

 Plans to implement the currently XE helpers? (TIntegerHelper,
 TStringHelper etc.)


 Definitely, as soon as I find time.
 But initial patches welcome.

 Michael.


 Nice. To implement it we can need to enable the {$modeswitch
 typehelpers}. Can you enable it in SysUtils?


Just testing:

unit sysutils;
interface

{$MODE objfpc}
{$MODESWITCH OUT}
{$MODESWITCH TYPEHELPERS}
...

sysutilh.inc
...
  function GetModuleName(Module: HMODULE): string;

type
  TGuidHelper = type helper for TGuid
//class function Create(const B: TBytes): TGUID; overload; static;
//class function Create(const S: string): TGUID; overload; static;
//class function Create(A: Integer; B: SmallInt; C: SmallInt; const D:
TBytes): TGUID; overload; static;
//class function Create(A: Integer; B: SmallInt; C: SmallInt; D, E, F,
G, H, I, J, K: Byte): TGUID; overload; static;
//class function Create(A: Cardinal; B: Word; C: Word; D, E, F, G, H,
I, J, K: Byte): TGUID; overload; static;
//class function NewGuid: TGUID; static;
//function ToByteArray: TBytes;
//function ToString: string;
  end;
...

sysutilh.inc(330,3) Error: Type TGuid cannot be extended by a type helper

I'll leave this task to you. =D

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] UTF8 RTL for Windows

2014-11-20 Thread silvioprog
On Thu, Nov 20, 2014 at 1:21 PM, Mattias Gaertner nc-gaert...@netcologne.de
 wrote:

 Hi all, especially Windows users,

 The development version of FPC 2.7.1 has extended Strings and many RTL
 functions now work for codepages other than the system codepage.

 This means Lazarus can now be compiled in two modes:

 1. The old mode: LCL treats all String as UTF-8 encoded. When
 accessing RTL and WinAPI functions you have to use the UTF8 functions.
 For example aStringList.LoadFromFile(UTF8ToSys(Filename)) and
 FileExistsUTF8. Note that UTF8ToSys only supports characters in the
 Windows code page, while FileExistsUTF8 supports the full Unicode range.

 2. The new mode: The LCL, FCL and RTL treat all String as UTF-8
 encoded. Most RTL file functions now work with full Unicode.
 For example FileExists and aStringList.LoadFromFile(Filename) now
 support full Unicode.
 AnsiToUTF8, UTF8ToAnsi, SysToUTF8, UTF8ToAnsi have no effect. Many
 UTF8Encode and UTF8Decode calls are no longer needed, because when
 assigning UnicodeString to String and vice versus the compiler does it
 automatically for you.
 When accessing the WinAPI you must use the W functions or use
 UTF8ToWinCP and WinCPToUTF8.
 You can enable the new mode by compiling Lazarus clean with
 -dEnableUTF8RTL.

 More information about the new FPC Unicode Support:
 http://wiki.freepascal.org/FPC_Unicode_support

 RTL functions that now support Unicode under Windows:
 http://wiki.freepascal.org/FPC_Unicode_support#RTL_changes

 The above links are about the default RTL with system code page.
 I want to create a Wiki page to gather all information about
 the UTF8 RTL for Lazarus users and how to adapt their code.

 Please test and tell what you find out.


 Mattias


The best news of the year! \o/ \o/ \o/

Thanks thanks thanks Lazarus/FPC team! (y)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 9:53 AM, Reimar Grabowski reimg...@web.de wrote:

 On Thu, 13 Nov 2014 11:33:58 -0300
 silvioprog silviop...@gmail.com wrote:

  I use an own TPreparedStatement (equivalent to TSQLQuery prepared +
  Params, but my structure does not uses TDataset) that I get the last
  inserted ID with (pseudo codes):
 snip
 Sorry, you lost me there, but not a problem (see my response to Marcos).

 Thanks anyway


I saw.

The problem which I see is just:

Query.SQL.Text := 'SELECT LAST_INSERT_ID() AS SomeNameIChoose;';
Query.Open;  here
ID := Query.Fields[0].AsInt64;

This approach is ugly IMHO.

So I use INSERT X (FIELDS) VALUES (PARAMS) RETURNING PK, returning the
generated ID in same SQL cursor which I used to prepare my statement. This
idea is from JDBC and I'm using it daily. Works fine in all popular SGBDs.
=)
Even when the SGBD does not provides the RETURNING feature, I use the SQL
cursor from the database driver to generate it without TDataset.Open.

My complete code works only in FPC 2.7.1+, but in short words I get the
generated ID via buffer (pointer) on database driver.

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt 
mich...@freepascal.org wrote:
[...]

 Connections for databases that have lastinsertID you can call the method
 created for this:

 Function GetInsertID: int64;

 There is a plan to let SQLDB retrieve the value of some fields fro the DB,
 but it is not implemented yet.


Awesome news! =)

Some branch to follow this new implementations? (trunk?)

Thanks!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 10:50 AM, Reimar Grabowski reimg...@web.de wrote:

 On Fri, 14 Nov 2014 14:15:08 +0100 (CET)
 Michael Van Canneyt mich...@freepascal.org wrote:

  Connections for databases that have lastinsertID you can call the method
 created for this:
 
  Function GetInsertID: int64;
 That is actually exactly what I was looking for.
 I was just too dense to realize that it belongs to the connection, not the
 query and didn't look for it there.
 Shame on me.

 Thanks a lot


+1

ID/Sequence generation must work out of transactions. It will be a nice new
feature in SQLdb! =)

Currently I use it via cursor from the database driver. It is very very
fast and is transaction independent. =)

--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 10:40 AM, Michael Van Canneyt 
mich...@freepascal.org wrote:

 On Fri, 14 Nov 2014, silvioprog wrote:

 On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt 
 mich...@freepascal.org wrote:
 [...]
   Connections for databases that have lastinsertID you can call the
 method created for this:

   Function GetInsertID: int64;

   There is a plan to let SQLDB retrieve the value of some fields fro
 the DB, but it is not implemented
   yet.


 Awesome news! =)

 Some branch to follow this new implementations? (trunk?)


 It will be implemented in trunk.


Thanks dude. I'll follow it there! (y)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 11:11 AM, Michael Van Canneyt 
mich...@freepascal.org wrote:
[...]

 By the very nature of the problem: GetLastAutoIncValue simply cannot be
 implemented in general.

 In firebird, postgres, these values are generated using a
 generator/sequence.
 You don't know the name of the generator, and even if you did, it is
 impossible to retrieve the value that was used to fill your particular
 record because the sequence/generator may have been updated several
 thousands of times by the time your second statement arrives.

 The only way to do this correctly is using a RETURNING clause when doing
 the insert.


Indded.


 The idea is to add [pfRefresh] to providerflags. When doing an insert, the
 fields with this flag will be added to the RETURNING clause and used to
 update the buffer.

 Fields of type ftautoInc can be added to this list (i.e. they automatically
 get pfRefresh in their providerflags)

 This approach will work on all SQL databases that support RETURNING.
 (That should include any SQL database available today)


Just a suggestion: it would be nice to implement it using interface or
abstract class (like ConnectionDef). So if a database X does not provide
the RETURNING support, a mortal programmer could do that by himself on
his own project. =D

E.g:

// implemented in FPC PQConnection.pas, using the RETURNING feature
TPGSequence = class(..., ISQLSequence)
..
  function GetLastId: int64;

// implemented in programmer project, using X feature
TXSequence = class(..., ISQLSequence)
..
  function GetLastId: int64;

So:

PQConnector1.SetSequencer(TPGSequence.Create);

or:

XYZConnector1.SetSequencer(TXSequence.Create);

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 11:43 AM, Michael Van Canneyt 
mich...@freepascal.org wrote:
[...]

 AFAIK Only sqlite does not (maybe it does today). But that is not a DBMS
 :-)


Yes. It would be nice execute the last_insert_rowid() to return it in the
same cursor (AFAIK, Android SDK use this mechanism in the
nativeExecuteForLastInsertedRowId). So it can be same to the MySQL
(LAST_INSERT_ID()). =)

And you can use the TSQLite3Connection.getinsertid method, no? =/

E.g in a simple raw query in MySQL:

===
INSERT INTO table_name (col1, col2,...) VALUES ('val1', 'val2'...);
SELECT LAST_INSERT_ID();

This will get you back the PRIMARY KEY value of the last row that *you*
 inserted:

The ID that was generated is maintained in the server on a *per-connection
basis*. This means that the value returned by the function to a given
client is the first AUTO_INCREMENT value generated for most recent
statement affecting an AUTO_INCREMENT column *by that client*.

So this is unaffected by other queries that might be running on the server
from other users.

S:
http://stackoverflow.com/questions/17112852/get-the-new-record-primary-key-id-from-mysql-insert-query
===

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 11:47 AM, Michael Van Canneyt 
mich...@freepascal.org wrote:
[...]

 I was planning some fallback mechanism, yes. And a class function
 SupportReturningClause : Boolean or something similar.
 Or maybe

 TDBCapability = (lastID,returningclause);
 TDBCapabilities = set of TDBCapability;

 and

 Class function DatabaseCapabilities : TDBCapabilities;

 I don't really like using interfaces when things can be done more simple.


Good too dude. =)

Protected virtual methods would be welcome too. =)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 12:49 PM, silvioprog silviop...@gmail.com wrote:

 On Fri, Nov 14, 2014 at 11:43 AM, Michael Van Canneyt 
 mich...@freepascal.org wrote:
 [...]

 AFAIK Only sqlite does not (maybe it does today). But that is not a DBMS
 :-)


 Yes. It would be nice execute the last_insert_rowid() to return it in
 the same cursor (AFAIK, Android SDK use this mechanism in the
 nativeExecuteForLastInsertedRowId). So it can be same to the MySQL
 (LAST_INSERT_ID()). =)

 And you can use the TSQLite3Connection.getinsertid method, no? =/


It works fine in SQLite (my test table have ten records and test2 one
record):

procedure TForm1.Button1Click(Sender: TObject);
var
  id1, id2: Int64;
begin
  SQLQuery1.Close;
  SQLQuery1.SQL.Text := 'insert into test (foo) values (''TEST'')';
  SQLQuery1.ExecSQL;
  id1 := SQLite3Connection1.GetInsertID;

  SQLQuery2.Close;
  SQLQuery2.SQL.Text := 'insert into test2 (foo) values (''TEST'');';
  SQLQuery2.ExecSQL;
  id2 := SQLite3Connection1.GetInsertID;

  ShowMessageFmt('ID1: %d; ID2: %d', [id1, id2]);
end;

[Window Title]
project1

[Content]
ID1: 11; ID2: 2

[OK]

I'll test it in MySQL ...

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 3:23 PM, Michael Van Canneyt mich...@freepascal.org
 wrote:

 On Fri, 14 Nov 2014, Reimar Grabowski wrote:

 On Fri, 14 Nov 2014 14:50:20 +0100
 Reimar Grabowski reimg...@web.de wrote:

  On Fri, 14 Nov 2014 14:15:08 +0100 (CET)
 Michael Van Canneyt mich...@freepascal.org wrote:

  Connections for databases that have lastinsertID you can call the
 method created for this:

 Function GetInsertID: int64;

 Unfortunately it does not work and returns only 0, while my custom query
 using LAST_INSERT_ID() works as expected.
 Debugging this is very hard as Lazarus crashes on me left and right when
 trying to step through the code and an exception is encountered.
 I have one connection, one transaction and some queries bound to them on
 a FPWebModule.

 ID1:=MySQL55Connection1.GetInsertID;
 SQLQuery1.Open;
 ID2:=SQLQuery1.FieldByName('LastInsertID').AsLargeInt;

 ID1 is 0 and ID2 the correct id value.

 Any ideas what I could be doing wrong?


 This is what it does:

 function TConnectionName.GetInsertID: Int64;
 begin
   CheckConnected;
   Result:=mysql_insert_id(GetHandle);
 end;

 a) Did you do an insert right before the call to GetInsertID ?
 b) Is the transaction active after the insert ? c) The connection
 transaction should be the same as the transaction of the insert.


Work fine here (MySQL 5.5 32 bits / Lazarus 1.2.6 r46529 FPC 2.6.4
i386-win32-win32/win64 / Windows 7 64 bits):

unit1.lfm:

object Form1: TForm1
  Left = 238
  Height = 240
  Top = 144
  Width = 320
  Caption = 'Form1'
  ClientHeight = 240
  ClientWidth = 320
  LCLVersion = '1.2.6.0'
  object Button1: TButton
Left = 10
Height = 25
Top = 8
Width = 75
Caption = 'Button1'
OnClick = Button1Click
TabOrder = 0
  end
  object MySQL55Connection1: TMySQL55Connection
Connected = False
LoginPrompt = False
DatabaseName = 'test'
KeepConnection = False
Password = 'root'
Transaction = SQLTransaction1
UserName = 'root'
HostName = '127.0.0.1'
LogEvents = []
left = 40
top = 16
  end
  object SQLQuery1: TSQLQuery
FieldDefs = 
Database = MySQL55Connection1
Transaction = SQLTransaction1
Params = 
left = 88
top = 116
  end
  object SQLTransaction1: TSQLTransaction
Active = False
Database = MySQL55Connection1
left = 147
top = 45
  end
end

...

unit1.pas:

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  SysUtils, mysql55conn, sqldb, Forms, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
Button1: TButton;
MySQL55Connection1: TMySQL55Connection;
SQLQuery1: TSQLQuery;
SQLTransaction1: TSQLTransaction;
procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  SQLQuery1.SQL.Text := 'insert into test (foo) values (:foo)';
  SQLQuery1.Params.ParamByName('foo').AsString := DateTimeToStr(Now);
  SQLQuery1.ExecSQL;
  ShowMessageFmt('%d', [MySQL55Connection1.GetInsertID]);
end;

end.

Result after three clicks:

[Window Title]
project1

[Content]
4

[OK]

SQL:

-- phpMyAdmin SQL Dump
-- version 4.2.11
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: 14-Nov-2014 às 17:09
-- Versão do servidor: 5.5.40
-- PHP Version: 5.3.21

SET SQL_MODE = NO_AUTO_VALUE_ON_ZERO;
SET time_zone = +00:00;

--
-- Database: `test`
--

-- 

--
-- Estrutura da tabela `test`
--

CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) NOT NULL,
  `foo` varchar(20) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `test`
--
ALTER TABLE `test`
 ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `test`
--
ALTER TABLE `test`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 8:32 PM, Marco van de Voort mar...@stack.nl wrote:

 On Fri, Nov 14, 2014 at 03:11:30PM +0100, Michael Van Canneyt wrote:
 
  By the very nature of the problem: GetLastAutoIncValue simply cannot be
 implemented in general.
 
  In firebird, postgres,

 (and Oracle afaik)

  these values are generated using a generator/sequence.
  You don't know the name of the generator, and even if you did, it is
 impossible
  to retrieve the value that was used to fill your particular record
 because the
  sequence/generator may have been updated several thousands of times by
 the time
  your second statement arrives.

 IIRC the currval from a sequence  is per session, so if you didn't insert
 again in the same transaction that is ok too.

 Moverover there is lastval to avoid knowing the sequence name

 from http://www.postgresql.org/docs/8.4/static/functions-sequence.html

 lastval

 Return the value most recently returned by nextval in the current
 session. This function is identical to currval, except that instead of
 taking the sequence name as an argument it fetches the value of the last
 sequence used by nextval in the current session. It is an error to call
 lastval if nextval has not yet been called in the current session.


And PostgreSQL provides the RETURNING feature too. =)

--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-13 Thread silvioprog
On Thu, Nov 13, 2014 at 11:07 AM, Reimar Grabowski reimg...@web.de wrote:

 Hi,

 first of all I am new to using Lazarus/FPC for database communication.
 I have set up my database connection, transaction and queries via the
 Object Inspector and all is working as it should. But I have a little
 problem getting the PK value of a newly inserted record (the PK field is an
 auto-incremented one).
 Actually it's not really a problem, I just don't like the way I do it and
 found no better one.

 Here is some code:

 SQLQuery.Insert;
 SQLQuery.FieldByName('SomeField').AsString:=SomeValue;
 SQLQuery.FieldByName('AnotherField').AsString:=AnotherValue;
 ... (setting more fields)
 SQLQuery.Post;
 SQLQuery.ApplyUpdates;
 SQLTransaction.Commit;
 // Now the part I don't like
 SQLQuery.Close;
 SQLQuery.Params.ParamByName('SomeField').AsString:=SomeValue;
 SQLQuery.Params.ParamByName('AnotherField').AsString:=AnotherValue;
 ... (setting more params, the same as the fields in the insert)
 SQLQuery.Open;
 NewID:=SQLQuery.FieldByName('AutoIncrementedPrimaryKey').AsInteger;

 It seems to work but it's IMHO not very nice.
 Ideally I'd like to have TSQLQuery do it for me and offer me some property
 like SQLQuery.LastInsertID or something along those lines.
 Is there any way to get the new PK value without manually querying for the
 inserted record?

 BTW the wiki (http://wiki.freepascal.org/Working_With_TSQLQuery) mentions
 that you should send 0 for the ID and add an appropriate 'ON DUPLICATE KEY'
 phrase to your SQL. I did not do this. I just omitted the ID in my
 SQLQuery.InsertSQL and AFAICT it works flawlessly.

 R.


I use an own TPreparedStatement (equivalent to TSQLQuery prepared +
Params, but my structure does not uses TDataset) that I get the last
inserted ID with (pseudo codes):

[code]
uses
  Core.SQL.PreparedStatement, ...

  VStmt := TPreparedStatementTMyObject.Create;
  ID := VStmt.Execute; // get last inserted ID instead of rowsaffected
[/code]

or:

[code]
  VStmt := TPreparedStatementTMyObject.Create;
  ID := VStmt.Execute.Values.ID; // get last inserted ID
[/code]

or:

[code]
uses
  Core.SQL.ConnectionFactory, ...

  PK := TConnectionFactory.GetInstance(Context).Insert(MyObject);
[/code]

or:

[code]
  TConnectionFactory.GetInstance(Context).Insert(MyObject);
  WriteLn('The generated ID is: ', MyObject.Id);
[/code]

or with on conflict:

[code]
  TConnectionFactory.GetInstance(Context).UpdateWithOnConflict(MyObject,
TConnection.CONFLICT_REPLACE);
  WriteLn('The generated or existing ID is: ', MyObject.Id);
[/code]

I'll send it soon to the Github. =)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Detecting if a remote web server is running

2014-10-30 Thread silvioprog
On Thu, Oct 30, 2014 at 6:44 AM, Richard Mace richard.m...@gmail.com
wrote:

 Hi All,
 What's the most reliable way of detecting whether a remote website is
 responding?


Get the HTTP headers:

uses
  fphttpclient;

procedure TForm1.Button1Click(Sender: TObject);
var
  VHttp: TFPHTTPClient;
  VHeaders: TStrings;
begin
  VHttp := TFPHTTPClient.Create(nil);
  VHeaders := TStringList.Create;
  try
VHttp.RequestHeaders.Add('Connection: Close');
VHttp.Head('http://lazarus.freepascal.org', VHeaders);
if VHeaders.Count  0 then
  ShowMessage('OK')
else
  ShowMessage('Fail');
  finally
VHeaders.Free;
VHttp.Free;
  end;
end;

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Detecting if a remote web server is running

2014-10-30 Thread silvioprog
On Thu, Oct 30, 2014 at 11:39 AM, waldo kitty wkitt...@windstream.net
wrote:

 On 10/30/2014 7:29 AM, Felipe Monteiro de Carvalho wrote:

 On Thu, Oct 30, 2014 at 10:44 AM, Richard Mace richard.m...@gmail.com
 wrote:

 Hi All,
 What's the most reliable way of detecting whether a remote website is
 responding?

 
  maybe ping?

 ping might tell you if the IP address is active but that's all... it won't
 tell you if the server is running or servicing requests... you have to
 request something from the server to see if it is servicing requests... the
 easiest and smallest would be to request the headers (only) from the root...


+1

Like this:
http://lists.lazarus.freepascal.org/pipermail/lazarus/2014-October/089112.html

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TPQConnection.CreateDB: ENCODING, OWNER, TEMPLATE, LC_CTYPE, TABLESPACE

2014-10-29 Thread silvioprog
On Tue, Oct 28, 2014 at 8:19 AM, Reinier Olislagers 
reinierolislag...@gmail.com wrote:

 On 28/10/2014 02:03, silvioprog wrote:
  Today I fixed that using a mix of codes: creating the database using
  the original postgre driver for Java, and calling java -jar create_mydb
  params via TProcess. Now it worked like a charm!

 Please don't raise a bug tracker issue... especially one with a simple
 sample program and PostgreSQL DDL so the issue is easily reproducible
 for devs.


Oopss... sorry, I'll do that dude. =)


 It's much better to keep using a workaround using another programming
 language and letting other programmers potentially face the same problem
 than getting it fixed in a newer version of FPC.
 /sarcasm


Yes, but I needed to fix the problem urgently, and unfortunatelly with
SQLdb doesn't worked. =( The final (quick workaround) code was:

procedure TCriadorBanco.Criar(const ADatabase, AOwner, AUser, APassword,
  ALocale, ATemplate: string);
var
  VJavaExe: string;
  VProcess: TProcess;
  VResult: TStringList;
begin
  VJavaExe :=
{$IFDEF MSWINDOWS}
IncludeTrailingPathDelimiter(GetEnvironmentVariable('JAVA_HOME'))
{$ELSE}
'/usr/'
{$ENDIF};
  VJavaExe += 'bin' + DirectorySeparator + path.JAVA_EXE;
  if not FileExists(VJavaExe) then
raise ECriadorBanco.CreateFmt(
  'Executável do Java não encontrado: %s.', [VJavaExe]);
  if not FileExists(path.CREATE_DB_JAR) then
raise ECriadorBanco.CreateFmt(
  'Arquivo JAR não encontrado: %s.', [path.CREATE_DB_JAR]);
  VProcess := TProcess.Create(nil);
  VResult := TStringList.Create;
  try
VProcess.Executable := path.JAVA_EXE;
VProcess.Options := VProcess.Options + [poWaitOnExit, poUsePipes,
  poStderrToOutPut];
VProcess.Parameters.Add('-jar');
VProcess.Parameters.Add(path.CREATE_DB_JAR);
VProcess.Parameters.Add('-d=' + ADatabase);
VProcess.Parameters.Add('-o=' + AOwner);
VProcess.Parameters.Add('-u=' + AUser);
VProcess.Parameters.Add('-p=' + APassword);
VProcess.Parameters.Add('-l=' + ALocale);
VProcess.Parameters.Add('-t=' + ATemplate);
VProcess.Execute;
VResult.LoadFromStream(VProcess.Output);
if (VResult.Count = 2) and (VResult[0] = 'Role successfully created')
and
  (VResult[1] = 'Database successfully created') then
else
  raise ECriadorBanco.Create(Trim(VResult.Text));
  finally
VResult.Free;
VProcess.Free;
  end;
end;


 PS: Glad you did find a workaround but... well...


=P~ =D

--
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


  1   2   3   4   5   6   7   8   >