Re: [fpc-pascal] Ho to convert a special format of datetime?

2018-12-13 Thread luciano de souza
Marco, Sílvio, thank you both. Since a ready function is available, I
used RF3339ToDatetime. I received lots of warnings about a possible
lost of data due to a string conversion from widestring to ansistring.
However, dispite the warnings, the result was perfect.
I didn't know scandatetime. Freepascal always present to us some
pleasant surprisses.

2018-12-13 18:07 GMT-02:00, luciano de souza :
> Hello all,
> I'd like to convert this date "2017-01-11T17:47:22.2912317-02:00" to
> TDatetime.
> It seems probably it exists in Freepascal, but I don't know.
> So, I ask, how to suply a date in this format and get a TDatetime?
> I found it in a XPDL file representing a flowchart and I don't know
> how to do it easily.
> I thank you for any help.
> Best Regards,
>
> --
> Luciano de Souza
>


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

[fpc-pascal] Ho to convert a special format of datetime?

2018-12-13 Thread luciano de souza
Hello all,
I'd like to convert this date "2017-01-11T17:47:22.2912317-02:00" to TDatetime.
It seems probably it exists in Freepascal, but I don't know.
So, I ask, how to suply a date in this format and get a TDatetime?
I found it in a XPDL file representing a flowchart and I don't know
how to do it easily.
I thank you for any help.
Best Regards,

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

Re: [fpc-pascal] Running tests with FPC units only

2018-11-11 Thread luciano de souza
What a shame! I shouldn't be so inattentive! Sorry, you are completely right!

2018-11-11 16:57 GMT-02:00, leledumbo via fpc-pascal
:
>> acording example I found in FPC examples directory,
>
> Check the one here instead:
> $(fpcsrcdir)/packages/fcl-fpcunit/src/demo/consolerunner/testrunner.pp
> It depends only on FPC units. I guess you're looking at examples from
> Lazarus directory instead of FPC.
>
>
>
> --
> Sent from: http://free-pascal-general.1045716.n5.nabble.com/
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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

[fpc-pascal] Running tests with FPC units only

2018-11-11 Thread luciano de souza
Hello hall,
I am blind, so I don't use Lazarus. In pure Freepascal, I tried to run
an example test:

program tester;
{$mode objfpc}{$H+}

uses
fpcunit, testregistry;

type
TMyTest = class(TTestCase)
published
procedure TestSomething;
end;

procedure TMyTest.TestSomething;
begin
AssertEquals(1, 1);
end;

BEGIN
RegisterTest(TMyTest);
END.

This code compiles, but doesn't do anything. Here tests were only
registered, not run.
For this purpose, acording example I found in FPC examples directory,
I need the class TTestRunner.

BEGIN
with TTestRunner.create(nil) do
begin
try
initialize;
run;
finally
free;
end;
end;
END.

However, TTestRunner belongs to consoletestrunner, a non Freepascal unit.
I imagine there is a way to run tests only with Freepascal units. But
how to do this without consoletestrunner, a unit found in Lazarus?
Best regards,

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

Re: [fpc-pascal] Pascal units to connect to an Exchange server

2018-07-20 Thread luciano de souza
Perhaps, this is the answer. In Outlook settings, I am not able to find SMTP.
I got the url server and some proxy settings. NTLM was one of parameters set.
If I don't have an SMTP endpoint, could I create a crawler to automate
the http connection available in Outlook Web App? In other words,
since I am able to use a web page to send e-mails, it's always true
that I can automate it, can't I?
In this case, I should study the requests and responses and, by means
of TFPHTTPVClient, to build something.

2018-07-19 16:51 GMT-03:00, Bo Berglund :
> On Thu, 19 Jul 2018 15:29:12 -0300, luciano de souza
>  wrote:
>
>>Hello all,
> >From a Linux machine connected to a Windows machine by VPN, I’d like
>>to send e-mails programmatically using a Microsoft Exchange account.
>>Using Windows resources, I could call Outlook automation API to do
>>this task. But is the same possible with Linux resources?
>>Is there a Freepascal unit to handle with Exchange sending protocol?
>>Best Regards,
>
> Why not just use somethng like Indy10 to implement an smtp sending
> function?
> It is quite simple and straightforward.
> What exactly are you wanting to accomplish by mixing in Exchange and
> Outlook?
>
>
> --
> Bo Berglund
> Developer in Sweden
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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

[fpc-pascal] Pascal units to connect to an Exchange server

2018-07-19 Thread luciano de souza
Hello all,
From a Linux machine connected to a Windows machine by VPN, I’d like
to send e-mails programmatically using a Microsoft Exchange account.
Using Windows resources, I could call Outlook automation API to do
this task. But is the same possible with Linux resources?
Is there a Freepascal unit to handle with Exchange sending protocol?
Best Regards,


-- 
Luciano de Souza

Hello all,
From a Linux machine connected to a Windows machine by VPN, I’d like
to send e-mails programmatically using a Microsoft Exchange account.
Using Windows resources, I could call Outlook automation API to do
this task. But is the same possible with Linux resources?
Is there a Freepascal unit to handle with Exchange sending protocol?
Best Regards,
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Replacing parts of a string with TRegexpr

2018-02-22 Thread luciano de souza
I am blind and it's not so easy to read the source code with so many comments.
Dispite this, I find the method "TRegexpr.replace", accepting as the
first argument the input string and the second the template string.
The return is what I want.
In other words, the problem is solved and anything else is needed!
Sorry for the unnecessary question!

2018-02-22 10:38 GMT-03:00, luciano de souza <luchya...@gmail.com>:
> Hello all,
> I'd like to replace some part of a string acording to a pattern.
> I know how to search and print the matches of a ER:
>
> program test;
> {$mode objfpc}{$H+}
>
> uses
> regexpr;
>
> var
> r: TRegexpr;
>
> BEGIN
> r := TRegexpr.create('(\d+)');
> try
> if r.exec('01 Brazil, 02 USA, 03 China') then
> begin
> repeat
> writeln(r.match[0]);
> until not r.ExecNext;
> end
> else
> writeln('Pattern not found');
> finally
> r.free;
> end;
> END.
>
> But how could I to substitute all "(\d+)", for example, to "xx".
> The regexpr unit has some documentation in its source code, but
> dispite this, I was not able to understand how to do it.
>
> --
> Luciano de Souza
>


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

[fpc-pascal] Replacing parts of a string with TRegexpr

2018-02-22 Thread luciano de souza
Hello all,
I'd like to replace some part of a string acording to a pattern.
I know how to search and print the matches of a ER:

program test;
{$mode objfpc}{$H+}

uses
regexpr;

var
r: TRegexpr;

BEGIN
r := TRegexpr.create('(\d+)');
try
if r.exec('01 Brazil, 02 USA, 03 China') then
begin
repeat
writeln(r.match[0]);
until not r.ExecNext;
end
else
writeln('Pattern not found');
finally
r.free;
end;
END.

But how could I to substitute all "(\d+)", for example, to "xx".
The regexpr unit has some documentation in its source code, but
dispite this, I was not able to understand how to do it.

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

Re: [fpc-pascal] Using the LCL without Lazarus

2016-12-01 Thread luciano de souza
Yes, this is a very good feature. As I can't see, the single way to
not extrapass the space is the automatic layout.
To become perfect, it would be fantastic if there is also automatic
positioning like in Wx or GTK.
In these tool kits, we can add a box or a sizer to the form. When you
add elements, as buttons, to the boxes, they are automatically
positioned on left, if is a horizontal box, or in the top, if it is a
vertical box.
There are something like this in LCL. If yes, the solution will be perfect.
The result don't need to become beautifull since I am blind, but if
elements are positioned over elements, perhaps the screen reader read
incorrectly.
What you have shown is very simple! Thank you!

2016-12-01 15:04 GMT-02:00, Mattias Gaertner <nc-gaert...@netcologne.de>:
> On Thu, 1 Dec 2016 14:57:42 -0200
> luciano de souza <luchya...@gmail.com> wrote:
>
>> I am also blind and this topic really interesses me.
>> In the given example, heith and width were specified in pixels.
>> Is there a way to write the same example using automatic adjustments,
>> in other words, setting to the layout incresing or decreasing in the
>> proporcion of the label writen?
>
> Yes. For example:
>
> With Form1.Button1 Do
> begin
>   Left := 10;
>   Top := 10;
>   AutoSize := true;
>   Caption := 'PRESS ME';
>   Parent := Form1;
> end;
>
> Mattias
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>


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


Re: [fpc-pascal] Using the LCL without Lazarus

2016-12-01 Thread luciano de souza
s.
>
>  End web-site excerpt 
>
> 1. I have FPC ver 3.0.0 and Lazarus ver 1.6
> Should the instructions given in the excerpt be applicable with these
> versions, as well?
>
> 2. Is it safe to assume that when they say
> "You are not forced to use the Lazarus IDE if you want to develop with the
> LCL. You can use it directly from the Free Pascal Compiler."
> that they mean that the source code can be submitted to FPC at the command
> line?
>
> 3. As I stated somewhere above, the FP IDE is not accessable at a practical
> level so, is there some other way that I can satisfy the requirements to do
> the following?
>
> Start the FP IDE (included with FPC).
> Click on the Options menu and then the Directories menu item.
> Select the Units tab (default).
> Add these directories:
> C:\FPC\2.4.4\units\i386-win32\lcl
> C:\FPC\2.4.4\units\i386-win32\lcl\units\i386-win32
> C:\FPC\2.4.4\units\i386-win32\lcl\widgetset
> C:\FPC\2.4.4\units\i386-win32\lcl\interfaces\win32
> Then click on the Include files tab.
> Add this directory:
> C:\FPC\2.4.4\units\i386-win32\lcl\include
> Now, you should be able to use the LCL.
>
>
> If the answers to my questions #1 & #2 are in the affirmative, and if the
> paths described in my question #3 can be added to the Windows search path or
> inserted into a *.ini file or somewhere else, perhaps I can give it a go.
>
> I apologize for such a lengthy message but, I didn't know how else to make
> clear my dilemma.
>
> Thanks,
>
> Bob
>
>


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


Re: [fpc-pascal] The testcase example doesn't generate plain text report

2016-11-16 Thread luciano de souza
Graeme,
Between my message and yours, I found your TestFramework. It worked
imediately, I liked, so I changed from FPCUnit to TestFramework.
In examples, I used check, checkequals, fail... Excelent! The single
feature I couldn't understand is "CheckException".
I have this code:

procedure TGroupTest.InsertRecord;
begin
FGroup.name = 'Geography';
FMapper.add(FGroup);
FMapper.apply;
end;

An exception can be raised in "FMapper.apply", but I could understand
the usage of CheckException.
The TestFramework, running only with this code, says that no errors
were found, but alerts to the fact that no tests were done in this
method of the Testcase.

2016-11-15 7:06 GMT-02:00, luciano de souza <luchya...@gmail.com>:
> Hello all,
> I am trying to run testcases.
> For testing the idea, I compile the example contained in:
>
> ./fpc-3.0.0/packages/fcl-fpcunit
>
> The compilation was successful.
>
> As I am blind, the XML format is very unpleasant becose the output is
> too verbose.
>
> So I runned the test with the following commandline:
>
> ./testrunner -a --format=plain
>
> However, the output produced was in XML.
>
> What am I doing wrong.
>
> See the output:
>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 62
> 0
> 0
> 
>
>
>
> --
> Luciano de Souza
>


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


[fpc-pascal] The testcase example doesn't generate plain text report

2016-11-15 Thread luciano de souza
Hello all,
I am trying to run testcases.
For testing the idea, I compile the example contained in:

./fpc-3.0.0/packages/fcl-fpcunit

The compilation was successful.

As I am blind, the XML format is very unpleasant becose the output is
too verbose.

So I runned the test with the following commandline:

./testrunner -a --format=plain

However, the output produced was in XML.

What am I doing wrong.

See the output:






























































































































62
0
0




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


[fpc-pascal] Writing DLLs to by used in Excel VBA code

2015-12-11 Thread luciano de souza
Hello all,

I want to use a DLL writen in Pascal to provide functions for a Excel VBA code:

The example code of my DLL is:
library CE;
{$mode objfpc}

uses
Sysutils;

function level(x1, x2: integer): integer; cdecl; export;
begin
result := x1 + 2*x2;
end;


exports
level name 'level';
end.

In VBA, I did the following code:


Public Declare Function dlevel Lib "CE" Alias "level" (ByVal x1 As
Integer, ByVal x2 As Integer) As Integer

Function nivel(ByVal x1 As Integer, ByVal x2 As Integer) As Integer
nivel = dlevel(x1, x2)
End Function

In the sheet, I did:

=nivel(2;5)

And I got:
#value

I really don't know what to do. Seemlngly, VBA code is correct. I
don't know so much about DLLs, would be possible to have a mistake in
my Pascal code?

Does someone have any idea?

Best regards,


-- 
Luciano de Souza
library CE;
{$mode objfpc}

uses
Sysutils;

function level(x1, x2: integer): integer; cdecl; export;
begin
result := x1 + 2*x2;
end;


exports
level name 'level';

end.

CE.xlsm
Description: application/vnd.ms-excel.sheet.macroenabled.12
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Searching recursively for units in a path

2015-12-05 Thread luciano de souza
It works partially.

broker.pas declare brookfclhttpappbroker.pas, but it was not found:

In fpc.cfg, I tried:

"-Fu./Globals/*"

The compiler said it is an illegal parameter, so I took off the quotes.

-Fu./Globals/*"

It was found ./Globals/Seetings/brokers.pas. It's Ok, but when
compiling brokers.pas,
./Globals/Components/Brook/brookfclhttpappbroker.pas was not found.

Perhaps, it's better to have the work of declaring everything individually.

2015-12-05 9:52 GMT-02:00, Michael Van Canneyt <mich...@freepascal.org>:
>
>
> On Sat, 5 Dec 2015, luciano de souza wrote:
>
>> Hello all,
>>
>> On the commandline or in fpc.cfg, I can include search paths as:
>>
>> fpc test.pp -Fu./Componentes
>>
>> But ./Components has a world of subfolders. So I imagine I could
>> indicates all subfolders as:
>>
>> fpc test.pp -Fu./Componentes/*
>>
>> It does not work, so I ask: is there a way to indicates subfolders
>> recursively with -Fu?
>
> You can, but you must quote the path, otherwise the shell will attempt to
> quote it:
>   fpc test.pp "-Fu./Componentes/*"
>
> That should work.
> If you look in the config file fpc.cfg generated by FPC, you will see that
> this technique is used there.
>
> Michael.
> ___________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>


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


[fpc-pascal] Searching recursively for units in a path

2015-12-05 Thread luciano de souza
Hello all,

On the commandline or in fpc.cfg, I can include search paths as:

fpc test.pp -Fu./Componentes

But ./Components has a world of subfolders. So I imagine I could
indicates all subfolders as:

fpc test.pp -Fu./Componentes/*

It does not work, so I ask: is there a way to indicates subfolders
recursively with -Fu?
-- 
Luciano de Souza
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Cryptography with Blowfish

2015-12-01 Thread luciano de souza
Problem solved. A friend advert me to the fact I can't use the  same
TMemoryStream for input and output.

This is the correct code:

program test;
{$mode objfpc}{$H+}

uses
blowfish, classes;

var
VInput, VOutput: TMemoryStream;
VCypher: TBlowfishEncryptStream;
BEGIN
VInput := nil;
VOutput := TMemoryStream.create;
VCypher := TBlowfishEncryptStream.create('lazarus-br', VOutput);
try
VInput := TMemoryStream.create;
VInput.LoadFromFile('origin.txt');
VCypher.writebuffer(VInput.memory, VInput.size);
VOutput.SaveToFile('output.bfe');
finally
VCypher.free;
VInput.free;
VOutput.free;
end;
END.

2015-12-01 17:57 GMT-02:00, luciano de souza <luchya...@gmail.com>:
> Hello all,
>
> What's wrong with this code?
>
> I try to cryptograph a file. The compiler doesn't raise errors, but
> after running the program, no results happen.
>
> program test;
> {$mode objfpc}{$H+}
>
> uses
> blowfish, classes;
>
> var
> VMemory: TMemoryStream;
> VCypher: TBlowfishEncryptStream;
> BEGIN
> VMemory := TMemoryStream.create;
> VMemory.LoadFromFile('origin.txt');
> VCypher := TBlowfishEncryptStream.create('lazarus-br', VMemory);
> try
> VMemory.position := 0;
> VCypher.write(VMemory.memory, VMemory.size);
> VMemory.SaveToFile('output.bfe');
> finally
> VCypher.free;
> VMemory.free;
> end;
> END.
>
> --
> Luciano de Souza
>


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


[fpc-pascal] Cryptography with Blowfish

2015-12-01 Thread luciano de souza
Hello all,

What's wrong with this code?

I try to cryptograph a file. The compiler doesn't raise errors, but
after running the program, no results happen.

program test;
{$mode objfpc}{$H+}

uses
blowfish, classes;

var
VMemory: TMemoryStream;
VCypher: TBlowfishEncryptStream;
BEGIN
VMemory := TMemoryStream.create;
VMemory.LoadFromFile('origin.txt');
VCypher := TBlowfishEncryptStream.create('lazarus-br', VMemory);
try
VMemory.position := 0;
VCypher.write(VMemory.memory, VMemory.size);
VMemory.SaveToFile('output.bfe');
finally
VCypher.free;
VMemory.free;
end;
END.

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


[fpc-pascal] Implementing Factory Method with Pascal

2015-11-27 Thread luciano de souza
Hello all,

I'd like to understand how to implement the Factory Method pattern in Pascal.

In my example, there are four classes:
1. TAnimal - The parent and abstract class;
2. TDog and TCat - The specialized classes;
3. TAnimalFactory - The class which creates instances of animals,
having received a enumerator as a parameter.

The method "live" is common to TAnimal, Tdog and TCat. However, "bark"
is found only in TDog.

In the following code, the compiler says that animal does not
possesses "bark" as a method. It's right. The behaviour is implemented
only in the derived class.

But, if this not works, how to implement the Factory Method in Freepascal?

program test;
{$mode objfpc}{$H+}

uses
tsbase;

var
animal: TAnimal;
BEGIN
animal := TAnimalFactory.create(atDog);
try
animal.bark; // Here is the error. If the call were "animal.live, no
errors would be shown. The code does not fails with (animal as
TDog).bark, but it does not make sense. The factory should allow to
create the instance only with the enumerator, without casting.

finally
animal.free;
end;
END.

unit tsbase;
{$mode objfpc}{$H+}

interface
type
TAnimal = class(TObject)
public
procedure live; virtual; abstract;
end;

TDog = class(TAnimal)
public
procedure live; override;
procedure bark;
end;

TCat = class(TAnimal)
public
procedure live; override;
end;

TAnimalType = (atDog, atCat);

TAnimalFactory = class(TObject)
public
class function create(AType: TAnimalType):TAnimal;
end;

implementation
{TDog}
procedure TDog.live;
begin
writeln('Um cachorro vive');
end;

procedure TDog.bark;
begin
writeln('Um cachorro foge');
end;

{TCat}
procedure TCat.live;
begin
writeln('Um gato vive');
end;

{TAnimalFactory}
class function TAnimalFactory.create(AType: TAnimalType):TAnimal;
begin
case AType of
atDog: result := TDog.create;
atCat: result := TCat.create;
end;
end;

end.

Well, I am studying design patterns, but I really does not understand
how to solve this problem.

I thank you for any tip.

Best regards,

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


Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-27 Thread luciano de souza
Marcos,

Your answer and the excelent article of Graeme clarify the question.

If I want to change the type of the instance, better is to use
generics. A factory is only a batch builder of the same objects.

Graeme, your article opened my mind. The mappings and the registers
caused me a very strong impression. Thank you!
2015-11-27 21:48 GMT-02:00, Marcos Douglas <m...@delfire.net>:
> On Fri, Nov 27, 2015 at 7:44 PM, luciano de souza <luchya...@gmail.com>
> wrote:
>> If I need to do "TAnimalFactory.create(atDog) as Tdog", perhaps, it
>> would be better not to use a factory, doing simply "TDog.create".
>
> You're right, use simply TDog.Create.
> Why do you have a factory to create different types of animals
> (classes)? Doesn't make sense. If you need a factory, you should use a
> factory for dogs, another for cats and so on.
> Another tip: Factories resolve some problems but there is a cost. The
> factory will creates your instance (object) but it know only one
> constructor, ie, the base class constructor.
> Objects should be immutable at first place, only if you have a good
> reason for don't use immutability. So, if they should be immutable,
> you have only the constructor to instantiate your object, passing
> arguments for it. If you have a constructor without arguments (using a
> base class for example), you won't pass arguments to instantiate your
> classe properly.
> Another tip: use interfaces, not inheritance. Inheritance is evil. You
> always will have problems using inheritance. Instead, use small
> objects with few methods (2-5) to resolve just one problem. You don't
> need inheritance for that. Your code will be more simpler and
> customizable.
> Decorator Pattern is more powerful than inheritance. Read about it.
>
> Best regards,
>
> Marcos Douglas
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>


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


[fpc-pascal] Persistent list to store objects

2015-08-17 Thread luciano de souza
Hello all,

There are several classes which manages lists. TCollection,
TObjectlist, TFPGObjectlist... Does someone know if one of then can be
saved as a file and reloaded again to an object?

Regards,

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


Re: [fpc-pascal] Writing a DLL to be use in a VBA code

2015-06-06 Thread luciano de souza
Thank you for the always rapid and gentile reply. Well, if there's no
way to avoid pchar, let's go to pchar!

2015-06-06 4:27 GMT-03:00, Michael Van Canneyt mich...@freepascal.org:


 On Sat, 6 Jun 2015, luciano de souza wrote:

 Hello all,

 At work, I need to create a Excel sheet containing certain more
 complex functions. I tried to use only VBA, but I released I will more
 productive if I could use a DLL writen in Pascal for the heavier code.

 Let see this DLL:

 library test;
 {$mode objfpc}{$H+}

 function concatenate(name: string): string; cdecl;
 begin
 result := 'Freepascal ' + name;
 end;

 function first(names: array of string):string; cdecl; // Warning:
 cdecl'ared functions have no high parameter

 I very much doubt VBA understands the 'array of string' concept.
 It is typical for pascal.

 begin
 result := names[0];
 end;

 exports
 concatenate;
 first;
 end.

 The compiler also raised this error: test.pas(10,1) Fatal: Internal
 error 201003031.

 I don't know what I am doing wrong. But actually, the reason of my
 message started from another point.

 Freepascal codes works with strings as usual. DLLs works with pchar. I
 could have declared the functions as the following:

 function concatenate(name: pchar): pchar; cdecl;
 function first(names: array of pchar): pchar; cdecl;

 I think you need to use stdcall calling convention.


 In the body of the functions, I would treat the conversions from pchar
 to string and from string to pchar again. But, when I used cdecl, am
 I making this conversion automatically? Is there a compilation switch
 that allows me to write strings and the compiled code having correctly
 treated the allocations and disallocation of strings?

 No, there is not.


 Suppose this VBA code:

 public declare function concatenate lib test (name as string) as string

 Is this the correct way to write the called function in Freepascal?

 function concatenate(name: string): string; cdecl;
 begin
 result := 'Freepascal ' + name;
 end;

 No, IMHO you will need to use pchar everywhere.

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



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


[fpc-pascal] Writing a DLL to be use in a VBA code

2015-06-06 Thread luciano de souza
Hello all,

At work, I need to create a Excel sheet containing certain more
complex functions. I tried to use only VBA, but I released I will more
productive if I could use a DLL writen in Pascal for the heavier code.

Let see this DLL:

library test;
{$mode objfpc}{$H+}

function concatenate(name: string): string; cdecl;
begin
result := 'Freepascal ' + name;
end;

function first(names: array of string):string; cdecl; // Warning:
cdecl'ared functions have no high parameter
begin
result := names[0];
end;

exports
concatenate;
first;
end.

The compiler also raised this error: test.pas(10,1) Fatal: Internal
error 201003031.

I don't know what I am doing wrong. But actually, the reason of my
message started from another point.

Freepascal codes works with strings as usual. DLLs works with pchar. I
could have declared the functions as the following:

function concatenate(name: pchar): pchar; cdecl;
function first(names: array of pchar): pchar; cdecl;

In the body of the functions, I would treat the conversions from pchar
to string and from string to pchar again. But, when I used cdecl, am
I making this conversion automatically? Is there a compilation switch
that allows me to write strings and the compiled code having correctly
treated the allocations and disallocation of strings?

Suppose this VBA code:

public declare function concatenate lib test (name as string) as string

Is this the correct way to write the called function in Freepascal?

function concatenate(name: string): string; cdecl;
begin
result := 'Freepascal ' + name;
end;



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


Re: [fpc-pascal] How to instantiate a public type in a generic class

2015-05-25 Thread luciano de souza
Sven,

I really thoght that I had replied your message, but now, I realize I
didn't do it.

Actually, the fact compiler does not  support the sintax I proposed,
it's not very severe. In stead of passing a subtype, I can firstly
create a type from the subtype and using it in the specialization:

TPersons = TdgOPFentity.Tentities;

Passing TPersons, the compiler will not complain.

But, say me: is the problem I faced related to 2.4 version? In newer
version, would it be possible to use something like I have proposed or
will the same behviour be maintained?



2015-05-17 15:46 GMT-03:00, luciano de souza luchya...@gmail.com:
 Hello listers,

 Using Freepascal 2.6.4, I have a problem about generics. In short, I
 can't specialize a class with a subtype of a type declared with
 public type. Let me try to explain.

 In dopf.pas, I have:

 type
 generic TdGOpfT1, T2, T3 = class(TdComponent)
 public type
 TEntities = specialize TFPGObjectListT3
 end;;

 If personmapper is a class specialized from TdGOpf, an instance can be
 created as follows:

 Personmapper := TPersonMapper.TEntities.create;

 Yes, this code is successul. But this code is not:

 type
 generic TGAction t1, t2 = class(specialize TBrookGAction t1);
 private
 Fentities: t2.TEntities; //Error in type definition
 end;

 This code failed, so I tried:

 type
 generic TGAction t1, t2 = class(specialize TBrookGAction t1);
 public type TCEntities = t2.Tentities; //Error in type definition
 end;

 I got also an error if I try:

 type
 generic TGAction t1, t2, t2.TEntities = class(specialize TBrookGAction
 t1);

 Well, I think the problem is illustrated. The doubt is how can create
 an instance of a public type, in my case, t2.Tentities inside my
 specialized class?

 Best regards,


 --
 Luciano de Souza



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


[fpc-pascal] How to instantiate a public type in a generic class

2015-05-17 Thread luciano de souza
Hello listers,

Using Freepascal 2.6.4, I have a problem about generics. In short, I
can't specialize a class with a subtype of a type declared with
public type. Let me try to explain.

In dopf.pas, I have:

type
generic TdGOpfT1, T2, T3 = class(TdComponent)
public type
TEntities = specialize TFPGObjectListT3
end;;

If personmapper is a class specialized from TdGOpf, an instance can be
created as follows:

Personmapper := TPersonMapper.TEntities.create;

Yes, this code is successul. But this code is not:

type
generic TGAction t1, t2 = class(specialize TBrookGAction t1);
private
Fentities: t2.TEntities; //Error in type definition
end;

This code failed, so I tried:

type
generic TGAction t1, t2 = class(specialize TBrookGAction t1);
public type TCEntities = t2.Tentities; //Error in type definition
end;

I got also an error if I try:

type
generic TGAction t1, t2, t2.TEntities = class(specialize TBrookGAction t1);

Well, I think the problem is illustrated. The doubt is how can create
an instance of a public type, in my case, t2.Tentities inside my
specialized class?

Best regards,


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


[fpc-pascal] Size limits to name child specialized classes

2014-10-10 Thread luciano de souza
Hello all,

Nowadays, using FPC 2.6.4, specialized classes have a size limit on
names. The compiler joins the the parent and child class names and
when the resultant string reaches more than 32 characters, an error is
raised.

My question is: in the comming version of FPC, will be this issue
solved? When the parent class has a long name, names chosen to child
class must be excessively short!

Regards,

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


Re: [fpc-pascal] Size limits to name child specialized classes

2014-10-10 Thread luciano de souza
Thank you. Generics is one of the best features the compiler has
lately implemented. I am happy to use it freely!

2014-10-10 9:34 GMT-03:00, Sven Barth pascaldra...@googlemail.com:
 Am 10.10.2014 12:52 schrieb luciano de souza luchya...@gmail.com:

 Hello all,

 Nowadays, using FPC 2.6.4, specialized classes have a size limit on
 names. The compiler joins the the parent and child class names and
 when the resultant string reaches more than 32 characters, an error is
 raised.

 My question is: in the comming version of FPC, will be this issue
 solved? When the parent class has a long name, names chosen to child
 class must be excessively short!

 Already solved in trunk for quite some time ;)

 Regards,
 Sven



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


Re: [fpc-pascal] Freepascal templating engines with logical structures

2014-09-22 Thread luciano de souza
Thank you. The options you had me done are very intersting.

I want to show HTML grids and I intend to use a templating engine for
this purpose. But, in stead of embed logics in the template, I think I
need to organize better my code.

Perhaps, I need to build a class THMLTable where I could set a dataset
to be shown and paginated. And by means of a text property, I can fill
the template with one of the presented engines.

2014-09-17 1:51 GMT-03:00, luciano de souza luchya...@gmail.com:
 Hello all,

 I Know two templating engines for Freepascal: FPTemplate e JTemplate.
 Both can be successfully used for html construction.

 But they presents the same aspect: only searches and replaces tags to
 values.

 Of course, it's crucial. But to show html grids, obtained from
 database queries, it would be better if the templating engine had
 support for logical structures. Something like:

 table
 %
 for row in rows do
 begin
 write('tr');
 for cell in cells do
 writeln('td%s/td', [cell]);
 write('/tr');
 end;
 %
 /table

 It's only an example. The engine can use a syntax different from Pascal.

  But what I really like is not to use Javascript. Yes, in the Pascal
 side, I could write a JSON and certainly, there would be several
 Javascript libraries to show a grid from a JSON. However, I would like
 a pure Pascal solution.

 Are there templating engines in Pascal with support for logical structures?

 Regards,

 --
 Luciano de Souza



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


[fpc-pascal] Commandline to compile projects with generics

2014-09-22 Thread luciano de souza
Hello all,

I don't use Lazarus, but only Freepascal. Untill the generics advent,
I used to compile my projects with the following commandline:

fpc progname.pp

However, using generics, it was common an access violation in
compiling time. A friend said that codes with generics sould be
compiled with:

fpc progname.pp -B -Scghi -O1 -gw2 -godwarfsets -gl -vewnhi

Yes, it works, but why is it not possible to compile programs with
generics with the conventional method?

Regards,

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


[fpc-pascal] Persistent lists to save records

2014-09-22 Thread luciano de souza
Hello all,

Sometimes, I want only to save a simple file of records. The first
approach is record files, handled with reset, read, write and close of
CRT unit.

However, thereis an important limit. Strings can't exceed 255
characters. The $H switch can't be on.

So my question is: which are the easiest way to save records without
this limitation?

Is there something like a persistent list?

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


Re: [fpc-pascal] Persistent lists to save records

2014-09-22 Thread luciano de souza
Hum... It's a very good idea. Firstly, I thought in something like a
persistent list with LoadFromFile and SaveTofile methods, but this
approach is really simple and useful.

2014-09-22 13:01 GMT-03:00, leledumbo leledumbo_c...@yahoo.co.id:
 So my question is: which are the easiest way to save records without this
 limitation?
 Is there something like a persistent list?

 Not with static data record. That one do only support shortstrings, because
 it contains actual data. Other strings are just pointers, which will be
 saved as pointers as well, thus cannot be used for things like this. For
 dynamic data, you have to work a little harder by using untyped file.
 Dynamic data can easily be represented as length followed by data. Length
 can be 1-n bytes, depending the maximum length of data you want to support.



 --
 View this message in context:
 http://free-pascal-general.1045716.n5.nabble.com/Persistent-lists-to-save-records-tp5720142p5720144.html
 Sent from the Free Pascal - General mailing list archive at Nabble.com.
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



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


Re: [fpc-pascal] Commandline to compile projects with generics

2014-09-22 Thread luciano de souza
Wonderful! Generics are one of the best things has succeed in Freepascal.

I suppose this correction will be available in FPC 2.8. Is there some
prevision when it will be launched? A friend took a look at GIT
updates and he was very happy with the advances.
2014-09-22 12:51 GMT-03:00, leledumbo leledumbo_c...@yahoo.co.id:
 Yes, it works, but why is it not possible to compile programs with
 generics with the conventional method?

 Compiler bug, which luckily gets fixed by specifying additional compiler
 options. In normal case, there should be no difference between compiling
 non-generic and generic code WRT compiler option.



 --
 View this message in context:
 http://free-pascal-general.1045716.n5.nabble.com/Commandline-to-compile-projects-with-generics-tp5720141p5720143.html
 Sent from the Free Pascal - General mailing list archive at Nabble.com.
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



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


[fpc-pascal] Freepascal templating engines with logical structures

2014-09-16 Thread luciano de souza
Hello all,

I Know two templating engines for Freepascal: FPTemplate e JTemplate.
Both can be successfully used for html construction.

But they presents the same aspect: only searches and replaces tags to values.

Of course, it's crucial. But to show html grids, obtained from
database queries, it would be better if the templating engine had
support for logical structures. Something like:

table
%
for row in rows do
begin
write('tr');
for cell in cells do
writeln('td%s/td', [cell]);
write('/tr');
end;
%
/table

It's only an example. The engine can use a syntax different from Pascal.

 But what I really like is not to use Javascript. Yes, in the Pascal
side, I could write a JSON and certainly, there would be several
Javascript libraries to show a grid from a JSON. However, I would like
a pure Pascal solution.

Are there templating engines in Pascal with support for logical structures?

Regards,

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


[fpc-pascal] Using a custom fpc.cfg

2014-07-07 Thread luciano de souza
Hello all,

In my application, I want to use a custom fpc.cfg. As I work only with
commandline tools, this is an important file for me.

I have used fpcmkcfg to generate a brand new fpc.cfg.

In my application, I have a directory for configuration files. I
thought in placing fpc.cfg there in stead of the same directory of the
executable.

What I want to know is: is there a commandline parameter to specify a
new name or, at least, a new directory to fpc.cfg file?

For example, in stead of placing fpc.cfg in ./, I want to place it in
./Settings.

I use fpc 2.6.4.
-- 
Luciano de Souza
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Understanding the usage of resources in Linux

2014-05-24 Thread luciano de souza
Hello all,

I want to use resources with FPC 2.6.2. Reading on Lazarus wiki, I
knew it's recommended the usage of Lazarus resources (lazres).

This is not an option for me. lazres expects a lrs file and I can't
generate it.

I am blind. I can install Lazarus in my Linux, but only to use some
units. The graphical interface of Lazarus is completely inaccessible.

I searched for a lrs example. I thought I could write it manually. But
it's impossible. It's a complex and a very large file.

The choices are:

1. A command line program generates the lrs file. Something like:
program file1.tpl file2.wav. After this, I could use lazres.
2. In my Ubuntu 13.10 64 bits, a program compile rc scripts into a res
files. For a long time, I tried to do it. I heard resources have a bad
behaviour in Linux.

Well, my question is: using Ubuntu 13.10 64 bits and only the command
line and a text editor like Gedit, is it possible to add files as
resources in my executable?
-- 
Regards,

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


Re: [fpc-pascal] A Regular Expression failing on the borders of words

2014-04-10 Thread luciano de souza
Well, I need to study more. I can't understand what is wrong. The
match starts with a blank space: \s+. Some string follows: .*. And it
ends in the border of word: \b. So, (\s+.*\b)*, for me, should return:
+ABC +DEF. If @ is not present, why the rest of the string was
matched.

My knowledge about Regular Expressions is small, so I really need to study more.

2014-04-10 4:16 GMT-03:00, Mattias Gaertner nc-gaert...@netcologne.de:
 On Thu, 10 Apr 2014 02:43:41 -0300
 luciano de souza luchya...@gmail.com wrote:

[...]
 r.expression := '^(x\s+)*(\([A-E]\))*(\s*.*\.)+(\s+\+.*\b)*(\s+@.*\b)*$';
 if r.exec('x (A) Write a report. +ABC +DEF @John @Mary') then

 The (\s+\+.*\b) matches '+ABC +DEF @John @Mary'.

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



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


[fpc-pascal] A Regular Expression failing on the borders of words

2014-04-09 Thread luciano de souza
Hello all,

This program compiles, but it gives a wrong output.

program ertext;
{$mode objfpc}{$H+}

uses
Sysutils, regexpr;

var
r: TRegexpr;
i: integer;

BEGIN
r := TRegexpr.create;
try
r.expression := '^(x\s+)*(\([A-E]\))*(\s*.*\.)+(\s+\+.*\b)*(\s+@.*\b)*$';
if r.exec('x (A) Write a report. +ABC +DEF @John @Mary') then
begin
for i := 1 to r.SubexprMatchCount do
begin
writeln(r.match[i]);
readln;
end;
end;

finally
r.free;
end;
END.

The input string is x (A) Write a report. +ABC +DEF @John @Mary.

The expected output was:

r.match[1] -  x - OK
r.match[2] - (A) - OK
r.match[3] - Write a report. - OK
r.match[4] -  +ABC +DEF - Error
r.match[5] -  @John @Mary - Error

In stead of 4 e 5, I got only 4 with the following output:  +ABC +DEF
@John @Mary.

It's true I am not have enough experience in Regular Expressions, but
the used one seems to be very logical for me. Would Someone have any
idea what is wrong?

Best regards,

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


Re: [fpc-pascal] A linking error in a SDL example

2014-03-04 Thread luciano de souza
It works! Thank you very much. The reason was the lacking library.

This code plays a mp3 file.

program test;
uses
sounds;

begin
PlaySound('guitar.wav');
end.

unit sounds;

interface
uses
sdl, sdl_mixer, strings;

procedure PlaySound(filename: string);

implementation
procedure PlaySound(filename: string);
var
VFilename: pchar;
VChunk: pmix_chunk;
begin
VFilename := strAlloc(length(filename) + 1);
StrPCopy(VFilename, filename);
VChunk := mix_loadWav(VFilename);
if VChunk = nil then
writeln('O arquivo não pôde ser carregado');
if mix_PlayChannel(-1, VChunk, 0)  0 then
exit;
while mix_Playing(0) = 1 do SDL_Delay(10);
StrDispose(VFilename);
end;

initialization
sdl_init(SDL_INIT_AUDIO);
mix_OpenAudio(44100, mix_Default_format, 2, 4096);

finalization
Mix_CloseAudio;
sdl_quit;
end.

2014-03-04 5:35 GMT-03:00, Yann Mérignac yann.merig...@gmail.com:
 Probably your missing the libsmpeg library. On debian it's provided by the
 libsmpeg0 package.

 https://packages.debian.org/wheezy/libsmpeg0



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

[fpc-pascal] A linking error in a SDL example

2014-03-03 Thread luciano de souza
Hell all,

A friend ask me about the audio playing with SDL. I tried to do an example.

As I use Linux, with the following command, I consider all packages
neeeded would be installed, but it seems that I am wrong:
sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev
libsdl-mixer1.2-dev libsdl-ttf2.0-dev

The source was compiled, but a link.res was generated as output.

According to the link.res, the executable coud not be built becose of
the lack of lsmpeg.

I don't know how to install lsmpeg.

Since my code compiles, I think is not a problem with the code. What
do you suppose is wrong?


Regards,


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


[fpc-pascal] Formating JSON outputs

2014-01-28 Thread luciano de souza
Hello all,

JSON is a very easy format to handle with Freepascal. However, the
output is not so readable when the number of registers increase. An
example of it is:

program test;
{$mode objfpc}{$H+}

uses
classes, fpjson;

var
r, j: TJSONObject;
a: TJSONArray;
s: TStringlist;

BEGIN
s := TStringlist.create;
r := TJSONObject.create;
a := TJSONarray.create;
j := TJsonObject.create;
j.strings['name'] := 'Luciano de Souza';
j.integers['age'] := 38;
j.strings['city'] := 'Niterói';
j.strings['country'] := 'Brazil';
a.add(j.clone);
j.clear;
j.strings['name'] := 'Mariella Molinari';
j.integers['age'] := 29;
j.strings['city'] := 'Padova';
j.strings['country'] := 'Italy';
a.add(j.clone);
r.add('people', a);
s.text := r.AsJson;
s.SavetoFile('test.txt');
try

finally
j.free;
r.free;
s.free;
end;
END.

The corresponding output is:

{ people : [{ name : Luciano de Souza, age : 38, city :
Niterói, country : Brazil }, { name : Mariella Molinari,
age : 29, city : Padova, country : Italy }] }

My question is: is there a way to automatically format it? Breaking
lines? Becoming easy the reading?

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

[fpc-pascal] Adding files to a tar file

2014-01-21 Thread luciano de souza
Hello all,

This code should add all the files of a directory in a tar file.

program e01;
{$mode objfpc}{$H+}

uses
libtar, sysutils;

var
archive: TTarWriter;
search: TSearchRec;

BEGIN
archive := TTarWriter.create('arquivo.tar');
with archive do
begin
try
FindFirst('/home/luciano/Documentos/*', faAnyFile, search);
repeat
if (search.name  '.') and (search.name  '..') then
AddFile(search.name);
until FindNext(Search) = 0;
finally
free;
end;
end;
END.

The program compiles, but I got an error. The message says that the
first file of the directory can't be opened.

What is wrong?

My second doubt is: I am running this program in Ubuntu 13.10. If I
run it in Windows, will a external library be necessary or all the
code is included in lib tar unit?

Regards,



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


[fpc-pascal] FPCUnit tests without Lazarus

2013-10-18 Thread luciano de souza
Hello all,

FPCUnit is a very good feature to test Pascal applications. At uses
clause, it's needed to declare fpcunit e testregistry. It's also
necessary to use the Console Test Runner. Yes, it's a good approach.

Nowever, fpcunit is on the FPc core and TestRegistry and console
Test Runner on the Lazarus units.

On the Lazarus wiki, I have read that it's also possible to test
applications only using fpcunit. I was interested in this idea. I am
blind and I program only using FPC. As Lazarus units regards to
graphical features, it seems to be that I have no reasons to install
it. If it was possible to use FPCUnit without Lazarus, yes, I really
would like to know how it can be done.

On the wiki, I have read that FPCUnit without Lazarus is a simple
approach. My needs are very simple, so why not to try it?

What do you can say me about FPCUnit without Lazarus? Or more broadly,
which would be your strategy to automatize tests if Lazarus didn't
exist?

Regards,

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


Re: [fpc-pascal] FPCUnit tests without Lazarus

2013-10-18 Thread luciano de souza
Yes, you are right. Now, I observe that we have two foldders: fpcunit
and fcl-fpcunit. The missing units were in the last one.

I don't know why I made this confusion. Sorry!

2013/10/18, Michael Van Canneyt mich...@freepascal.org:


 On Fri, 18 Oct 2013, luciano de souza wrote:

 Hello all,

 FPCUnit is a very good feature to test Pascal applications. At uses
 clause, it's needed to declare fpcunit e testregistry. It's also
 necessary to use the Console Test Runner. Yes, it's a good approach.

 Nowever, fpcunit is on the FPc core and TestRegistry and console
 Test Runner on the Lazarus units.

 This is not correct. testregistry and consoletestrunner are part of FPC.
 I run all my tests without reference to lazarus.

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



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


Re: [fpc-pascal] Executable with invisible window and IO enabled

2013-07-21 Thread Luciano de Souza

I thank you for the tip. That's true I haven't tested it up to now.
The Windows was damaged by 194 infections. this large amount of virus 
has blocked the browsers and, as a result, the web development was 
suspensed for some time. It's really confortable to know Linux is safier.

the important is that explanations were very clear and useful.
Thank you!


Em 20-07-2013 14:49, Graeme Geldenhuys escreveu:

On 2013-07-20 12:28, Noah Silva wrote:

remember one book recommending the following way to sort a list of strings:
1. Create an invisible list box on the window

:-)  I'm still required to maintain a VB6 program that is full of such
sh*t. Hidden controls all over the place. :-/  That definitely was the
way VB developers coded though.


Regards,
   Graeme

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


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


Re: [fpc-pascal] Executable with invisible window and IO enabled

2013-07-21 Thread Luciano de Souza

I thank you for the tip. That's true I haven't tested it up to now.
The Windows was damaged by 194 infections. this large amount of virus 
has blocked the browsers and, as a result, the web development was 
suspensed for some time. It's really confortable to know Linux is safier.

the important is that explanations were very clear and useful.
Thank you!


Em 20-07-2013 14:49, Graeme Geldenhuys escreveu:

On 2013-07-20 12:28, Noah Silva wrote:

remember one book recommending the following way to sort a list of strings:
1. Create an invisible list box on the window

:-)  I'm still required to maintain a VB6 program that is full of such
sh*t. Hidden controls all over the place. :-/  That definitely was the
way VB developers coded though.


Regards,
   Graeme

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


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


[fpc-pascal] Executable with invisible window and IO enabled

2013-07-15 Thread luciano de souza
hello all,
I want to compile a program with no visible screen, but at the same
time, with input and output enabled.
If I use $apptype gui, the screen is invisible, but there are not
input and output.
If I use the standard $apptype console, the input and output is
enabled, but the screen is visible.
In Windows, how to obtain the both effects simultaneously?
Brook has an embeded web server. With one click on the executable, the
web server is opened. However, it's not my intention to keep the
window visible. Otherwise, the browser will read data from the input
and write data to the output. So, I really need invisibility and
enable IO.
Regards,
Luciano
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] ID3v2 - Reading and writing MP3 metadata

2013-05-09 Thread luciano de souza
Hello listers,
I friend has sent me a component to read and write mp3 tags. In
particular, I am interested in the ID3v2 pattern.
In theory, the attatched component could do what I want. I can't make
sure, but I think it is not working very well.
When I use ID3v1 tags, title, artist, album, comment, track, genre,
the sucess is total. However, when I use ID3v2 tags like composer,
the tag is not created or updated. The executable is generated without
erros, it runs without erros, but does not fills up the composer
tag.
So I ask you: do you knows how to write composer tag in a mp3 file?
The solution can be with this or another component.
Actually, if this component is bugged, it's really sad. It's so simple
to use... let's show:

program id3;
{$mode objfpc}{$H+}

uses
sysutils, id3v2;

var
tagger: TID3v2;

BEGIN
tagger := TID3v2.create;
try
with tagger do
begin
track := StrToInt64Def('12', 0);
title := 'O meu título';
artist := 'O meu artista';
album := 'O meu álbum';
year := '2013';
comment := 'O meu comentário';
genre := 'clássico';
composer := 'O meu compositor';
SavetoFile('01.mp3');
end;
finallyt
tagger.free;
end;
END.

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


Re: [fpc-pascal] Re: ID3v2 - Reading and writing MP3 metadata

2013-05-09 Thread luciano de souza
Well, the unit you present me seems to only support ID3v1.
I said: It works only under the ID3v1 pattern! No. Its not correct.
What I want to say is that only the same tags filled under the ID3v1
pattern is filled when I use the TID3v2 class. So the attached unit
and the mentioned example behaves as the ID3v1 was the active
supported pattern.
In my example, composer is the single tag present in v2, not present in v1.
Attached is the unit sent to me.
ID3v1 is a very simple pattern. It's enough to read the last 128 byte
of the mp3 file, assigning it to a record. So with simple blockreads
and blockwrites, the work is done without difficulties. ID3v2 is much
more complex.
After visiting http://www.id3.org, I got some information for
developers. Hum.. The ID3v2 is so complex that I think I was not able
to implement it if it is already available.


2013/5/9, leledumbo leledumbo_c...@yahoo.co.id:
 As wikipedia explains, ID3v1 and ID3v2 are completely unrelated and have
 different structure. Without seeing what your friend unit contains, it's
 hard to tell whether he implements both versions correctly or not. But
 since
 you said the version 1 works, and I don't see anything discriminating the
 two version in your sample code (again, this can't be concluded without
 seeing the actual unit code), I guess he only implements version 1.

 Apparently, Cactus Jukebox supports ID3, both version 1 and 2.
 The related unit is here:
 https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/applications/cactusjukebox/source/tagreader/mp3file.pas
 You can see how it's used here:
 https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/applications/cactusjukebox/source/mediacol.pas




 --
 View this message in context:
 http://free-pascal-general.1045716.n5.nabble.com/ID3v2-Reading-and-writing-MP3-metadata-tp5714707p5714708.html
 Sent from the Free Pascal - General mailing list archive at Nabble.com.
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal



-- 
Luciano de Souza
unit ID3v2;
{$mode objfpc}{$H+}

interface 

uses 
  Classes, SysUtils; 

const 
  TAG_VERSION_2_2 = 2; 
  TAG_VERSION_2_3 = 3; 
  TAG_VERSION_2_4 = 4; 

type 
  TID3v2 = class(TObject) 
  private 
FExists: Boolean; 
FVersionID: Byte; 
FSize: Integer; 
FTitle: string; 
FArtist: string; 
FAlbum: string; 
FTrack: Word; 
FTrackString: string; 
FYear: string; 
FGenre: string; 
FComment: string; 
FComposer: string; 
FEncoder: string; 
FCopyright: string; 
FLanguage: string; 
FLink: string; 
procedure FSetTitle(const NewTitle: string); 
procedure FSetArtist(const NewArtist: string); 
procedure FSetAlbum(const NewAlbum: string); 
procedure FSetTrack(const NewTrack: Word); 
procedure FSetYear(const NewYear: string); 
procedure FSetGenre(const NewGenre: string); 
procedure FSetComment(const NewComment: string); 
procedure FSetComposer(const NewComposer: string); 
procedure FSetEncoder(const NewEncoder: string); 
procedure FSetCopyright(const NewCopyright: string); 
procedure FSetLanguage(const NewLanguage: string); 
procedure FSetLink(const NewLink: string);

  public 
constructor Create;
procedure ResetData; 
function ReadFromFile  (const FileName: string): Boolean; 
function SaveToFile(const FileName: string): Boolean; 
function RemoveFromFile(const FileName: string): Boolean; 
property Exists  : Boolean read FExists; 
property VersionID   : Byteread FVersionID; 
property Size: Integer read FSize; 
property Title   : String  read FTitle write FSetTitle; 
property Artist  : String  read FArtistwrite FSetArtist; 
property Album   : String  read FAlbum write FSetAlbum; 
property Track   : Wordread FTrack write FSetTrack; 
property TrackString : String  read FTrackString; 
property Year: String  read FYear  write FSetYear; 
property Genre   : String  read FGenre write FSetGenre; 
property Comment : String  read FComment   write FSetComment; 
property Composer: String  read FComposer  write FSetComposer; 
property Encoder : String  read FEncoder   write FSetEncoder; 
property Copyright   : String  read FCopyright write FSetCopyright;
property Language: String  read FLanguage  write FSetLanguage;
property Link: String  read FLink  write FSetLink;
  end;

implementation

const
  ID3V2_ID = 'ID3';
  ID3V2_FRAME_COUNT = 16;
  ID3V2_FRAME_DESC: array [1..ID3V2_FRAME_COUNT] of string =
('Title/songname/content description',
 'Lead performer(s)/Soloist(s)',
 'Album/Movie/Show title',
 'Track number/Position in set',
 'Year',
 'Content type',
 'Comments',
 'Composer',
 'Encoded by',
 'Copyright message',
 'Language(s

Re: [fpc-pascal] Re: ID3v2 - Reading and writing MP3 metadata

2013-05-09 Thread luciano de souza
I didn't test it becose I didn't find the composer tag in the source
code. Without the composer tag, I can conclude it does not support
ID3V2.
I observed also that genre is an integer. At ID3v2, genre became a string.

2013/5/9, Fred van Stappen fi...@hotmail.com:
 Well, the unit you present me seems to only support ID3v1.
 I said: It works only under the ID3v1 pattern! No. Its not correct.
 What I want to say is that only the same tags filled under the ID3v1
 pattern is filled when I use the TID3v2 class. So the attached unit
 and the mentioned example behaves as the ID3v1 was the active
 supported pattern.
 In my example, composer is the single tag present in v2, not present in
 v1.
 Attached is the unit sent to me.
 ID3v1 is a very simple pattern. It's enough to read the last 128 byte
 of the mp3 file, assigning it to a record. So with simple blockreads
 and blockwrites, the work is done without difficulties. ID3v2 is much
 more complex.
 After visiting http://www.id3.org, I got some information for
 developers. Hum.. The ID3v2 is so complex that I think I was not able
 to implement it if it is already available.
 e Free Pascal - General mailing list archive at Nabble.com.

 __

 Hello.
 Im busy to implement ID3v2 tag in uos.
 Im nearly ready...
 https://github.com/fredvs/uos
   


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


Re: [fpc-pascal] Documentation

2012-12-17 Thread luciano de souza
I have never used FPDoc, but I'd like to understand how it would work
in my specific case.
I am blind. I use screen reader. I compile my projects without the
intervenience of an IDE. No Lazarus, No FPC console ID, I compile my
projects with commands like that:

fpc myprog.pp

If Myprog.pp has the Pasdoc marks, I can create the documentation also
by means of commandline. But my question is: FPDoc can be used without
an IDE? If true, would I have to create the XML structure manually?
Pasdoc is a very good tool, but that's true the source code becomes overcrowded.
For my case, Pasdoc seems to be better becouse I won't have an IDE to
create the XML. Is this true?


2012/12/17, dev.d...@gmail.com dev.d...@gmail.com:
 Hi,
 as the question whether inline or external source docs are the way to go
 (again?) came up, here are my thoughts (currently searching for the best
 solution :) ):

 I personally prefer external docs (and thus started to use fpdoc);
 reasons are uncluttered source, less scrolling and (if you strictly limit
 oneself to 80 chars per line) readability on small screens (mobile).
 At the same time, I use short single (!) line comments to functions, very
 much
 the way pasdoc would use them.

 For sources in an early state (moving code around etc.) external
 documentation
 is really annoying, for the detailed documentation of mature source inline
 docs are simply unsuitable IMHO.

 Therefore I would really like to see a feature that combines both
 approaches,
 small inline comments, e.g. for IDE tooltips and overview documentation
 together with the possibility to have more detailed infos in external
 files.

 Don't get me wrong, that's not an complaint...
 ... I don't how much work it would be to extend fpdoc, but I really would
 like
 to contribute if I knew where to start [and had some more time...] :)

 Btw. I really like the lazarus fpdoc GUI...

 Just my 2 cents,
 d.l.i.w


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



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


Re: [fpc-pascal] Brook 1.0 - A new framework for web was born

2012-12-15 Thread luciano de souza
No, Brook works with any web server. Apache is only the an example and
the preference of the author.


2012/12/15, silvioprog silviop...@gmail.com:
 Hello all,

 More than 15,000 lines of source code, more than 90 test cases, more than
 one year of work. Today, a new framework for web development was born. It's
 name is Brook and its nice features are available for you.
 I thank the FPWeb, the Freespider, the Powtils, the ExtPascal, the CustCGI
 and the EazyCGI developers. I got inspiration in all of them and and still
 in Rails and Slim Framework.

 Special thanks, I drive to João Moraes, who gave me valuable advices to
 decoupling the code. Thanks for Luciano de Souza, responsible for the
 documentation and the name of methods and properties. Thanks also for
 Marcos Douglas, the author of Greyhound, project  wich started as an
 inspiration and finished as a valuable partner in the new web ways.

 Finally, I thank for the Free Pascal and Lazarus community for the precious
 tips and quick helps.

 I was thinking about what to write in the launching e-mail. But, there's no
 much to say. The site of Brook and its documentation will speak for me. So
 I present the Brook's house:

 http://brookframework.org

 Your visit will be appreciated.

 Their, you find the documentation, you find examples running online and you
 find also the hopeness this work will be very useful to the Free Pascal and
 Lazarus commoties.

 On Sunday, I am going to start my vacations. Thanks God. The work is ready
 and the conscious is quiet.

 Enjoy!

 --
 Silvio Clécio
 My public projects - github.com/silvioprog



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


Re: [fpc-pascal] Brook 1.0 - A new framework for web was born

2012-12-15 Thread luciano de souza
It would be very intersting, but in this moment, it would mean a lost
of focus. The  existant web servers are fortunately reliable. So Brook
has prefered to invest in another aspects.
For example, the route handling. With one line, you can register a
pattern to calll your URLs:

action1.register('/person/:id/');

In the above code, you are saying that:
1. The first level of your pathinfo is /person;
2. The second level of your PathInfo is a variable containing an ID;
3. The final slash indicates that the URL will be a final slash even
if you have forgoten it.

Examples:

http://www.mysite.com/person/25
http://www.mysite.com/person/25/

If only an example of the power of route handling.
I think people will really appreciate the news Brook implements.


2012/12/15, Rainer Stratmann rainerstratm...@t-online.de:
 I thought the webserver itself was programmed in FreePascal...

 Am Saturday 15 December 2012 09:59:48 schrieb luciano de souza:
 No, Brook works with any web server. Apache is only the an example and
 the preference of the author.

 2012/12/15, silvioprog silviop...@gmail.com:
  Hello all,
 
  More than 15,000 lines of source code, more than 90 test cases, more
  than
  one year of work. Today, a new framework for web development was born.
  It's name is Brook and its nice features are available for you.
  I thank the FPWeb, the Freespider, the Powtils, the ExtPascal, the
  CustCGI and the EazyCGI developers. I got inspiration in all of them
  and
  and still in Rails and Slim Framework.
 
  Special thanks, I drive to João Moraes, who gave me valuable advices to
  decoupling the code. Thanks for Luciano de Souza, responsible for the
  documentation and the name of methods and properties. Thanks also for
  Marcos Douglas, the author of Greyhound, project  wich started as an
  inspiration and finished as a valuable partner in the new web ways.
 
  Finally, I thank for the Free Pascal and Lazarus community for the
  precious tips and quick helps.
 
  I was thinking about what to write in the launching e-mail. But,
  there's
  no much to say. The site of Brook and its documentation will speak for
  me. So I present the Brook's house:
 
  http://brookframework.org
 
  Your visit will be appreciated.
 
  Their, you find the documentation, you find examples running online and
  you find also the hopeness this work will be very useful to the Free
  Pascal and Lazarus commoties.
 
  On Sunday, I am going to start my vacations. Thanks God. The work is
  ready and the conscious is quiet.
 
  Enjoy!
 
  --
  Silvio Clécio
  My public projects - github.com/silvioprog


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



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


Re: [fpc-pascal] Brook 1.0 - A new framework for web was born

2012-12-15 Thread luciano de souza
Yes, there is a very nice tool. Its name is Pasdoc. Take a look here:
http://sourceforge.net/projects/pasdoc/
For this project, the author has changed the source code of Pasdoc.
Originally, it's compatible only with HTML 4, but the documentation
was released in HTML 5.


2012/12/15, Juha Manninen juha.mannine...@gmail.com:
 May I ask how were the hierarchy and dependency graps generated?
 Is there a tool that can do it?

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



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


Re: [fpc-pascal] A simple HTTP request with FPC standard units

2012-11-24 Thread Luciano de Souza
Unfortunately, I don't have enough knowledlge even to start a task like 
that. But observing the firm journey of Freepascal, I am sure we will 
have it soon.


Em 24-11-2012 06:52, Michael Van Canneyt escreveu:



On Fri, 23 Nov 2012, luciano de souza wrote:


Among its hundreds of units, the Freepascal always keeps surprises for
us. FPHTTPClient was a pleasant surprise.
The talk has followed freely and perhaps my question has been skipped:
is there Freepascal native routines to deal with SMTP protocol? In
other words, is there a native way to send an e-mail with Freepascal?


There are no FPC-provided native freepascal routines for this, but I 
see Paul Breneman has provided an alternative.


Contributions are welcome. It is mostly lack of time that keeps us 
from implementing these things.
As far as I know, SMTP is a fairly simple protocol, probably it is not 
too hard to implement.


Michael.





2012/11/23, Michael Van Canneyt mich...@freepascal.org:



On Fri, 23 Nov 2012, Leonardo M. Ramé wrote:


You mean probably
   s := TFPCustomHTTPClient.Get('http://a_site/a_page');

It could be done, but it will need to create an instance anyway.
Although I suspect such a simple case is a minority.

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



Yes, I said this because the original poster wrote he needed the very
little code to accomplish this.


I implemented the class methods for all forms of Get/Post/Formpost, 
so now

you can do:

s := TFPCustomHTTPClient.SimpleGet('http://a_site/a_page');

You can't get more simple than that.

Michael.



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



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


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

Re: [fpc-pascal] Fwd: [OFF-TOPIC] EazyRSS - A simple writer and reader for the RSS protocol

2012-11-24 Thread luciano de souza
I am really enthusiastic on RSS readers. I don't like to be searching
hours for some feature in the web. The more complete is Freepascal,
the more I like it. So my vote is to include Eazy RSS as a standard
package. It's really well useful and well implemented.

2012/11/24, silvioprog silviop...@gmail.com:
 Hello,

 This topic has started in FPC-Devel, but I regard more people wile can be
 interested. Is EazyRSS useful for anyone? Should it be included in the
 standard units of Free Pascal since the web development has been a trend?

 -- Forwarded message --
 From: silvioprog silviop...@gmail.com
 Date: 2012/11/23
 Subject: [OFF-TOPIC] EazyRSS - A simple writer and reader for the RSS
 protocol
 To: FPC developers' list fpc-de...@lists.freepascal.org

 Hello,

 The Freepascal has been important to my life, so it's very nice to
 contribute with some code.
 I didn't know FPHTTPClient. But it helped me a lot since I got a native
 implementation for a component.
 I have implemented a component to download and parse RSS. There is aclass
 to provide the RSS service and another to read news from a channel.

 The result of this work is here:

 https://github.com/silvioprog/easyrss

 I liked the result of this work. There is no native units in Freepascal to
 manage RSS. If the team of Freepascal regards this code can be intersting
 and wants to add it to native units, for me, of course, it would be an
 honor to participate in this fantastic project.
 Is the FPC team likes, I will exclude this project from Github since, in
 this case, it wouldn't make sense to stay there.
 But whatever is the will, here I offer my work and I hope the friends like
 it.

 Thank you,
 --
 Silvio Clécio
 My public projects - github.com/silvioprog



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


[fpc-pascal] A simple HTTP request with FPC standard units

2012-11-23 Thread luciano de souza
Hello listers,
Using Synapse, the developer has very good features to deal with the
HTTP protocol. But imagine you want only to do a get in a URL and
take a string back. I imagine it can be done with the standard units
of Freepascal. Is it true? How could I do it with FPC 2.7.1?
Best regards,
Luciano
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] A simple HTTP request with FPC standard units

2012-11-23 Thread Luciano de Souza

Yes, when I ask for a simple way, I could not imagine something so simpler!
Thank you. Your tip help me a lot.
The success of your answer is so that I add a question: is there also a 
FPC native unit dealing with SMTP?


Em 23-11-2012 14:15, Michael Van Canneyt escreveu:



On Fri, 23 Nov 2012, luciano de souza wrote:


Hello listers,
Using Synapse, the developer has very good features to deal with the
HTTP protocol. But imagine you want only to do a get in a URL and
take a string back. I imagine it can be done with the standard units
of Freepascal. Is it true? How could I do it with FPC 2.7.1?


very simple:

uses fphttpclient;

Var
  S : String;

begin
  With TFPHttpClient.Create(Nil) do
try
  S:=Get(ParamStr(1));
  finally
Free;
  end;
  Writeln('Got : ',S);
end.


home: fpc -S2 th.pp
/usr/bin/ld: warning: link.res contains output sections; did you 
forget -T?

home: th http://www.freepascal.org/
Got : !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
!-- Web Page Design by James Koster - http://www.jameskoster.co.uk  
and Marko Mihel?i? - http://www.mcville.net--


head

I cut off the rest.

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


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


Re: [fpc-pascal] A simple HTTP request with FPC standard units

2012-11-23 Thread luciano de souza
Among its hundreds of units, the Freepascal always keeps surprises for
us. FPHTTPClient was a pleasant surprise.
The talk has followed freely and perhaps my question has been skipped:
is there Freepascal native routines to deal with SMTP protocol? In
other words, is there a native way to send an e-mail with Freepascal?


2012/11/23, Michael Van Canneyt mich...@freepascal.org:


 On Fri, 23 Nov 2012, Leonardo M. Ramé wrote:

 You mean probably
s := TFPCustomHTTPClient.Get('http://a_site/a_page');

 It could be done, but it will need to create an instance anyway.
 Although I suspect such a simple case is a minority.

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


 Yes, I said this because the original poster wrote he needed the very
 little code to accomplish this.

 I implemented the class methods for all forms of Get/Post/Formpost, so now
 you can do:

 s := TFPCustomHTTPClient.SimpleGet('http://a_site/a_page');

 You can't get more simple than that.

 Michael.


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


Re: [fpc-pascal] Using flag field in Getopts

2012-10-31 Thread luciano de souza
If I correctly understood, the flag field is to find arguments. If it
remains nil, the argument was not found, otherwise, it's a pointer
to the short option.


2012/10/30, Henry Vermaak henry.verm...@gmail.com:
 On 30/10/12 10:05, luciano de souza wrote:
 Hello listers,
 Getopts offers very good features to process commandline arguments. As
 far as I could understand, I used it successfully. But it remains one
 unknown aspect for me. What is the field flag of TOption record?
 How to use it?

   TOption = Record
 Name: String;
 Has_arg : Integer;
 Flag: PChar;
 Value   : Char;
   end;

 I think the man page for getopt explains best how this is supposed to work:

 flag specifies how results are returned for a long option.  If flag is
 NULL, then getopt_long() returns val.  (For example, the calling program
 may set val to the equivalent short option character.)  Otherwise,
 getopt_long() returns 0, and flag points to a variable which is set to
 val if the option is found, but left unchanged if the option is not found.

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



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


Re: [fpc-pascal] Re: Generating templates with FPTemplate

2012-07-27 Thread Luciano de Souza

On 27/7/2012 08:51, leledumbo wrote:

try this:

type
   TMyTemplate = class(TFPTemplate)
   private
 procedure ReplaceMyTags(Sender : TObject; Const TagString : String;
TagParams:TStringList; Out ReplaceText : String);
   public
 constructor Create;
   end;

procedure TMyTemplate.ReplaceMyTags(Sender : TObject; Const TagString :
String; TagParams:TStringList; Out ReplaceText : String);
begin
   // use if-else if-else if your compiler version doesn't support case
statement with string variable
   case TagString of
 'name': ReplaceText := 'sysutils, classes';
 'modules': ReplaceText := 'freevox';
   end;
end;

constructor TMyTemplate.Create;
begin
   inherited Create;
   StartDelimiter := '#';
   EndDelimiter := '';
   OnReplaceTag := @ReplaceMyTags;
end;

begin
   with TMyTemplate.Create do
 try
   FileName := 'e030.txt';
   WriteLn(GetContent);
 finally
   Free;
 end;
end.

if you want to use your style, you can try adapting
http://free-pascal-general.1045716.n5.nabble.com/file/n5710450/view.pp my
unit . It's more or less like what you want, only with more features as I
support parameters.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Generating-Yes, it's really 
very good. An example like that could be added to the source package. 
Templating with parameters? Oh! Yes, there are lots of interesting things I can 
do with it!

Thank you!



templates-with-FPTemplate-tp5710448p5710450.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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


Re: [fpc-pascal] Generating templates with FPTemplate

2012-07-27 Thread Luciano de Souza

Michael,
Your example is very clear. I am not very good to understand source 
codes. But this style seems to be very good and logical.

It's really wonderful: FPC owns units for everything!
Thank you.

On 27/7/2012 08:43, michael.vancann...@wisa.be wrote:



On Fri, 27 Jul 2012, luciano de souza wrote:


Hello all,

I am trying to create an example with the FPTemplate unit. Firstly, I
wrote a hypothetical unit template.


[snip]



I am not successful in filling up the template. If I do
writeln(source.template), the answer is an empty string. If I do
writeln(source.GetContent), the answer is the template without the
needed replacements.

So I ask: what is wrong? How can I get a file, to replace tags and to
get a replaced string?


1. You need only one of the two classes, never both at the same time. 
2. You need to set the correct delimiters. Default are { and }


If you want to have fixed values for parameters, the easiest is
TTemplateParser. TFPCustomTemplate (or TFPTemplate) does not have 
fixed values, everything is event driven.


So, the following will do what you want:

program e30;

{$mode objfpc}{$H+}

uses
  fptemplate, classes;

var
  T : TTemplateParser;
  Fin,Fout : TFileStream;

BEGIN
  T := TTemplateParser.create;
  try
T.StartDelimiter:='#';
T.EndDelimiter:='';
T.values['name'] := 'freevox';
T.values['modules'] := 'sysutils, classes';
T.AllowTagParams:=False;
Fin:=TFileStream.Create('e30.txt',fmOpenRead);
try
  Fout:=TFileStream.Create('freevox.pas',fmCreate);
  try
T.ParseStream(fin,fout);
  finally
Fout.Free;
  end;
finally
  Fin.Free;
end;
  finally
T.free;
  end;
end.

Running this produces the file you want:

fsb: e30
fsb: cat freevox.pas
unit freevox;
{$mode objfpc}{$H+}

interface
uses
sysutils, classes

implementation

end.

That's it.

In revision 21977, I added a ParseFiles call, which makes the program 
even

easier:

program e30;

{$mode objfpc}{$H+}

uses
  fptemplate, classes;

var
  T : TTemplateParser;

BEGIN
  T := TTemplateParser.create;
  try
T.StartDelimiter:='#';
T.EndDelimiter:='';
T.values['name'] := 'freevox';
T.values['modules'] := 'sysutils, classes';
T.AllowTagParams:=False;
T.ParseFiles('e30.txt','freevox.pas');
  finally
T.free;
  end;
end.

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


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


[fpc-pascal] Small and not instalable web server for a local Pascal CGI application

2012-07-12 Thread luciano de souza
Hello all,
I am running some CGIs in localhost. When talking about web servers,
the name of Apache comes as natural. However, I would like to share
some zip files to show the results. For this purpose, Apache is not
the best   because I need something not instalable.
I tried a small server called Mongoose. I was enthusiastic with the
size: 140 kilobytes. Unfortunately, it used to fail when dealing with
some UTF-8 PathInfos.
Regarding I don't need many resources to run simple applications in
localhost, I would like indications about small, not instalable web
servers, ideal for my simple and sharable Pascal CGIs! Does someone
know something about this?
Regards,
Luciano
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Codepage: UTF-8 code greater than 65535 found

2012-06-24 Thread luciano de souza
Hello all,

In order to enable UTF-8 characters, I tried to use it:

program dvcodepage;
{$codepage UTF8}

uses
Sysutils;

var
x: integer;

BEGIN
writeln('Digite um número');
readln(x);
writeln('O número digitado foi ', x);
END.

I really didn't expect errors, but I got the following output:

Free Pascal Compiler version 2.6.0 [2011/12/25] for i386
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling dvcodepage.pas
dvcodepage.pas(9,9) Error: UTF-8 code greater than 65535 found
dvcodepage.pas(11,9) Error: UTF-8 code greater than 65535 found
dvcodepage.pas(12,4) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted

It's something related to size of integers, but what?
How to compile this code without errors?

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


[fpc-pascal] Re: Playing sounds with standard components

2012-06-11 Thread luciano de souza
I took a look in Openal examples. I need to confess that I expected
something easier. Perhaps, something like:

PlaySound('file.wav', 0)

In MMSystem, we have something like that, but it's not cross platform.

The examples present hundreds of lines. It's something frightful!

Regarding the complexity, probably is's possible to do much more than
simply play a sound. In spite of that, it would be intersting to have
something easier.

The examples work with complex and for me, abstract structures. Which
kind of content, do I need to study to understand Openal or SDL?




2012/6/9, luciano de souza luchya...@gmail.com:
 Hello all,

 Bass is a very good library for sound playing and recording. However,
 it's not included as an standard feature of Freepascal. For whom wich
 wants to work with standard components, are there other options: (1)
 to play sounds and (2) to record sounds?

 Regards,
 Luciano

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


[fpc-pascal] Playing sounds with standard components

2012-06-09 Thread luciano de souza
Hello all,

Bass is a very good library for sound playing and recording. However,
it's not included as an standard feature of Freepascal. For whom wich
wants to work with standard components, are there other options: (1)
to play sounds and (2) to record sounds?

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


[fpc-pascal] Getting an output string from a TProcess

2012-06-01 Thread luciano de souza
Hello all,

I want to execute FPC, but filtering the output in order to show only
the necessary information. The reason is I am blind, I use screen
reader and, in the console environment, it's not possible to read the
rows below without firstly read the rows above.
My intention is to use TProcess, calling fpc commmandline, replacing
all the non necessary information by ''. My first line will by
something like compiling ' or 'linking '.
For this purpose, TProcess is wonderful.
I want a function that receives a commandline string and returns an
output string. This return will be afterwards used to  replacements.

function execute(AProcess: TProcess; instr: string):string;
var
buffer: integer;
begin
with AProcess do
begin
commandline := instr;
options := [poUsePipes];
execute;
output.read(buffer, 10);
result := buffer;
end;
end;

I am confused due to some reasons:
1. Commandline is signed as deprecated, so what is the best way to
pass a string to TProcess? Is the  commandline the first item of the
tstrings called parameter?
2. The output is a class derived from THandleStream. As the read
method is override, its behaviour is different from TStream.
So I ask: what's the correct code to inform as argument a TProcess and
a instruction string and as a return, to get the output string?

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


[fpc-pascal] Handling with sources and exebutables with different names

2012-05-17 Thread luciano de souza
hello all,

I am compiling CGI modules with Freepascal in commandline mode. if I do:

fpc test.pas

the result is test.exe. But the source name needs to be different
from the executable name. For this reason:

fpc test.pas -oindex.cgi

This command should result in index.cgi, placed on the current folder.
However, this command is ignore and I obtain test.exe again.

My question is: how to produce a executable, compiling from the
commandline in FPC 2.6.0, with a different name of its source?

Regards,

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


[fpc-pascal] Re: Handling with sources and exebutables with different names

2012-05-17 Thread luciano de souza
Actually, there are no errors.

Using cmd.exe on Windows 7 and FPC 2.6.0, I did:

fpc test.pas -oindex.cgi

I got test.exe and no errors are raised.

We can do -d in the commandline or {$ifdef ..} in the source code.
Several other options are available from the two modes. Is there a
directive, placeable in code, allowing me to define a name for the
executable?

I am asking to myself: Did I become crazy? Have I done the test
wrongly? Yes, it can be. However, I did it several times with the
same result. I don't know what, but something misleading is wrong.


2012/5/17, luciano de souza luchya...@gmail.com:
 hello all,

 I am compiling CGI modules with Freepascal in commandline mode. if I do:

 fpc test.pas

 the result is test.exe. But the source name needs to be different
 from the executable name. For this reason:

 fpc test.pas -oindex.cgi

 This command should result in index.cgi, placed on the current folder.
 However, this command is ignore and I obtain test.exe again.

 My question is: how to produce a executable, compiling from the
 commandline in FPC 2.6.0, with a different name of its source?

 Regards,

 Luciano

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


[fpc-pascal] Re: Parsing parameters inside an interpreter

2012-05-14 Thread luciano de souza
Fortunately, my case is the simplest one. There will not quotes inside
quotes. Therefore, I believe TStringlists will sove the whole problem.
It's really  amasing what we can do with a TStringlist.

Thank you for the precious tips!


2012/5/13, luciano de souza luchya...@gmail.com:
 Hello all,

 I trying to build a very small interpreter. I can type commands like:

 $ add Luciano de Souza luchya...@gmail.com

 Somewhere in my code, I can have something like:

 procedure parse(commandline: string; var params: array of string);

 In this case, the commandline has the format: add %s %s. So I would
 obtain:

 parse('add Luciano de Souza luchya...@gmail.com', params);

 After this command, the parameter would have the following values:

 params[0] := 'add';
 params[1] := 'Luciano de Souza';
 params[2] := 'luchya...@gmail.com';

 My question is: there is a way to do it easily using a standard class
 of Freepascal?

 Luciano

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


[fpc-pascal] Data persistance in CGI projects

2012-02-26 Thread Luciano de Souza

Hello all,

For desktop environments, there are mature projects on data persistance. 
Press Objects, TiOPF... desktop developers can be proud of the tools 
they have.


What about CGI environments? Is there something already developed? Yes, 
we can use SQLDB. It's really a very good component. However, we need to 
write lots of SQL. The dream would be something like:


user := TUser.create;
user.name := 'Luciano';
user.age := 36;
user.insert;


I can hide all the SQL statements behind a custom TUser class. I can 
implement it. However, before writing this clear code, I will have to 
type a set of SQL statements. In other words, to simplify, it would be 
necessary to create a mother clas whose properties and methods would be 
use for my custom TUser class.


Of course, it is only a possible approach. I believe this pattern is 
called ActiveRecord. I confess I know little about persistance patterns. 
There is also the DAO pattern. Well, there are certainly several patterns.


My questions concerns exactly to it:

1. What are the alternatives for a CGI environment using a productive 
data persistance? What are your suggestions in terms of units, class or 
either strategies, including the model, the view and the controller?
2. If CGI with Frepascal is still starting and consequently, there 
aren't powerful tools and, therefore, code needs to be implemented, 
which pattern do you recommend? ActiveRecord? DAO? Another?


Well, before starting something, the first step is to listen and I am 
sure, here there is people with a significant higher background than me!


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


Re: [fpc-pascal] Data persistance in CGI projects

2012-02-26 Thread Luciano de Souza
Actually, reading the tiOPF, I found the support for Firebird, Microsoft 
SQL Server, Oracle, but not for PostgreSQL. This is the first reason. I 
really don't know how proper tiOPF is when we focuses on CGI 
development. At a first look, the project seemed to be very complex to 
use, but of course, I may be wrong.



Em 26-02-2012 13:29, Michael Van Canneyt escreveu:



On Sun, 26 Feb 2012, Luciano de Souza wrote:


Hello all,

For desktop environments, there are mature projects on data 
persistance. Press Objects, TiOPF... desktop developers can be proud 
of the tools they have.


What about CGI environments? Is there something already developed? 
Yes, we can use SQLDB. It's really a very good component. However, we 
need to write lots of SQL. The dream would be something like:


user := TUser.create;
user.name := 'Luciano';
user.age := 36;
user.insert;


Why not use tiOPF for this as well ? It works just as well in CGI 
environments.


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



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


Re: [fpc-pascal] FormatDatetime is not respecting the specified pattern

2012-02-01 Thread Luciano de Souza
Oh! Your correction is really good and welcome. Becouse of a Leber 
Congenital Amaurosis, I became blind when I was a child. As a 
consequence, nowadays, for me, slashes and backslashes are only a word 
spoken by the screen reader. It's really curious how brains can work 
differrently.


When people know you are blind, they don't use to make this kind of 
comment. I am lucky becouse you don't know it! Yes, if the shape of 
slashes and backslashes were similar to a triangle or a castle, it 
wouldn't matter for my daily life. In spite of this, it's really 
intersting to know how things exist in the visual world.


Even screen readers are worried in supplying some visual information. 
NVDA, the screen reader I currently use, can speak the RGB code on a 
particular point. Other screen readers can be more: they can also speak 
the name of the color. Some time ago, using this feature, I knew a color 
called brick. Brick as a color? It's really intersting. Yes, this 
information is not very important in my life, but at the point of view 
of culture, of the visual culture, it's really curious.


For these reasons, I like Pascal intensively. The two first screen 
readers, these technological wonder, I have been using, they are 
developed in Pascal: Dosvox and Virtual Vision, both conceived by 
brazilian developers.


Welll, well, let me stop the message. If I say something more off topic, 
I will be likely talking about planets and galaxes!


Thank you very much!

Regards,

Luciano

Em 01/02/2012 04:54, waldo kitty escreveu:

On 1/31/2012 22:23, Luciano de Souza wrote:

Hello listers,

A strange error came up when formating a date. See this code:
writeln(formatdatetime('dd/mm/', now));
The answer should be: 31/01/2012
The answer was: 31-01-2012
I did one test else:
writeln(formatdatetime('dd$mm$', now));
The answer was: 31$01$2012
Yes, the problem seems to be related to the backslash.


errrm1... that's not a 'back slash'... that's a forward slash.. aka 
just a plain slash... back slash leans backwards (ie: top to the 
left)...



DefaultFormatSettings.DateSeparator := '/';
writeln(formatdatetime('dd/mm/', now));
The answer was: 31/01/2012
Right! That's the answer. But it was necessary to setup the settings 
manually.

The test was done with Freepascal 2.4.4


errrm2: FP 2.6.0 is the current release... unless i'm highly 
mistaken... but still, see higher above ;)



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



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


Re: [fpc-pascal] FormatDatetime is not respecting the specified pattern

2012-02-01 Thread Luciano de Souza
Oh! Very well! I am blind, for me, slashes and backslashes are only 
words spoken by the screen reader. The worst is I listen barra and 
barra invertida, the portuguese correspondent words. You can imagine: 
I don't see slashes and I listen differently. The chance of mistake is 
very high! But fortunately, I have a good friend who corrects me! One 
bilion of corrections else and I will be perfect!


Thank you very much!

Em 01-02-2012 04:54, waldo kitty escreveu:

On 1/31/2012 22:23, Luciano de Souza wrote:

Hello listers,

A strange error came up when formating a date. See this code:
writeln(formatdatetime('dd/mm/', now));
The answer should be: 31/01/2012
The answer was: 31-01-2012
I did one test else:
writeln(formatdatetime('dd$mm$', now));
The answer was: 31$01$2012
Yes, the problem seems to be related to the backslash.


errrm1... that's not a 'back slash'... that's a forward slash.. aka 
just a plain slash... back slash leans backwards (ie: top to the 
left)...



DefaultFormatSettings.DateSeparator := '/';
writeln(formatdatetime('dd/mm/', now));
The answer was: 31/01/2012
Right! That's the answer. But it was necessary to setup the settings 
manually.

The test was done with Freepascal 2.4.4


errrm2: FP 2.6.0 is the current release... unless i'm highly 
mistaken... but still, see higher above ;)



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


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


[fpc-pascal] FormatDatetime is not respecting the specified pattern

2012-01-31 Thread Luciano de Souza

Hello listers,

 A strange error came up when formating a date. See this code:
writeln(formatdatetime('dd/mm/', now));
The answer should be: 31/01/2012
The answer was: 31-01-2012
I did one test else:
writeln(formatdatetime('dd$mm$', now));
The answer was: 31$01$2012
Yes, the problem seems to be related to the backslash.
DefaultFormatSettings.DateSeparator := '/';
writeln(formatdatetime('dd/mm/', now));
The answer was: 31/01/2012
Right! That's the answer. But it was necessary to setup the settings 
manually.

The test was done with Freepascal 2.4.4 and Ubuntu 10.10.
Does someone know what is my mistake?
Regards,
Luciano
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: FPCUnit without Lazarus

2012-01-08 Thread Luciano de Souza
Now, I understand. FPCUnit and FPCRegistry do not have LCL dependences. 
What depends on LCL is the runner called Console Runner. This name make 
me confused!


I ahve alredy read the documentation, but I could not understand. 
Perhaps, perhaps my weak english... Well, the fact is that everything is 
now OK.


When I read the documentation I didn't understand the runner was a 
separated executable: an application built specially to test my program.


I thought all the code needed to test my program would be in my test 
unit. I was able to create, to register the tests, but not to run then. 
I was searching something to run in FPCUnit and FPCRegister. All the 
code  required to run my test would be in the initialization of my test 
unit. When compiling my application I would do:


program MyApp;
uses
MyUnit,
{$ifdef tst}
MyUnitTest;
{$endif}

And I call: fpc MyApp.pas -dtest. According to this idea, the runner 
would be my own application called with certain commandline options.


Yes, in my first reading, I do not understand it. Now I can see the 
adopted model is best. I don't need to mix the code of my application 
with test code. {$ifdef ...} is not required.


In brief, all my problem was that I could understand that I have a 
runner and I will need to compile it each time I create a new project.


Solved my interpretation issues, now I am coming back to the tests.

Thank you very much for the attention!

Regards,

Luciano

Em 08-01-2012 00:14, leledumbo escreveu:

FPCUnit is part of FCL and it doesn't require LCL. Of course if you install
via packages under Lazarus components folder, it would depend on Lazarus
parts (e.g, LCL), esp. for the runner. Open
fpc/packages/fcl-fpcunit/src/demo for a pure FPC example. Or
http://free-pascal-general.1045716.n5.nabble.com/file/n5128730/fpcunit.pdf
here  for the documentation.

--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/FPCUnit-without-Lazarus-tp5128696p5128730.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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


Re: [fpc-pascal] FPCUnit without Lazarus

2012-01-08 Thread Luciano de Souza
Perhaps, the issue has no a happy end for all, but for me, that don't 
use Lazarus and I won't have to do it due FPCUnit, everything is 
fortunatelly OK. It would be unconfortable to install many megabytes to 
use almost nothing. Now, I am happy with Freepascal.

In the future, it's not impossible that I need FileUtils and Clipboard. But
 When it comes, I will think about. Until there, FPC is complete for me.

Em 08-01-2012 10:06, Rainer Stratmann escreveu:

Am Sunday 08 January 2012 02:17:29 schrieb Luciano de Souza:

I have downloaded a Lazarus deb package compatible with FPC 2.4.4. I try
to install with: sudo dpkg -i *. It fails, so: sudo apt-get install -f.
...
...
...

This was already some time discussed here and in my opinion this is the
bottleneck of working with freepascal on linux.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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


Re: [fpc-pascal] FPCUnit without Lazarus

2012-01-08 Thread Luciano de Souza

Michael,

In a exemple folder ConsoleRunner inside FPC, I found something like 
TestRunner.pp. It's something like the ConsoleRunner of Lazarus 
Components. I added my unit in this application and after compiling, I 
could run my tests.


I am really entusiastic with FPCUnit. It's really easy to create my 
tests. But being everything in FPC, it would be better, becouse after 
installling FPC, the feature is ready to use. I am using the application 
runner, not the unit ConsoleRunner, but, it's enough to run everything.


Thank you for the attention and congratulations for your work.

Regards,

Luciano

Em 08-01-2012 13:31, Michael Van Canneyt escreveu:


Follow-up:

I moved consoletestrunner unit to fcl. Revision 20010.

Michael.

On Sun, 8 Jan 2012, Michael Van Canneyt wrote:



Hello,

After your previous mails about this, I have discussed this with 
Vincent Snijders, the author of the console runner class. The console 
runner class of the LCL does not really have any dependencies on the 
LCL, only on FCL.


So, it will be moved to the FCL, Vincent has agreed to this.
You must simply give me some time to actually do this move.

So please, patience, it will be done, and you will not need Lazarus.

Michael.


On Sat, 7 Jan 2012, Luciano de Souza wrote:


Hello listers,

I have really appreciated the organized tests that FPCUnit allows. 
It's really a very good feature, but for me, it hasn't  been to 
use it.


For some while, I have writen an e-mail saying I could not run some 
example. The problem was that I don't use Lazarus, but only FPC. I 
am blind, so for me LCL doesn't make sense.


In spite of that, I had to instal Lazarus because FPCUnit has a LCL 
dependence.


I would like to use FPCUnit without install Lazarus, but perhaps it 
was not possible. If I bring FPCUnits modules to my folder, they 
require other modules and the other modules seem to require more 
modules. Without Lazarus installed, I could not run it.


The problem has become more severe becouse my Windows has failed. As 
I have Ubuntu 10.10, I decided to install everything here. FPC was 
installed, but Lazarus... I have problems of broken packages. I try 
to install with apt-get, but the repository has an old version only 
compatible with FPC 2.4.0.


I have downloaded a Lazarus deb package compatible with FPC 2.4.4. I 
try to install with: sudo dpkg -i *. It fails, so: sudo apt-get 
install -f.


Well, I could not install it. But, I would really prefer not to 
install Lazarus.


So I want an advice. As FPCUnit has no visual components, I could 
not understand why LCL units are required. But the important is:


How to run FPCUnit without Lazarus? Is it possible?

Regards,

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


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


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


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


Re: [fpc-pascal] Adding code indentation without Lazarus

2012-01-02 Thread Luciano de Souza
I have tested ptop with very good results. It does really what I want. 
As it is possible to get the default cfg with '-g, we can change it and 
call the changed cfg with '-c'. It's really  a powerful and easy tool.


Em 02-01-2012 14:29, Marco van de Voort escreveu:

In our previous episode, michael.vancann...@wisa.be said:

My editor is Gedit. In Linux, there are not lots of accessible
editors. For this reason, I don't think I will get a plugin to do it
for me.

So I ask: Does someone know a commandline tool that indents the code
automatically?

Yes. FPC comes with a tool ptop. It indents code. It is probably not as
powerful as the lazarus code formatter, but it does the job.

Hasn't been dialect updated for quite a while I think.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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


Re: [fpc-pascal] Testing applications with FPCUnit

2011-12-17 Thread Luciano de Souza

The article is very good, but it does not focuse on all aspects.

I have tried to create my first test example, but it didn't work. The 
compilation is successful and the program is executed without errors. 
However, I received no messages, informing the test has failed. 
Actually, the test should be failed.


This example is seemingly equivalent the minimum example  supplied by 
the article.


As recommended, I only add the unit test in the clause uses, so the 
test was expected to run. Does someone know what is wrong?


First of all, a unit with a routine to be tested:

unit numbers;
{$mode objfpc}{$h+}

interface
uses
Sysutils;

function calculate(a, b: integer):integer;
implementation

function calculate(a, b: integer):integer;
begin
result := a + b;
end;

INITIALIZATION
END.

Now, my testcase class:

unit test;
{$mode objfpc}{$h+}

interface
numbers, fpcunit, testregistry;
uses

type
TBugTest = class(TTestCase)
published
procedure calculate;
end;

implementation
procedure TBugTest.calculate;
begin
AssertEquals('The calculation is not done', 8, numbers.calculate(5, 4));
end;

INITIALIZATION
RegisterTest(TBugTest);
END.

Now, the runer:

program apptest;
{$mode objfpc}{$h+}

uses
test;

begin
end.

Em 16/12/2011 11:44, Michael Van Canneyt escreveu:



On Fri, 16 Dec 2011, Vincent Snijders wrote:


2011/12/16 luciano de souza luchya...@gmail.com:

Hello listers,

Navigating in FPC source codes, I found fpcunit. It's really
wonderful. With the tTestCase class, we can  generate a report with
the success or the failure of our tests.

Is there documentation on the usage of fpcunit? What is the best way
to study it?


Google found this (old) article:
http://www.freepascal.org/olddocs-html/fpcunit.pdf


It is old, but still correct.

I will see about refreshing it, and adding it in the FPC documentation.

Michael.


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



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

Re: [fpc-pascal] Testing applications with FPCUnit

2011-12-17 Thread Luciano de Souza

Michael,

I have a meaningful peculiarity: I am blind and I use Freepascal only in 
the console interface, reading all the output by means of my screen 
reader. Lazarus and Freepascal console IDE are both inaccessible. But, 
fortunately, for me, it's easy to call the compiler passing parameters 
at the command line.


I can compile using callings like:
fpc test.pas
fpc -XX test.pas
fpc test.pas -Fu./pas -FE./exe

I really thank Freepascal developers. The reachness of its command line 
allow me to access the features of the compiler.


For these reasons, it's not possible to open Lazarus and compile the 
project using its interface. My screen reader has an awful response in 
this environment.


After reading your message, I ask for a help. A friend told me fpcunit 
depends on FPCUnitConsole... Well, I don't remember exactly the name, 
but it's a Lazarus package.


Observe I need to compile in the console. If it's possible to run the 
executable, but it's not possible to compile in the command line, I 
won't be able to use FPCUnit.


You said that I need to use '--format=plain' '--all'. I tried:
fpc apptest.pas --format=plain -all
And also:
fpc apptest
apptest --format=plain -alll
But, in both cases, I got no result.
I don't know how to embody this parameters in my compilation tasks.

So I ask you: Is it possible to use FPCUnit only in the command line, it 
means, compiling and executing in console?


The idea of FPCUnit is really wonderful. I really would like to use it, 
but Lazarus dependences can complicate a lot.


Em 17/12/2011 11:02, Michael Van Canneyt escreveu:


You see no test results, because the program file of your test 
application is missing some essential things.


If you are using lazarus, simply create a new testing application:

First, make sure that package fpcunitide is installed.

Then, in the 'File-New' dialog, your testproject should be of type

'FPCUNit console test application'
or
'FPCUnit test application'

This will install a test decorator which prints out the result.
Then add your test unit to this application.

If you run the console test application on the command-line,
specify options '--format=plain' and '--all'

The graphical application will show test results in a tree.

Michael.

On Sat, 17 Dec 2011, Luciano de Souza wrote:


The article is very good, but it does not focuse on all aspects.

I have tried to create my first test example, but it didn't work. The 
compilation is successful and the program is executed without errors. 
However, I
received no messages, informing the test has failed. Actually, the 
test should be failed.


This example is seemingly equivalent the minimum example  supplied by 
the article.


As recommended, I only add the unit test in the clause uses, so 
the test was expected to run. Does someone know what is wrong?


First of all, a unit with a routine to be tested:

unit numbers;
{$mode objfpc}{$h+}

interface
uses
Sysutils;

function calculate(a, b: integer):integer;
implementation

function calculate(a, b: integer):integer;
begin
result := a + b;
end;

INITIALIZATION
END.

Now, my testcase class:

unit test;
{$mode objfpc}{$h+}

interface
numbers, fpcunit, testregistry;
uses

type
TBugTest = class(TTestCase)
published
procedure calculate;
end;

implementation
procedure TBugTest.calculate;
begin
AssertEquals('The calculation is not done', 8, numbers.calculate(5, 4));
end;

INITIALIZATION
RegisterTest(TBugTest);
END.

Now, the runer:

program apptest;
{$mode objfpc}{$h+}

uses
test;

begin
end.

Em 16/12/2011 11:44, Michael Van Canneyt escreveu:


  On Fri, 16 Dec 2011, Vincent Snijders wrote:

2011/12/16 luciano de souza luchya...@gmail.com:
  Hello listers,

  Navigating in FPC source codes, I found fpcunit. 
It's really
  wonderful. With the tTestCase class, we can 
 generate a report with

  the success or the failure of our tests.

  Is there documentation on the usage of fpcunit? 
What is the best way

  to study it?


Google found this (old) article:
http://www.freepascal.org/olddocs-html/fpcunit.pdf


  It is old, but still correct.

  I will see about refreshing it, and adding it in the FPC 
documentation.


  Michael.


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



--
Luciano de Souza




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



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

Re: [fpc-pascal] Testing applications with FPCUnit

2011-12-17 Thread Luciano de Souza

You would believe if I told you I could not compile yet?

It's not lack of effort, believe me. I really can't understand what is 
failing.


See my compilation script:

@echo off
set compilerpath=c:\lazarus\fpc\2.4.4\bin\i386-win32\fpc.exe
set unitpath=-Fuc:\lazarus\fpc\units\i386-win32\* 
-Fuc:\lazarus\units\i386-win32\* -Fuc:\lazarus\lcl\units\i386-win32\*

set debugerpath = c:\lazarus\mingw\bin\gdb.exe
Set NormalParam=-XX
set DebugParam=-g

if %1== goto end else goto start

:start
if %1==-n goto normalmode
if %1==-d goto debugmode
if %1==-g goto debuger
goto end

:normalmode
%compilerpath% %2 %NormalParam% %unitpath%
goto end

:debugmode
%compilerpath% %2 %DebugParam% %unitpath%
goto end

:debuger
gdb %1
goto end

:end

When I do: make -n {filename}, I got an error. fileutil is not found.

But fileutil is in c:\lazarus\lcl\units\i386-win32 and this path is 
already added.


Actually, I added this path in fpc.cfg.

Lazbuild seems to simplify compilation using Lazarus. But as a 
parameter, it receives a LPI file. However, lpi files are created in 
Lazarus interface. The lack of accessibility of Lazarus is so big that 
even this task I could not do at Lazarus interface.


If LPI files are really necessary, I must create then manually.

Em 17/12/2011 16:11, Mattias Gaertner escreveu:

On Sat, 17 Dec 2011 17:47:49 +0100
Felipe Monteiro de Carvalhofelipemonteiro.carva...@gmail.com  wrote:


On Sat, Dec 17, 2011 at 5:03 PM, Luciano de Souzaluchya...@gmail.com  wrote:

I can compile using callings like:
fpc test.pas
fpc -XX test.pas
fpc test.pas -Fu./pas -FE./exe

You can compile Lazarus projects in the command line using lazbuild
which comes with Lazarus, like this:

lazbuild project.lpi

It will build all required projects and otherwise do everything the
IDE would do to build the project. The only catch might be if the
package requires a package that your Lazarus doesn't know. I don't
know which configuration file would need to be modified to tell
Lazarus where a package is without opening the IDE.

lazbuild path/packagename.lpk

Mattias

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



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


[fpc-pascal] Testing applications with FPCUnit

2011-12-16 Thread luciano de souza
Hello listers,

Navigating in FPC source codes, I found fpcunit. It's really
wonderful. With the tTestCase class, we can  generate a report with
the success or the failure of our tests.

However, only observing the source code, it's not easy to comprehend
how it works. I found a single parcial example, showing the usage of
AssertEqual, but it was not enough to understand.

I have never used something like that. I know other languages have
similar features, but I have never programed tests in other languages.

Is there documentation on the usage of fpcunit? What is the best way
to study it?

regards,

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


Re: [fpc-pascal] Testing applications with FPCUnit

2011-12-16 Thread Luciano de Souza
Perhaps becouse I am not an experienced programer, but the code sounds a 
little complex. However, the effort will bring large bennefits.


Thank you very much for the article. It will help me a lot.



Em 16/12/2011 11:44, Michael Van Canneyt escreveu:



On Fri, 16 Dec 2011, Vincent Snijders wrote:


2011/12/16 luciano de souza luchya...@gmail.com:

Hello listers,

Navigating in FPC source codes, I found fpcunit. It's really
wonderful. With the tTestCase class, we can  generate a report with
the success or the failure of our tests.

Is there documentation on the usage of fpcunit? What is the best way
to study it?


Google found this (old) article:
http://www.freepascal.org/olddocs-html/fpcunit.pdf


It is old, but still correct.

I will see about refreshing it, and adding it in the FPC documentation.

Michael.


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



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

[fpc-pascal] Sorting an open unidimensional array

2011-12-11 Thread Luciano de Souza

Hello listers,

I want to sort an open unidimensional array of integers from the minimum 
to the maximum and from the maximum to the minimum.


Is there a standard unit providing this kind of service? Regarding the 
number of elements is not very high, I don't need complex algorithms.


Thank you in advance!

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


Re: [fpc-pascal] Sorting an open unidimensional array

2011-12-11 Thread Luciano de Souza
Yes, the unit seems to be very complete. I will study it and I am sure 
good results will come up!


Thank you!

Em 11/12/2011 18:18, Martin Schreiber escreveu:

On 12/11/2011 09:10 PM, Luciano de Souza wrote:

Hello listers,

I want to sort an open unidimensional array of integers from the minimum
to the maximum and from the maximum to the minimum.


MSEgui has sorting functions for dynamic arrays in
lib/common/kernel/msearrayutils.pas.

http://gitorious.org/mseide-msegui/mseide-msegui/blobs/master/lib/common/kernel/msearrayutils.pas

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



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


[fpc-pascal] The best approaching for templating

2011-11-07 Thread luciano de souza
Hello listers,

I would like to create some templates. Suppose the following example:

html
head
title%s/title
/head
body
%s p
%s p
%s p
/body
/html

I can certainly use format to link %s to the respective variables.
However, if the number of %s is big, probabily, the reading would be
less clearer.

But, suppose I have $title in stead of %s and $p1 in stead of %s. In
Lua, I have a module called Cosmo taht perform it.

my question is: is there something similar in Pascal?

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


[fpc-pascal] Using areq.getnextpathinfo in a CGI module

2011-11-01 Thread Luciano de Souza

Hello listers,

I am trying to understand how to create some code using Custcgi. 
However, the following peace is not clear for me concerning to 
getnextpathinfo. Let's see:


program cgiproject1;

{$mode objfpc}{$H+}

uses
  HTTPDefs, custweb, custcgi, main;

type

  { TMyCGIHandler }

  TMyCGIHandler = class(TCGIHandler)
  public
procedure HandleRequest(AReq: TRequest; ARes: TResponse); override;
  end;

  TMyCGIApp = class(TCustomCGIApplication)
  protected
function InitializeWebHandler: TWebHandler; override;
  end;

procedure TMyCGIHandler.HandleRequest(AReq: TRequest; ARes: TResponse);
begin
  if AReq.GetNextPathInfo = 'test' then
CGITest(AReq, ARes)
  else
CGIAbreHtml(AReq, ARes);
end;

function TMyCGIApp.InitializeWebHandler: TWebHandler;
begin
  Result := TMyCGIHandler.Create(self);
end;

begin
  With TMyCGIApp.Create(Nil) do
try
  Initialize;
  Run;
finally
  Free;
end;
end.

The code seems to be logical. I created a tCGIApplication derived from 
tCustomApplication, in other words, the object responsible for the 
program initialization.


By means of initializeWebHandler, a tCGIHandler object is created. Of 
course, this is the responsible for requests and responses handling.


Everything is good until:

if AReq.GetNextPathInfo = 'test' then
CGITest(AReq, ARes)
  else
CGIAbreHtml(AReq, ARes);
en

What does it mean AReq.GetNextPathInfo = 'test'?

Best regards,

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


[fpc-pascal] A linking error when compiling with FPC 2.4.4

2011-10-31 Thread Luciano de Souza

Hi listers,

I have installed FPC 2.4.4 using the following package:
http://mirrors.iwi.me/lazarus/snapshots/fpc-2.4.4-1.i386.deb.tar
Having unpacked it in a folder, I did:
sudo dpkg -i *.deb
The instalation was seemingly successful since I could compile some 
sources. However, compiling the attached example, I got an error:

fpc macuco.pas  output
The output file has received the following content:
Free Pascal Compiler version 2.4.4-1 [2011/05/24] for i386
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Linux for i386
Compiling macuco.pas
Compiling macbase.pas
Linking macuco
macuco.pas(14,1) Error: Error while linking
macuco.pas(14,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not 
specify a source file to be compiled)


The executable was not generated. In its place, I found link.res. The 
compilation was successful, but for a unknown reason, the linkage was 
not completed. I don't understand what the statements in link.res means 
indeed.
In spite of the output redirection, a  statement was writen in console 
in stead of the output file.


Cannot find -lsqlite3

I tried a reinstalation:

sudo apt-get purge fp-compiler
sudo apt-get autoremove
cd /home/luciano/fpc-2.4.4-1.i386/
sudo dpkg -I *deb

After it, the compiler shows the same behaviour and the described error 
continues. The compiler seems to be working correctly when I don't use 
uses db, sqlite3ds'.

Does someone know what it is wrong?
I use FPC 2.4.4 without Lazarus and Ubuntu 10.10.

Luciano
SEARCH_DIR(/lib/)
SEARCH_DIR(/usr/lib/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/httpd22/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/rtl/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fpgtk/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/gtk1/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fftw/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/x11/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/utmp/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fcl-js/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/mysql/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/libcurl/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/libgd/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fcl-registry/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/hash/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/gmp/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/ncurses/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/pcap/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/pthreads/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fcl-json/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/gtk2/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/ggi/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/libsee/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/libpng/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/pasjpeg/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fcl-res/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/iconvenc/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/lua/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/ldap/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fcl-db/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/odbc/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fcl-async/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fcl-extra/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/gdbm/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/sqlite/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/a52/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/proj4/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/httpd13/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/openal/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/cairo/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/hermes/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/paszlib/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/unixutil/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/lexyacc/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/svgalib/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/mad/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/opengl/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/symbolic/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/dbus/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/opencl/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/chm/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/dts/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fcl-base/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/modplug/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fv/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/numlib/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/oggvorbis/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/gnome1/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/graph/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fppkg/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/pxlib/)
SEARCH_DIR(/usr/lib/fpc/2.4.4/units/i386-linux/fcl-xml/)

[fpc-pascal] CGI under Freepascal

2011-10-18 Thread Luciano de Souza

Hello listers,

I am trying to use CGI with Pascal. I don't have background in web 
development, but principles of CGI seems to be simple.


The first way could be FPWeb. However, I prefer another solution even if 
it is the best bet. It requires complex compilations and configurations 
since it's not available in a deb package. So I want an alternative 
working with FPC 2.4.4.


The second attempt was custcgi. Except for the source code and an single 
example sent to a friend, no more documentation I found. I tried also 
Ezcgi, but the lack of documentation and examples are big obstacles.


What I want to create something simple with a minimum support of CGI 
facilities, but without onus of instalations, compilations and 
configurations.


I don't matter if the solution is modern or old, if only a set of some 
few resources are available, if the method is not appropriate to a large 
quantity o of simultaneous users, for me, it's important the solution 
only works.


With a tStringList.loadfromfile, I can load a HTML file and show it 
iterating on list elements. If this is not my option is because the 
difficulty to process variables received from a form. So a minimum of 
specialized routines should be available.


The variety of projects under Freepascal is so big that I will be not 
surprised with other solutions for my problem. What do you suggest for me?


Regards,

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


[fpc-pascal] Error when translating a C header

2011-10-03 Thread Luciano de Souza

Hi listers,

I tried to translate a C header with:

h2pas -e -d -p iupkey.h

I got the following error:

at line 21 error : syntax error
at line 41 error : syntax error
Illegal character in line 45
#define K_at  '@'   /* 64 */
Illegal character in line 73
#define K_backslash   '\\'  /* 92 */
Illegal character in line 73
#define K_backslash   '\\'  /* 92 */
Illegal character in line 75
#define K_circum  '^'   /* 94 */
Illegal character in line 77
#define K_grave   '`'   /* 96 */
Illegal character in line 113
#define K_BS '\b'   /* 8 */
Illegal character in line 114
#define K_TAB'\t'   /* 9 */
Illegal character in line 115
#define K_LF '\n'   /* 10 (0x0A) not a real key, is a 
combination of CR with a modifier, just to document */

Illegal character in line 116
#define K_CR '\r'   /* 13 (0x0D) */
LexLib: yytext overflow

I could understand if the Pascal unit was generated, but not compiled. 
What I can't understand is that even the Pascal unit, h2pas was not able 
to produce.


I am trying to translate it becouse it is very important for me. 
Actually, I don't know C, but I hope I can complete the task.


I am blind and I am trying to create graphical interfaces. It seems to 
be so curious, but I can make sure the idea is reasonable and suitable. 
Of course, I cwon't conceive beautiful interfaces. But with the help of 
IUP, a graphical interface library which supports automatic layout, I 
will produce dialogs  interacting very good with screen readers.


As my objective is to program to blind people, beauty is not properly a 
requirement. Having used IUP with Lua, I know it works, but now, to use 
it with Pascal, I need to overcome this initial difficulties.


Does someone know how to convert it? Why the unit, even wrong, is not 
created?


Luciano
/** \file
 * \brief Keyboard Keys definitions.
 *
 * See Copyright Notice in iup.h
 */
 
#ifndef __IUPKEY_H 
#define __IUPKEY_H

/* from 32 to 126, all character sets are equal,
   the key code i the same as the character code. */

#define K_SP  ' '   /* 32 (0x20) */
#define K_exclam  '!'   /* 33 */
#define K_quotedbl'\'  /* 34 */
#define K_numbersign  '#'   /* 35 */
#define K_dollar  '$'   /* 36 */
#define K_percent '%'   /* 37 */
#define K_ampersand   ''   /* 38 */
#define K_apostrophe  '\''  /* 39 */
#define K_parentleft  '('   /* 40 */
#define K_parentright ')'   /* 41 */
#define K_asterisk'*'   /* 42 */
#define K_plus'+'   /* 43 */
#define K_comma   ','   /* 44 */
#define K_minus   '-'   /* 45 */
#define K_period  '.'   /* 46 */
#define K_slash   '/'   /* 47 */
#define K_0   '0'   /* 48 (0x30) */
#define K_1   '1'   /* 49 */
#define K_2   '2'   /* 50 */
#define K_3   '3'   /* 51 */
#define K_4   '4'   /* 52 */
#define K_5   '5'   /* 53 */
#define K_6   '6'   /* 54 */
#define K_7   '7'   /* 55 */
#define K_8   '8'   /* 56 */
#define K_9   '9'   /* 57 */
#define K_colon   ':'   /* 58 */
#define K_semicolon   ';'   /* 59 */
#define K_less''   /* 60 */
#define K_equal   '='   /* 61 */
#define K_greater ''   /* 62 */
#define K_question'?'   /* 63 */
#define K_at  '@'   /* 64 */
#define K_A   'A'   /* 65 (0x41) */
#define K_B   'B'   /* 66 */
#define K_C   'C'   /* 67 */
#define K_D   'D'   /* 68 */
#define K_E   'E'   /* 69 */
#define K_F   'F'   /* 70 */
#define K_G   'G'   /* 71 */
#define K_H   'H'   /* 72 */
#define K_I   'I'   /* 73 */
#define K_J   'J'   /* 74 */
#define K_K   'K'   /* 75 */
#define K_L   'L'   /* 76 */
#define K_M   'M'   /* 77 */
#define K_N   'N'   /* 78 */
#define K_O   'O'   /* 79 */
#define K_P   'P'   /* 80 */
#define K_Q   'Q'   /* 81 */
#define K_R   'R'   /* 82 */
#define K_S   'S'   /* 83 */
#define K_T   'T'   /* 84 */
#define K_U   'U'   /* 85 */
#define K_V   'V'   /* 86 */
#define K_W   'W'   /* 87 */
#define K_X   'X'   /* 88 */
#define K_Y   'Y'   /* 89 */
#define K_Z   'Z'   /* 90 */
#define K_bracketleft '['   /* 91 */
#define K_backslash   '\\'  /* 92 */
#define K_bracketright ']'  /* 93 */
#define K_circum  '^'   /* 94 */
#define K_underscore  '_'   /* 95 */
#define K_grave   '`'   /* 96 */
#define K_a   'a'   /* 97 (0x61) */
#define K_b   'b'   /* 98 */
#define K_c   'c'   /* 99 */
#define K_d   'd'   /* 100 */
#define K_e   'e'   /* 101 */
#define K_f   'f'   /* 102 */
#define K_g   'g'   /* 103 */
#define K_h   'h'   /* 104 */
#define K_i   'i'   /* 105 */
#define K_j   'j'   /* 106 */
#define K_k   'k'   /* 107 */
#define K_l   'l'   /* 108 */
#define K_m   'm'   /* 109 */
#define K_n