Re: [Lazarus] Write to UNC or mapped drive

2016-05-26 Thread Leonardo M . Ramé



El 26/05/16 a las 08:22, Santiago A. escribió:

El 25/05/2016 a las 21:48, Marc Weustink escribió:

Correct. Drivemappings are user specific. You get the same if you want
to run something as administrator from a mapping.

More than user specific are desktop session specific.


Depends on windows version, iirc on modern versions local system (or was it 
local service) it has no network access
Marc


I think there is a user named "NetworkService", that at least has access
to network. Obviously, it has to open the session on the remote resource.

--
Saluds

Santiago A.
s...@ciberpiula.net




Thanks to all. The solution was to impersonate the user, then create the 
mapped drive by code (using the NetUseAdd function, see below), write 
the files to the destination drive, then NetUseDelete:


function Impersonate(const User, PW: string): Boolean;
var
  LogonType : Integer;
  LogonProvider : Integer;
  TokenHandle   : THandle;
  strAdminUser  : string;
  strAdminDomain: string;
  strAdminPassword  : string;
begin
  LogonType := LOGON32_LOGON_INTERACTIVE;
  LogonProvider := LOGON32_PROVIDER_DEFAULT;
  strAdminUser := USER;
  strAdminDomain := '';
  strAdminPassword := PW;
  Result := LogonUser(PChar(strAdminUser), nil,
PChar(strAdminPassword), LogonType, LogonProvider, TokenHandle);
  if Result then
  begin
Result := ImpersonateLoggedOnUser(TokenHandle);
  end;
end;

function NetUseAdd(const LocalName, RemoteName, UserName, Password: 
string; var AccessName: string): DWord;

var
  netResource: TNetResource;
  dwResult, dwBufSize, dwFlags: DWORD;
  hRes: DWORD;
  buf: array[0..1024] of Char;
begin
  dwFlags := CONNECT_REDIRECT;
  ZeroMemory(@netResource, sizeof(TNetResource));
  with netResource do begin
dwType := RESOURCETYPE_DISK;
lpLocalName := PAnsiChar(LocalName);
lpRemoteName := PAnsiChar(RemoteName);
lpProvider := nil;
  end;
  dwBufSize := Sizeof(buf);
  result := WNetUseConnection(0, netResource, PAnsiChar(Password), 
PAnsiChar(UserName), dwFlags, buf, dwBufSize, dwResult);

  if hRes = NO_ERROR then
AccessName := buf;
end;

function NetUseDelete(const LocalName: string): Boolean;
var
  hRes: DWORD;
begin
  hRes := WNetCancelConnection2(PChar(LocalName), 
CONNECT_UPDATE_PROFILE, true);

  result := (hres = NO_ERROR);
end;

To use these:

var
  lAccess: string;

begin
  if Impersonate('user', 'pass') then
  begin
NetUseAdd('X:', '\\server\directory', 'remoteuser', 'remotepass', 
lAccess);

// write files to X:\
NetUseDelete('X:');
  end;
end;


Regards,
--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877

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


[Lazarus] Write to UNC or mapped drive

2016-05-24 Thread Leonardo M . Ramé
Hi, My app is a CGI running on Windows2012 (IIS 7.0), it needs to save a 
file to a remote UNC or Mapped drive, but when I check using 
DirectoryExists in both cases I get False, but of course the UNC and 
mapped drive exists.


Any hint?.

Regards,
--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877

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


[Lazarus] test

2016-05-05 Thread Leonardo M . Ramé


--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877

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


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

2016-04-15 Thread Leonardo M . Ramé

El 15/04/16 a las 16:33, silvioprog escribió:

On Fri, Apr 15, 2016 at 4:25 PM, Leonardo M. Ramé <l.r...@griensu.com
<mailto:l.r...@griensu.com>> wrote:
[...]

It works pefectly por param=value&..., but I don't know how to parse
array type values.

example: ?filters[0]['filter']=name[0]['value']=john


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

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

The parser can populate a class structure like:

=== code ===

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

   TFilters = class(TFPGMapObject)
   end;

=== /code ===




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


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


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

2016-04-15 Thread Leonardo M . Ramé



El 15/04/16 a las 16:22, Michael Van Canneyt escribió:



On Fri, 15 Apr 2016, Leonardo M. Ramé wrote:


Hi, I need to extract the field values of a GET query of type:

http://127.0.0.1/cgi-bin/test.cgi?fields[1]=f1value[2]=f2value

Is there a way to handle this apart from HttpRequest.QueryFields?


What other way would you like ? What is not good about this way ?

Michael.


It works pefectly por param=value&..., but I don't know how to parse 
array type values.


example: ?filters[0]['filter']=name[0]['value']=john

Regards,
--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877


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


[Lazarus] fcl-web or BrookFramework queryfields array

2016-04-15 Thread Leonardo M . Ramé

Hi, I need to extract the field values of a GET query of type:

http://127.0.0.1/cgi-bin/test.cgi?fields[1]=f1value[2]=f2value

Is there a way to handle this apart from HttpRequest.QueryFields?

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

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


Re: [Lazarus] Raspberry Pi 3 Now Available

2016-02-29 Thread Leonardo M . Ramé

El 29/02/16 a las 12:48, Dennis escribió:

The speed of hardware improvement is so impressive and at the same time
so scary. For those of us who have spent so much time optimizing the
software so as to run smoothly on earlier primitive hardware, our effect
seems so obsolete and silly from hindsight.

Dennis


Anthony Walter wrote:

This is just a heads up to Lazrus/FPC users who are interested in the
Raspberry Pi.

Raspberry Pi is now available. New features include integrated
wireless bluetooth, and a quad-core 64-bit ARM Cortex A53 clocked at
1.2 GHz.

https://www.raspberrypi.org/blog/raspberry-pi-3-on-sale


Does anyone know if this version includes a Gigabit nic? or allows USB 3 
(to let ethernet-usb conversion) ?. I've read version 2 had slow network 
transfer because of only allowing USB2.


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


Re: [Lazarus] Lazarus on my ancient computer?

2016-02-17 Thread Leonardo M . Ramé

El 14/02/16 a las 11:34, Mark Morgan Lloyd escribió:

Sven Barth wrote:

On 14.02.2016 15:14, Bart wrote:

Hi,

This is a bit off-topic.

I have an ancient computer: Intel Celeron 700Mhz, 512MB RAM, 20GB 
IDE HD.

(http://flyingsheep.nl/computer_nostalgie.htm#celeron700)
(Hardware upgrades are not in the picture.)


[snip]


So, do you have tips on which Linux flavour to install on this machine?


I'd suggest ArchLinux. It's a very lightweight distro that's based on a
rolling release (like Gentoo), but uses binary packages instead. I use
it on my two main computers. On one I'm only using Awesome as window
manager and on the other OpenBox. Nothing else.


Alternatively, I run Debian "Lenny" with KDE on a number of machines 
of that sort of spec. For later Debians consider XFCE irrespective of 
system spec.


+1 I run XUbuntu, that comes with XFCE instead of Unity and runs pretty 
well on low end PCs..


Regards,

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

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


Re: [Lazarus] TOracleConnector connect as SYSDBA

2016-01-20 Thread Leonardo M . Ramé


El 19/01/16 a las 15:55, Leonardo M. Ramé escribió:

Hi, does anyone know how to connect to Oracle as SYSDBA?, I'm getting
"ORA-01017: invalid username/password; logon denied" when I set these
params:

Hostname: 127.0.0.1
Database: MYDB
User: sys as SYSDBA
Pass: MYPASSWORD
Role: SYSDBA (this field is not taken into account -apparently-)

If, instead of using "sys as SYSDBA" I use "sys" alone, I get
"ORA-28009: connection as SYS should be as SYSDBA or SYSOPER".


I've found a solution, instead of using "sys as SYSDBA" I used the 
username "system", and leave Role empty.


Leonardo.

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


[Lazarus] TOracleConnector connect as SYSDBA

2016-01-19 Thread Leonardo M . Ramé
Hi, does anyone know how to connect to Oracle as SYSDBA?, I'm getting 
"ORA-01017: invalid username/password; logon denied" when I set these 
params:


Hostname: 127.0.0.1
Database: MYDB
User: sys as SYSDBA
Pass: MYPASSWORD
Role: SYSDBA (this field is not taken into account -apparently-)

If, instead of using "sys as SYSDBA" I use "sys" alone, I get 
"ORA-28009: connection as SYS should be as SYSDBA or SYSOPER".



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

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


Re: [Lazarus] Different behavior of method and class variables

2015-11-30 Thread Leonardo M . Ramé
Please, forget about this. I was using a header for a different version 
of the dll.



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

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


[Lazarus] Different behavior of method and class variables

2015-11-29 Thread Leonardo M . Ramé

I'm creating a class out of a C header converted to pascal using h2pas.

I created this type:

pRobotArray = ^TArray0toMAX_ROBOT_DRIVES1OfHANDLE;

If I use it inside a method, like this:

procedure TMyClass.myMethod;
var
  lRobots: pRobotArray;
begin
  getRobots(lHRobots);
  lRobots := @lHRobots; // this works ok.
end;

If I add an FRobots var to my class:

TRobotClass = class
private
  FRobots: pRobotArray;
public
  procedure myMethod;
end;

procedure TMyClass.myMethod;
begin
  getRobots(lHRobots);
  FRobots := @lHRobots; // I get an external SIGSEGV.
end;

Why the difference?.


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

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


Re: [Lazarus] Codetools and specialize

2015-11-16 Thread Leonardo M . Ramé



El 16/11/15 a las 09:18, Mattias Gaertner escribió:

On Mon, 16 Nov 2015 08:16:18 -0300
Leonardo M. Ramé <l.r...@griensu.com> wrote:


Hi, I'm trying to implement a method of an specialized class, but when I
type ctrl+space the IDE shows "Error: Identifier not found: specialize".
But I can compile this project without problems.

The definition of my class is this:

TActListStudies = class(specialize TBaseGAction)
public
procedure Post; override;
end;


Codetools do not yet support anonymous specialization.
See bug report:
http://bugs.freepascal.org/view.php?id=27895

Can you use below instead?

TBaseGActionDummy = specialize TBaseGAction;

TActListStudies = class(TBaseGActionDummy)
public
procedure Post; override;
end;



Hmm, when I change that, the same error is raised, this time in the
definition of TBaseGAction:

  generic TBaseGAction = class(specialize TBrookGAction)

...

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


[Lazarus] Codetools and specialize

2015-11-16 Thread Leonardo M . Ramé
Hi, I'm trying to implement a method of an specialized class, but when I 
type ctrl+space the IDE shows "Error: Identifier not found: specialize". 
But I can compile this project without problems.


The definition of my class is this:

TActListStudies = class(specialize TBaseGAction)
public
  procedure Post; override;
end;


And the implementation:

procedure TActListStudies.Post;
begin
  // here CTRL+SPACE raises the error.
  Write('Your content here ...');
end;



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

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


[Lazarus] File is locked?

2015-11-14 Thread Leonardo M . Ramé
Hi, I'm checking the contents of an .ini file every 10 seconds (with a 
TTimer), the file is modified by another application and I display its 
contents in my program.


The problem is the file is locked while the other program is using it 
and aparently TIniFile cannot handle this situation, thus raising an 
"Unable to open file" error. How can I check if the file is locked 
before reading its contents?.


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

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


Re: [Lazarus] TextHint, TextHintFontColor, TextHintFontStyle

2015-11-08 Thread Leonardo M . Ramé

El 08/11/15 a las 11:08, Bart escribió:

On 11/8/15, Leonardo M. Ramé <l.r...@griensu.com> wrote:


Hi, I noted there are new (to me) properties in some components, what's
the difference between those and the good old Hint property?.



TextHint fills the TCustomEdit with the value assigned to it, whenever
the control's Text property is empty and the control does not have
focus.
Hint only (and alwaysif showhint = true) displays a bloontip when the
mouse is over the control.

Just play with it:

Edit1.TextHint := 'Type your name here';

Bart


Thanks Bart, it's the same as Bootstrap's  placeholder property.

Regards,

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

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


[Lazarus] TextHint, TextHintFontColor, TextHintFontStyle

2015-11-08 Thread Leonardo M . Ramé
Hi, I noted there are new (to me) properties in some components, what's 
the difference between those and the good old Hint property?.


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

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


Re: [Lazarus] External SIGSEGV (random) when assigning TBookmark

2015-11-03 Thread Leonardo M . Ramé

El 03/11/15 a las 04:40, Michael Van Canneyt escribió:



On Mon, 2 Nov 2015, Leonardo M. Ramé wrote:



El 01/11/15 a las 09:25, Leonardo M. Ramé escribió:

Hi, I don't use data aware controls too often, but as I'm updating a
legacy application I have to use them.
...


I finally solved this by getting the value of a primary key, then
after TSQLQuery.refresh I do a locate for that key, works like a charm.

What I don't get is what's the purpouse of TBookmark, I thought it was
made for solving the problem I had.


Bookmarks are only valid until the dataset closes.
I will add this to the documentation.

Michael.



Ok, but apart from Closing/Opening or Refresh, is there any other way to 
reload a dataset without closing it? TSqlQuery.Refresh also loses the 
Bookmark.


Regards,
Leonardo.

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


Re: [Lazarus] External SIGSEGV (random) when assigning TBookmark

2015-11-02 Thread Leonardo M . Ramé


El 01/11/15 a las 09:25, Leonardo M. Ramé escribió:

Hi, I don't use data aware controls too often, but as I'm updating a
legacy application I have to use them.
...


I finally solved this by getting the value of a primary key, then after 
TSQLQuery.refresh I do a locate for that key, works like a charm.


What I don't get is what's the purpouse of TBookmark, I thought it was 
made for solving the problem I had.


Leonardo.

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


[Lazarus] External SIGSEGV (random) when assigning TBookmark

2015-11-01 Thread Leonardo M . Ramé
Hi, I don't use data aware controls too often, but as I'm updating a 
legacy application I have to use them.


Please take a look at this code. DataModule1.SQLQuery1 is a simple 
"select * from customers limit 10". What I want to accomplish is the 
refreshing of a DBGrid *without losing the focused row*, that's why I 
use a TBookmark.


To me, the code looks correct, but I'm getting a SIGSEGV while assigning 
the bookmark. I must add the error only happens the 2nd or 3rd time this 
method is called:


var
  lOldStatus: string;
  lBookmark : TBookmark;
begin
  lOldStatus := StatusBar1.Panels[1].Text;
  StatusBar1.Panels[1].Text := 'Updating...';
  lBookmark := DataModule1.SQLQuery1.Bookmark;
  DataModule1.SQLQuery1.DisableControls;
  DataModule1.SQLQuery1.Close;
  DataModule1.SQLQuery1.Open;
  DataModule1.SQLQuery1.EnableControls;
  DataModule1.SQLQuery1.Bookmark := lBookmark; <-- Random SIGSEGV
  StatusBar1.Panels[1].Text := lOldStatus;
end;

--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877

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


Re: [Lazarus] Printing on Raspberry Pi

2015-10-30 Thread Leonardo M . Ramé

El 29/10/15 a las 12:24, Koenraad Lelong escribió:

Hi,

I'm trying to print a lazreport on a Raspberry Pi2.
It's not working, I get :
Bus Error or misaligned data access
Press OK to ignore ...

Pressing OK does nothing.

Any suggestions to solve this ?

I also tried the example from
http://wiki.lazarus.freepascal.org/Using_the_printer. On my x86
linux-machine this works, on the RPi, nothing happens.

Koenraad.



Hi Koenraad, can you print using the RPi from other applications?.

Regards,
Leonardo.

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


Re: [Lazarus] Theoretical question about future of Lazarus

2015-10-12 Thread Leonardo M . Ramé

El 12/10/15 a las 09:03, JuuS escribió:

Hi,

Lazarus has had the number schemes 0.xxx to now of 1.4.xx

Before falling asleep it passed through my mind about a lazarus 2.xx and...

...I thought what could it be? Lazarus is already so good and so feature
filled that I struggled to understand what could possibly be in or
justify a Lazarus 2.xx

Any thoughts from anyone what a Laz 2 would be?

Julius



An api for command line .lpi handling, I user "lazbuild -B 
myproject.lpi" for command line compiling, and I wonder if there's 
something similar for project creation, package inclusion, etc.




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

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


Re: [Lazarus] PostgreSql: unexpected EOF on client connection with an open transaction

2015-09-02 Thread Leonardo M . Ramé

Do you have a second transaction object (e.g. default transaction) ?
If so, that's probably it.

Michael.




No, just a TSQLTransaction attached to the TPQConnection object.

I commented all my code but the PQConnection1.Connected := True, and I 
noted I get the "could not receive data from client: Connection reset by 
peer" message just after the CGI program ends its execution.


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


Re: [Lazarus] PostgreSql: unexpected EOF on client connection with an open transaction

2015-09-02 Thread Leonardo M . Ramé


El 02/09/15 a las 16:11, Leonardo M. Ramé escribió:

El 02/09/15 a las 16:00, Michael Van Canneyt escribió:


Well, that is why I asked how it is closed. Maybe it was closed a
different way in your CGI, without properly closing it.
The strange thing is that it reports an active transaction.

Do you open a dataset ? If so, try setting Unidirectional:=True before
opening it.
(this avoids extra queries to fetch unique key data etc.)



No, the error is raised even when I only have a TDataModule with a
PQConnection.Connect on it's onCreate event.

I'll ask Silvio, because I'm using Brook Framework, and maybe the way
TBrookApp is handling creation/drestruction of TDatamodule is different
than with TApplication, and it seems that onDestroy is not called.




I think I found a bug in Brook.

My .lpr now has this:

begin
  BrookApp.CreateForm(TDataModule1, DataModule1);
  BrookApp.Run;
  DataModule1.Free; // this fixes the issue.
end.




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


Re: [Lazarus] PostgreSql: unexpected EOF on client connection with an open transaction

2015-09-02 Thread Leonardo M . Ramé

El 02/09/15 a las 15:09, Michael Van Canneyt escribió:



On Wed, 2 Sep 2015, Leonardo M. Ramé wrote:


Do you have a second transaction object (e.g. default transaction) ?
If so, that's probably it.

Michael.






Yes, I added an onDestroy event to the datamodule containing the 
PQConnection object and called PQConnection.Close(), but the efect is 
the same. BTW, the onCreate event is who calls PQConnection.Connect := True.


There must be a problem in the CGI, because I created a desktop app with 
just a PQConnection, SQLTransaction and SQLQuery and the message isn't 
logged on the server's log.


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


Re: [Lazarus] PostgreSql: unexpected EOF on client connection with an open transaction

2015-09-02 Thread Leonardo M . Ramé

El 02/09/15 a las 16:00, Michael Van Canneyt escribió:


Well, that is why I asked how it is closed. Maybe it was closed a
different way in your CGI, without properly closing it.
The strange thing is that it reports an active transaction.

Do you open a dataset ? If so, try setting Unidirectional:=True before
opening it.
(this avoids extra queries to fetch unique key data etc.)



No, the error is raised even when I only have a TDataModule with a 
PQConnection.Connect on it's onCreate event.


I'll ask Silvio, because I'm using Brook Framework, and maybe the way 
TBrookApp is handling creation/drestruction of TDatamodule is different 
than with TApplication, and it seems that onDestroy is not called.



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


Re: [Lazarus] PostgreSql: unexpected EOF on client connection with an open transaction

2015-09-02 Thread Leonardo M . Ramé


El 02/09/15 a las 10:28, Marc Santhoff escribió:


Only guessing: maybe the transaction object is set to "autocommit" and
the .Commit statement produces the error?




It's configured to caRollBack.

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


[Lazarus] PostgreSql: unexpected EOF on client connection with an open transaction

2015-09-01 Thread Leonardo M . Ramé
Hi, this is kind of a dejavu, I'm pretty sure I have asked this question 
before, but I can't find the old message, so, here I go.


In my postgresql.log file I get this two messages every time I 
query/update the database:


could not receive data from client: Connection reset by peer
unexpected EOF on client connection with an open transaction

I'm using TPQConnection/TSqlTransaction/TSqlQuery in a CGI with this method:

procedure TDataModule1.ExecSql(ASql: string);
var
  lSql: TSQLQuery;
begin
  lSql := TSQLQuery.Create(nil);
  try
lSql.DataBase := PQConnection1;
lSql.Transaction := SQLTransaction1;
lSql.SQL.Text:= ASql;
lSql.ExecSQL;
SQLTransaction1.Commit;
  finally
lSql.Free;
  end;
end;

The query is executed without issues, data is stored into the db, but I 
keep getting those messages.


I'm using FPC 3.1.1 - Lazarus 1.5 - Linux 64bits (Ubuntu 15.04).

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

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


Re: [Lazarus] Protocol Buffers

2015-07-25 Thread Leonardo M. Ramé

On 25/07/15 06:31, Michael Van Canneyt wrote:



On Fri, 24 Jul 2015, Leonardo M. Ramé wrote:


Hi, does anyone know if there's a FreePascal implementation of
Protocol Buffers, it seems to fit perfectly in on use case I'm working
on:

https://developers.google.com/protocol-buffers/


Yes, there are several. See e.g. fundamentals.

http://fundementals.sourceforge.net/

Michael.


Nice!, I didn't know about this library.


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

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


Re: [Lazarus] Protocol Buffers

2015-07-25 Thread Leonardo M. Ramé

On 25/07/15 08:17, Aradeonas wrote:

Leonardo can you explain where you can use it?

Regards,
Ara




Currently one of my apps is sending JSON files to a server, with a 
structure similar to this:


{
  document_name: doc 1,
  document_type: pdf,
  content: BASE64_ENCODED_PDF
}

Where BASE64_ENCODED_PDF is an binary file that must be converted to 
base64 to be included into a json field.


The base64 encoding/decoding carries both processor and transfer size 
overhead, compared to a binary protocol.


Of course I could have created my own proprietary protocol, but I have 
some constraints, for example, the sender is a Java application, and the 
receiver is a FreePascal one, so, using a standard protocol, like 
Google's Protocol Buffers seems to fit very well in this particular 
scenario.


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

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


[Lazarus] Protocol Buffers

2015-07-24 Thread Leonardo M. Ramé
Hi, does anyone know if there's a FreePascal implementation of Protocol 
Buffers, it seems to fit perfectly in on use case I'm working on:


https://developers.google.com/protocol-buffers/

Regards,
--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877

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


Re: [Lazarus] Base64 broken in json?

2015-06-02 Thread Leonardo M. Ramé



El 02/06/15 a las 09:21, Michael Van Canneyt escibió:



On Tue, 2 Jun 2015, Leonardo M. Ramé wrote:

You cannot copypaste that, because there may be escaped characters in 
it.

If you are doing that, you are doing it wrong.



Hmm. That's the problem, then.

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


Re: [Lazarus] Base64 broken in json?

2015-06-02 Thread Leonardo M. Ramé



El 02/06/15 a las 04:20, Michael Van Canneyt escibió:



On Mon, 1 Jun 2015, Leonardo M. Ramé wrote:


El 30/05/15 a las 13:29, silvioprog escibió:

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


[Window Title]
project1

[Content]
{ var1 : bGVvbmFyZG8= } - leonardo

[OK]

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

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

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



Hi Silvio, can you try encoding the attached file, then output using
both methods?.


I tested your file with the following program:

program jsonb;

uses sysutils, classes, fpjson, jsonparser, base64;

Var
   O : TJSONObject;
   F : TFileStream;
   S : TStringStream;

begin
   S:=Nil;
   O:=Nil;
   try
 F:=TFileStream.Create(ParamStr(1),fmOpenRead);
 S:=TStringStream.Create('');
 With TBase64EncodingStream.Create(S) do
   try
 CopyFrom(F,0);
 Flush;
 O:=TJSONObject.Create(['file',S.DataString]);
   finally
 Free;
   end;
 FreeAndNil(S);
 S:=TStringStream.Create(O.Get('file'));
 S.Position:=0;
 FreeAndNil(F);
 F:=TFileStream.Create(ChangeFileExt(paramstr(1),'.base64'),fmCreate);
 F.CopyFrom(S,0);
   finally
 O.Free;
 F.Free;
 S.Free;
   end;
end.

cadwal: ./jsonb plantilla-original.ott
cadwal: base64 -d plantilla-original.base64  b.ott
cadwal: ls *.ott -l
-rw-rw-r-- 1 michael michael 41956 Jun  2 09:16 b.ott
-rw-rw-r-- 1 michael michael 41956 Jun  2 09:05 plantilla-original.ott
cadwal: cmp b.ott plantilla-original.ott

cmp reports all is well.

Michael.




Thanks Michael, what if you save the json object to file using:

with TStringList.Create do
begin
  Text := O.AsJson;
  SaveToFile('test.json');
end;

Then copy the content of the file variable, and save as test.base64? 
and try base64 -d test.base64, this is what I tried to do and got errors 
decoding.


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


Re: [Lazarus] Base64 broken in json?

2015-06-01 Thread Leonardo M. Ramé

El 30/05/15 a las 13:29, silvioprog escibió:

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


[Window Title]
project1

[Content]
{ var1 : bGVvbmFyZG8= } - leonardo

[OK]

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

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

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



Hi Silvio, can you try encoding the attached file, then output using 
both methods?.


Leonardo


plantilla-original.ott
Description: application/vnd.oasis.opendocument.text-template
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Base64 broken in json?

2015-05-30 Thread Leonardo M. Ramé

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



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


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


Normally not.


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


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

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

Michael.




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


I just concatenated a string like:

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

And it worked perfectly, while doing:

myJson.Add('var1', Base64EncodedString);

and

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


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

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


[Lazarus] Base64 broken in json?

2015-05-29 Thread Leonardo M. Ramé
Hi, does anyone know if when adding a base64 encoded string to an 
TJsonObject and calling AsJson method, the base64 is broken?


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



--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877

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


Re: [Lazarus] Base64 broken in json?

2015-05-29 Thread Leonardo M. Ramé

El 29/05/15 a las 14:55, Leonardo M. Ramé escibió:

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

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




Is weird but returning a json composed by hand worked without issues. 
I'll make an example and post to Mantis.


Leonardo.

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


Re: [Lazarus] Inserting enum type into Postgresql

2015-05-15 Thread Leonardo M. Ramé

El 15/05/15 a las 12:26, Michael Van Canneyt escibió:



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


Hi, I need to insert a value into a custom type column in a PostgreSql
database.

The type was created using this:

create type doc_type as enum('pdf', 'rtf', 'html', 'doc', 'docx',
'xls', 'xlsx', 'txt');

To insert a field into a table with one column of that type, I use:

var
 lQuery: TSqlQuery;

begin
 ...
 lQuery.Sql.Text := 'insert into documents(document_name,
document_type) values(:name, :type)';
 lQuery.ParamByName('type').AsString := 'txt';
 ...

I get Primary Error: column document_type is of type doc_type but
expression is of type text. How can I cast this?.


I would think
insert into documents(document_name, document_type)  values(:name,
(:type)::doc_type )';
?

Michael.




Yes, that was the solution.

Leonardo.

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


[Lazarus] Inserting enum type into Postgresql

2015-05-15 Thread Leonardo M. Ramé
Hi, I need to insert a value into a custom type column in a PostgreSql 
database.


The type was created using this:

create type doc_type as enum('pdf', 'rtf', 'html', 'doc', 'docx', 'xls', 
'xlsx', 'txt');


To insert a field into a table with one column of that type, I use:

var
  lQuery: TSqlQuery;

begin
  ...
  lQuery.Sql.Text := 'insert into documents(document_name, 
document_type) values(:name, :type)';

  lQuery.ParamByName('type').AsString := 'txt';
  ...

I get Primary Error: column document_type is of type doc_type but 
expression is of type text. How can I cast this?.


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

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


Re: [Lazarus] Error: Duplicate identifier $ansistrrec18

2015-04-28 Thread Leonardo M. Ramé

El 28/04/15 a las 07:16, Leonardo M. Ramé escibió:

Hi, I'm trying to build a CGI program using BrookFramework in FPC 3.1.1
and Lazarus compiled today but I'm getting this error:

Error: Duplicate identifier $ansistrrec18

That identifier of course is not a variable, nor unit name, and it can't
be found in any of the used files. Any hint?.

BTW, the error happens in a method of a Generic Class defined this way:

   generic TBaseGActionT = class(specialize TBrookGActionT)
   ...
   end;

Regards,


Changed to the fixes_3_0 branch and everything compiled flawlessly.

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

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


[Lazarus] Error: Duplicate identifier $ansistrrec18

2015-04-28 Thread Leonardo M. Ramé
Hi, I'm trying to build a CGI program using BrookFramework in FPC 3.1.1 
and Lazarus compiled today but I'm getting this error:


Error: Duplicate identifier $ansistrrec18

That identifier of course is not a variable, nor unit name, and it can't 
be found in any of the used files. Any hint?.


BTW, the error happens in a method of a Generic Class defined this way:

  generic TBaseGActionT = class(specialize TBrookGActionT)
  ...
  end;

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

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


Re: [Lazarus] Impressive web development

2015-04-17 Thread Leonardo M. Ramé

Nah, for web development leave me with Vim and I'll be happy.

El 14/04/15 a las 17:32, Graeme Geldenhuys escibió:

Hi,

I just came across this on Google+ - probably the most impressive web
app I've ever seen. It is called Codenvy and is a fully functional
zero-configuration integrated development environment.

   http://ow.ly/LBJUa 

Are we going to see such a web based Lazarus IDE soon? ;-)  It should
help stop all those FPC  Lazarus installation issue support emails. :)


Regards,
   - Graeme -




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


Re: [Lazarus] Cross Codebot surface drawing examples

2015-03-26 Thread Leonardo M. Ramé

El 21/03/15 a las 01:44, Anthony Walter escibió:

Here is a brief overview of some of custom rendering which can be done
with Cross Codebot graphics interfaces. A few videos are embedded in the
page below:

http://www.getlazarus.org/forums/viewtopic.php?f=18t=35p=150#p150

Here is a listing of the interfaces and their methods:

http://www.getlazarus.org/videos/crossgraphics/

If you're interested in testing the Cross Codebot package let me know
and I can provide user level account access to my private git server.



Hi Anthony, looks nice!, congrats for the great work you are doing.

BTW, please, include some introduction about Cross Codebot, some people 
(like me) doesn't know what it is.



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

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


Re: [Lazarus] Play video from memory

2015-03-06 Thread Leonardo M. Ramé
To embed mplayer into a window you must know its ID. Window IDs have a 
relation with the WindowHandle, but that value must be somehow 
translated to be understood by X11 (or Windows). I don't know how to 
translate it :(.


For example, If I use Format('%x', [Self.WindowHandle]) I get the Hex 
value BB5380, then, using the wininfo tool I can get the ID. Just run 
xwininfo and click on the window you want to embed mplayer into.


In my example I got:

xwininfo: Window id: 0x2800048 BB5380

  Absolute upper-left X:  662
  Absolute upper-left Y:  270
  Relative upper-left X:  1
  Relative upper-left Y:  24
  Width: 320
  Height: 240
  Depth: 24
  Visual: 0x20
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x22 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +662+270  -1744+270  -1744-258  +662-258
  -geometry 320x240+661+246

As you can see, the first line displays the same Hex number I get from 
Lazarus, and 0x2800048, this is the value mplayer expects.


So, to embed a movie into a window, when you know the window Id, you 
just launch mplayer using this options:


mplayer -wid 0x2800048 /home/leonardo/Imágenes/Fotos/2009/11/21/mvi_0260.avi

Please, if any you know how to translate BB5380 to 0x2800048 I'll be 
glad to learn.


El 05/03/15 a las 18:51, Philippe Lévi escibió:

and you know how to tell MPLAYER to show the video in a specific window? (using 
WINDOWS, and glutCreateWindow).

thanks
Philippe


De: Leonardo M. Ramé l.r...@griensu.com
Enviado: quinta-feira, 5 de março de 2015 17:44
Para: lazarus@lists.lazarus.freepascal.org
Assunto: Re: [Lazarus] Play video from memory

Yes, you can!.

1) Load your Video to a TStream (TMemoryStream for example).
2) Use TProcess to execute mplayer -, the - is the parameter.
3) Send your stream to the standard input of the process.


El 05/03/15 a las 16:45, aradeonas escibió:

Thank you Leonardo,

I saw it before but it doesn't seem there is a way to pass memory to it
or I couldn't find out how.
Do you know?

Regards,
Ara

On Thu, Mar 5, 2015, at 11:40 AM, Leonardo M. Ramé wrote:

It looks like MPlayer can do this:
http://www.mplayerhq.hu/DOCS/HTML/en/streaming.html

El 04/03/15 a las 13:29, aradeonas escibió:

Hi,

Any one know a library or way to buffer video file into memory and then
pass it to player?
Any simple player do the job but it should support a way to open file
from memory.

Regards,
Ara


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


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

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



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


Re: [Lazarus] Play video from memory

2015-03-05 Thread Leonardo M. Ramé
It looks like MPlayer can do this: 
http://www.mplayerhq.hu/DOCS/HTML/en/streaming.html


El 04/03/15 a las 13:29, aradeonas escibió:

Hi,

Any one know a library or way to buffer video file into memory and then
pass it to player?
Any simple player do the job but it should support a way to open file
from memory.

Regards,
Ara




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


Re: [Lazarus] Play video from memory

2015-03-05 Thread Leonardo M. Ramé

Yes, you can!.

1) Load your Video to a TStream (TMemoryStream for example).
2) Use TProcess to execute mplayer -, the - is the parameter.
3) Send your stream to the standard input of the process.


El 05/03/15 a las 16:45, aradeonas escibió:

Thank you Leonardo,

I saw it before but it doesn't seem there is a way to pass memory to it
or I couldn't find out how.
Do you know?

Regards,
Ara

On Thu, Mar 5, 2015, at 11:40 AM, Leonardo M. Ramé wrote:

It looks like MPlayer can do this:
http://www.mplayerhq.hu/DOCS/HTML/en/streaming.html

El 04/03/15 a las 13:29, aradeonas escibió:

Hi,

Any one know a library or way to buffer video file into memory and then
pass it to player?
Any simple player do the job but it should support a way to open file
from memory.

Regards,
Ara



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



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


[Lazarus] Missing (compatible) underlying dataset, can not open

2014-11-27 Thread Leonardo M. Ramé
Hi, I'm trying to execute this query, but I'm getting Missing 
(compatible) underlying dataset, can not open.


lQuery.DataBase := PQConnection1;
lQuery.ParseSQL:= false;
lQuery.SQL.Text:= 'select json_agg(resultset) as json from(select 1) as 
resultset';

lQuery.Open;

The query runs without problems in PostgreSql 9.3 both from pgAdmin and 
psql.


Any hint?.

--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877


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


Re: [Lazarus] Missing (compatible) underlying dataset, can not open

2014-11-27 Thread Leonardo M. Ramé


El 27/11/14 a las 12:26, Michael Van Canneyt escibió:



On Thu, 27 Nov 2014, Leonardo M. Ramé wrote:


Hi, I'm trying to execute this query, but I'm getting Missing
(compatible) underlying dataset, can not open.

lQuery.DataBase := PQConnection1;
lQuery.ParseSQL:= false;
lQuery.SQL.Text:= 'select json_agg(resultset) as json from(select 1)
as resultset';
lQuery.Open;

The query runs without problems in PostgreSql 9.3 both from pgAdmin
and psql.

Any hint?.


Yes: You are creating a result set with fields that are not recognized
by SQLDB (json type).
PQLib (on which pqconnection is based) also does not understand json
result fields, it converts them to text.

So, you must somehow typecast the result to string:

Probably

select json_agg(resultset)::text as myjson from(select 1) as resultset

should work.

Michael.




Great Michael!, that worked.

--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877


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


[Lazarus] OT: Fast image viewer

2014-11-05 Thread Leonardo M. Ramé
Hi, I'm lookig for a fast-small JPEG/BMP image viewer with Zoom, Pan, 
and Print (if possible), to be launched from my application and passing 
a File param or better a Stream to be opened.


Can anyone recommend such viewer?. I need it for Windows.

Regards,
--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877


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


Re: [Lazarus] OT: Fast image viewer

2014-11-05 Thread Leonardo M. Ramé


El 05/11/14 a las 15:08, Frederic Da Vitoria escibió:

2014-11-05 13:24 GMT+01:00 Leonardo M. Ramé l.r...@griensu.com
mailto:l.r...@griensu.com:

Hi, I'm lookig for a fast-small JPEG/BMP image viewer with Zoom,
Pan, and Print (if possible), to be launched from my application and
passing a File param or better a Stream to be opened.

Can anyone recommend such viewer?. I need it for Windows.


Maybe JPEGView? http://sourceforge.net/projects/jpegview/

If you want something better in terms of usability:
http://www.faststone.org/ , but definitely not as small as JPEGView

--
Frederic Da Vitoria
(davitof)


Thanks Frederic, JPEGView looks great!.

--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877


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


Re: [Lazarus] TAChart cannot zoom

2014-10-22 Thread Leonardo M. Ramé


El 21/10/14 a las 15:32, Werner Pamler escibió:

You have added a ChartToolset and have assigned it to the chart. This
deactivates the built-in toolset which is responsible for default
zooming and panning. All you have to do is to add another ZoomDragTool
to your toolset. To make it respond to dragging with the left mouse
button set its Shift property to ssLeft, this is the standard behavior
of the built-in zoom tool. If you need panning as well add a
ZoomPanTool; by default, it becomes active with the right mouse button.
But if you already use these Shift values in tools that are currently in
your toolset, select something else, or add a key like ssCtrl, or
ssShift (or both) - there are many possibilities.

There are several tutorial which cover zooming in TAChart:

  * http://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Chart_Tools,
  * http://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Function_Series
  * http://wiki.lazarus.freepascal.org/TAChart_Tutorial:_ColorMapSeries,_Zooming



Thanks Werner, I'll take a look at it.

--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877


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


[Lazarus] TAChart cannot zoom

2014-10-21 Thread Leonardo M. Ramé
Hi, I don't know what I did, but I no longer can zoom in / zoom out (by 
dragging the mouse pointer) my chart. If I draw 1000 data points, they 
all are drawn into the chart, but I only want to display part of that 
data, for example 100 points.


Here's the definition of my TAChart object (extracted from the lfm), I 
hope this help:


  object HAChart: TChart
Left = 0
Height = 206
Top = 302
Width = 582
AxisList = 
  item
Grid.Color = 2434341
TickColor = clSilver
Alignment = calRight
Group = 1
Marks.Format = '%0.2f'
Marks.Range.Max = 50
Marks.Style = smsCustom
Minors = 
Title.LabelFont.Orientation = 900
  end
  item
Grid.Color = clGray
Grid.Visible = False
Intervals.MaxLength = 100
Intervals.MinLength = 30
Alignment = calBottom
Marks.LabelFont.Orientation = 750
Marks.Format = '%2:s'
Marks.Source = ListChartSource1
Marks.Style = smsLabel
Minors = 
  end
BackColor = clBlack
ExpandPercentage = 5
Extent.UseYMin = True
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
Frame.Color = clMedGray
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Text.Strings = (
  'TAChart'
)
Toolset = ChartToolset1
OnAfterDrawBackWall = CandleStickChartAfterDrawBackWall
OnAfterPaint = CandleStickChartAfterPaint
Align = alClient
Color = clBlack
ParentColor = False
ParentShowHint = False
OnMouseMove = CandleStickChartMouseMove
  end


Regards,

--
Leonardo M. Ramébr
Medical IT - Griensu S.A.br
Av. Colón 636 - Piso 8 Of. Abr
X5000EPT -- Córdobabr
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19br
Cel.: +54 9 (011) 40871877


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


Re: [Lazarus] TProcess.Input hangs

2014-10-19 Thread Leonardo M. Ramé

On 17/10/14 20:54, Andrew Haines wrote:

On 10/17/14 11:46, Leonardo M. Ramé wrote:

Hi, I'm using this code to convert WAV files to MP3 on the fly, using
lame. It was working great until today.

It looks like this code has problems with large files sent to stdin.

lProcess := TProcess.Create(nil);
lProcess.Executable := '/usr/bin/lame';
lProcess.Parameters.Add('-');  // stdin
lProcess.Parameters.Add('-');  // stdout
lProcess.Options := [poUsePipes];
lProcess.Execute;
lWav.LoadFromFile('/home/leonardo/16310.wav');
lWav.Position:= 0;
lWav.SaveToStream(lProcess.Input); // --  here hangs
lProcess.CloseInput;


I also tried using this:

   repeat
 lReadCount := lProcess.Input.Write(lWav.Memory^, 500);
 if lReadCount  500 then
   lReadCount := 0;
   until lReadCount = 0;

But also hangs before lReadCount  500.

Any hint?



You are writing to stdin while the process is generating data to stdout.
If you don't empty stdout and stderr the process will hang.

There's lots of info here:
http://wiki.freepascal.org/Executing_External_Programs

You need something like

while lProcess.Running or (lProcess.StdOut.NumBytesAvailable  0) do
begin
   while lProcess.StdOut.NumBytesAvailable  0 do
   begin
 lReadCount := lProcess.StdOut.Read(Buffer, SizeOf(Buffer);
 if lReadCount  0 then
   // do something with encoded data
   end;

   // also you need to keep lProcess.StdErr empty or it can hang if it
gets full.
   while lProcess.StdErr.NumBytesAvailable  0 do
   begin
 lReadCount := lProcess.StdErr.Read(Buffer, SizeOf(Buffer);
 if lReadCount  0 then
   // do something with Stderr data
   end;

// now write data to be encoded.
lReadCount := lWav.Read(Buffer, SizeOf(Buffer));
lProcess.Input.Write(Buffer, lReadCount);
end;

Regards,

Andrew Haines


Thanks Andrew!, that fixed the issue.


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

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


[Lazarus] TProcess.Input hangs

2014-10-17 Thread Leonardo M. Ramé
Hi, I'm using this code to convert WAV files to MP3 on the fly, using 
lame. It was working great until today.


It looks like this code has problems with large files sent to stdin.

lProcess := TProcess.Create(nil);
lProcess.Executable := '/usr/bin/lame';
lProcess.Parameters.Add('-');  // stdin
lProcess.Parameters.Add('-');  // stdout
lProcess.Options := [poUsePipes];
lProcess.Execute;
lWav.LoadFromFile('/home/leonardo/16310.wav');
lWav.Position:= 0;
lWav.SaveToStream(lProcess.Input); // --  here hangs
lProcess.CloseInput;


I also tried using this:

  repeat
lReadCount := lProcess.Input.Write(lWav.Memory^, 500);
if lReadCount  500 then
  lReadCount := 0;
  until lReadCount = 0;

But also hangs before lReadCount  500.

Any hint?

--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877


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


[Lazarus] Alt + tab IDE Windows

2014-09-26 Thread Leonardo M. Ramé
Hi, on GTK2, when I alt+tab from another app, I would like to bring to 
front all Lazarus windows, instead I hav to alt+tab several times until 
each window (editor, menu, Object Inspector, etc.) comes to front.


Is it possible to link all lazarus windows in a way that when alt+tab 
they work as one app, instead of separated windows?.


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

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


Re: [Lazarus] Alt + tab IDE Windows

2014-09-26 Thread Leonardo M. Ramé

El 26/09/14 a las 10:52, William Ferreira escibió:

On IDE Options, try to enable 'Show single button in TaskBar'. Maybe
could help...



Yes, I tried that before asking, but sadly it does exactly the same.


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

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


[Lazarus] Anchordocking

2014-09-25 Thread Leonardo M. Ramé
Hi, from time to time I check this bug request: 
http://mantis.freepascal.org/view.php?id=26646 and found a comment added 
by Juha Manninen saying it won't work with laptop and external monitor, 
because of negative position.


I compiled the trunk version and tested again, on the right monitor it 
doesn't work, but as a workaround I found I can configure my docking 
layout on the left monitor, save it then close Lazarus. The next time I 
launch Lazarus it will open on the left monitor with my layout. A minor 
glitch is I only have to drag the window to the right monitor just after 
opening Lazarus.



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

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


Re: [Lazarus] Anchordocking

2014-09-25 Thread Leonardo M. Ramé

El 25/09/14 a las 11:12, Juha Manninen escibió:


On Thursday, September 25, 2014, Leonardo M. Ramé l.r...@griensu.com
mailto:l.r...@griensu.com wrote:

Hi, from time to time I check this bug request:
http://mantis.freepascal.org/__view.php?id=26646
http://mantis.freepascal.org/view.php?id=26646 and found a comment
added by Juha Manninen saying it won't work with laptop and external
monitor, because of negative position.


In fact I only changed the summary based on _your_ own comment.
I also marked it as duplicate to another issue as indicated in forum
discussion.

Personally I don't care about a docked IDE. I often want to have 2
editor windows, both from floor to ceiling, as high as possible. It
would not be possible with docking.
Earlier there were problems with many icons in task bar and then only
one IDE window could be selected at a time. It has been fixed since a
while and usability of the multi-window IDE is very good.
Partly this is a question of fashion. Now docked IDEs are in fashion but
maybe it will change again.

Juha



I also wouldn't care about docked windows if at least the ide could 
remember window position. Is it possible to save the window positions?.


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

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


Re: [Lazarus] Anchordocking

2014-09-25 Thread Leonardo M. Ramé

El 25/09/14 a las 13:07, Juha Manninen escibió:


On Thursday, September 25, 2014, Leonardo M. Ramé l.r...@griensu.com
mailto:l.r...@griensu.com wrote:

I also wouldn't care about docked windows if at least the ide could
remember window position. Is it possible to save the window positions?


It does remember the window positions. They are persistent, previous
positions are restored when you start Lazarus IDE.
Does it not work for you?

Juha




Great!, I didn't know that. Tested and it worked.

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

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


[Lazarus] TAChart DataPointCrossHairTool

2014-09-21 Thread Leonardo M. Ramé
Hi, I'm playing with the DataPointCrossHairTool, and I would like to 
know if it's possible to display the horizontal line on cursor's 
position, instead as the default data point value.


If mean, for example, my points are:

1: 10
2: 20
3: 30

When the mouse cursor is between 20 and 10, say 13 for example, the 
default behavior is displaying a line at 10 or 20, but what if I want to 
display the line just at 13?.



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

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


Re: [Lazarus] TAChart DataPointCrossHairTool

2014-09-21 Thread Leonardo M. Ramé

On 21/09/14 11:56, Werner Pamler wrote:

Hi, I'm playing with the DataPointCrossHairTool, and I would like to
know if it's possible to display the horizontal line on cursor's
position, instead as the default data point value.


Not 100% sure, but I believe that this tool always snaps to the data
points.
An alternative would be to add a constant line series to the chart and use
a TDatapointDragTool to drag the line. Use the chart's MouseDown to show
and
the MouseUp to hide the line. The toolsdemo in TAChart's demo folder
is an
example of the basic idea (the green and purple dashed vertical lines).


--


I kind of got what I need, based on Mouse.CursorPos and 
TAChart.ScreenToClient.


Now, I need to convert the mouse pos to a relative value to the axis.

In the AfterDrawBackWall event, to get current Y cursos position, I have:

ASender.ScreenToClient(Mouse.CursorPos).Y

Now, how can I convert that value to its relative to axis value.

Please, take a look at the attached screenshot, in the bottom chart, you 
can see the cursor and an horizontal line, with its value at the rigth 
axis, in this case is a 64 (yellow bold) between 3.50 and 4.00, instead 
of 64 I want to display the correct value (approx. 3.95).



--
Leonardo M. Ramé
http://leonardorame.blogspot.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TAChart DataPointCrossHairTool

2014-09-21 Thread Leonardo M. Ramé

On 21/09/14 16:54, Werner Pamler wrote:

To convert image coordinates (pixels within the chart rectangle which
you, indeed, can obtain from the global mouse position converted to the
local chart pixels) to graph coordinates you call the chart methods

* XImageToGraph(x:Integer): Double for x coordinates,
* YImageToGraph(y:Integer): Double for y coordinates, or
* ImageToGraph(P:TPoint): TDoublePoint (for both).

(or XGraphToImage() etc for the other direction).

If you do not use axis transformations, then graph coordinates directly
refer to the units of your data. If, on the other hand, axis
transformations are involved (logarithmic axes, multiple axes etc) the
values on the axes may be different from the graph units used in an
internal coordinate system. In this case, you have to link the series to
the axis (by means of the AxisIndexX and AxisIndexY properties) and call
the GraphToAxis or AxisToGraph methods of the AxisTransformation which
is obtained from the method GetTransform of the axis. In your example of
y values the transformation chain would be

   mouse point yi -- graph coords by yg := Chart.YImageToGraph(yi) --
axis coords by ya := Chart.LeftAxis.GetTransform.GraphToAxis(yg).

Here, ya refers to your input data, yi to the pixel data.

But since you don't use transformations YImageToGraph is sufficient.




Great!, here's a screenshot.

Meanwhile I found a way to get the Y pixel value of a point, as you can 
see, the 19.60 with yellow background refers to the last point in my 
series, and is drawn exactly at the same position of the Close Y Point. 
For this I used GetYImgValue( Index of last point ) of the series.


--
Leonardo M. Ramé
http://leonardorame.blogspot.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Hint as text over TAChart

2014-09-20 Thread Leonardo M. Ramé
Hi, I want to display the value of the point below the mouse cursor as 
text over the chart.


The way I'm trying to implement this is by first add a TChartToolSet and 
DataPointHintTool, with an onHintPosition event handler to determine the 
point value, for example:


procedure TForm1.ChartToolset1DataPointHintTool1HintPosition(
  ATool: TDataPointHintTool; var APoint: TPoint);
begin
  FmyHint := Format('O: %f, H: %f, L: %f, C: %f',
[FOHLCArray[ATool.PointIndex].open,
FOHLCArray[ATool.PointIndex].high,
FOHLCArray[ATool.PointIndex].low,
FOHLCArray[ATool.PointIndex].close]);
end;

This just set a value for a variable, in this case FMyHint. Then, to 
draw the value over the chart, I use the onAfterPaint event of TAChart:


procedure TForm1.Chart1AfterPaint(ASender: TChart);
begin
  Sender.Canvas.TextOut(10, 10, FmyHint);
end;

But this event is not called after DataPointHintToolPosition, but on 
other events, such as Form.onResize.


One question is, is this the correct way to display text over a 
TAChart?, I don't like to add a TLabel over the chart.


The second question, how can I force a call to TAChart.onAftertPaint?.

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

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


Re: [Lazarus] Hint as text over TAChart

2014-09-20 Thread Leonardo M. Ramé

On 20/09/14 17:08, Werner Pamler wrote:

Using the TDataPointHintTool is correct. It is just a little bit awkward
to use... In particular you are not picking the correct event.

Here's a step-by-step instruction. Code shown will be based on the
financial demo which I added to TAChart recently:

  * Add a TChartToolset to the form
  * Set the chart's Toolset property to the toolset added.
  * Add a TDatapointHintTool.
  * Set DistanceMode to cdmOnlyX - this means that only the x
coordinate of the mouse is evaluated to find the data point under
the mouse; otherwise you'd have to move the move correctly to x and
y. GrabRadius is the tolerance for point detection; you may want
to increase the value a bit.
  * Add code to the OnHint event of the DatapointHintTool, this is the
code which generates the hint text. Adapt your code to the following
which works with the financial demo (note that the hint string may
contain line breaks!):

procedure TMainForm.ChartToolset1DataPointHintTool1Hint(ATool:
TDataPointHintTool;
   const APoint: TPoint; var AHint: String);
var
   ser: TOpenHighLowCloseSeries;
begin
   ser := ATool.Series as TOpenHighLowCloseSeries;
   AHint := Format('Date: %s'#13'  Open: %.2f'#13'  High: %.2f'#13'
Low: %.2f'#13'  Close: %.2f', [
 ser.ListSource[Atool.PointIndex]^.Text,// In
this example the date is not stored in x, but in the Text of the
data point
 ser.ListSource[ATool.PointIndex]^.YList[0],
 ser.ListSource[ATool.PointIndex]^.YList[2],
 ser.ListSource[ATool.PointIndex]^.Y,
 ser.ListSource[ATool.PointIndex]^.YList[1]
   ]);
end;

  * When you compile the hints should work already. However, they are
not properly positioned. I'd prefer to move them above a data point
and center them horizontally to the data points. The OnHintPosition
event is responsible to determine the location of the upper/left
corner of the hint window.

procedure
TMainForm.ChartToolset1DataPointHintTool1HintPosition(ATool:
TDataPointHintTool;
   var APoint: TPoint);
var
   ser: TOpenHighLowCloseSeries;
   x, y: Integer;
   w, h: Integer;
   r: TRect;
   hintwnd : THintWindow;
   s: String;
begin
   { Calculate screen coordinates of the high point }

   ser := ATool.Series as TOpenHighLowCloseSeries;
   x :=
FinancialChart.XGraphToImage(ser.ListSource[ATool.PointIndex]^.X);
   y :=
FinancialChart.YGraphToImage(ser.ListSource[ATool.PointIndex]^.YList[2]);
 // High value, i.e. max of data point

   { Calculate size of hint window }

   // Get hint text - just call the event handler of OnHint
   ChartToolset1DataPointHintTool1Hint(ATool, APoint, s);

   // Calculation - borrowed from TATools
   hintwnd := THintWindow.Create(nil);
   try
 r := hintwnd.CalcHintRect(FinancialChart.Width, s, nil);
 w := r.Right - r.Left;  // Hint width
 h := r.Bottom - r.Top;  // Hint height
   finally
 hintwnd.Free;
   end;

   // Center hint horizontally relative to data point
   APoint.x := x - w div 2;

   // Move hint 10 pixels above the High data point
   APoint.y := y - h - 10;

   // Hint coordinates are relative to screen
   APoint := FinancialChart.ClientToScreen(APoint);
end;


Regarding your second question how to call OnAfterPaint: Just call it
like I call the OnHint event in above example.




Great, calling onAfterPaint did the trick. Btw, thanks for the example.


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

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


[Lazarus] TAchart frame left and top values

2014-09-20 Thread Leonardo M. Ramé
I need to draw text just at the top left corner of a chart, is there a 
property to allow me to know the top, left (and of course right and 
bottom) points of the frame containing the chart?.


I attached a screenshot showing what I'm looking for.

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TAChart CandleStick Chart

2014-09-17 Thread Leonardo M. Ramé

El 16/09/14 a las 16:09, Werner Pamler escibió:

In r46244 the TOpenHighLowCloseSeries has a new property Mode:
selection mOHLC does the standard painting as before while
mChandleStick paints the candlesticks that you requested. Since your
code was mostly a copy of existing code I decided to stick to the old
series type, but just add the painting modes. There are also properties
CandleStickUpBrush, CandleStickDownBrush and CandleStickLinePen to
control painting of the up and down bars and the border and shadow line.
I also added a little demo financial to the demo folder of the
TAChart installation which demonstrates both modes. It would be nice if
you could have a look if everything is fine - I'm not an expert in
financial charts.

I also fixed the bug which ignored the true minimum of the data -
therefore, it is no longer necessary to calculate the minimum by
yourself, just have a look at the code in the demo project. And,
finally, I modified the AddXOHLC method such that it automatically
initializes the size of the YCount of the chart source if the current
size would not be enough.




Great!, I'll take a look later today.

--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877


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


Re: [Lazarus] TAChart CandleStick Chart

2014-09-15 Thread Leonardo M. Ramé

El 14/09/14 a las 11:46, Werner Pamler escibió:

I'm not familiar with the multivalued series. But you chandlestick
series looks much like the Box/Whisker series which is included in
TAChart. Can you point out the difference?

--


Mm, they look similar, but Box/Whisker, has a top and bottom horizontal 
lines and an horizontal line in the middle of the candle, maybe adding a 
couple of boolean properties like TopMark, BottomMark and MiddleMark to 
the Box/Whisker chart will let use it as a CandleStick chart.


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

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


Re: [Lazarus] TAChart CandleStick Chart

2014-09-15 Thread Leonardo M. Ramé




El 15/09/14 a las 15:49, Werner Pamler escibió:

The TopMark and BottomMark, as you call it, can be removed by
setting WhiskerWidth to 0, and the MiddleMark disappears with
MedianPen.Style set to psClear. The Up and Down colors can be set by
some logics when adding data points (there's the color parameter in the
Add method...). The intrinsic problem that Box/Whisker expects
ordered y values, while the Candle obviously does not (open can be
greater or smaller then close), could be overcome by pre-sorting the
data which should also take account of the Up/Down colors. Well, in
total, these are a few lines of code, but relatively straightforward.
Nevertheless, maybe too much for less code-centered guys?

Anyway, I'll try to add your contribution to a new CandleStick series. A
few question before I begin: Your posting says that Candlestick plots do
not have top and bottom marks, but the wikipedia reference that you gave
does show them. What is true? What should be the default up and down
colors?


Thanks. I'm used to see CandleStick charts in many Stock Trading 
software, and I never saw thos top and bottom marks. Default UP can be 
clLime and Down clRed.


P.S.: the next chart type is Heikin Ashi, a variation of CandleStick.


--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877

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


Re: [Lazarus] TAChart Date Axis Remove Weekends

2014-09-14 Thread Leonardo M. Ramé

On 14/09/14 06:57, Werner Pamler wrote:

Don't use the real date as x value. Instead, use a counter value that is
incremented every time you add a value to the series. Don't add data if
the DayOfWeek of their date is 6 (Friday) or 7 (Saturday). In the data
you posted in your previous message the weekends are already messing,
therefore you can simply use the line index I for the x coordinate of
the data point.

The problem left is the display of the axis labels. Your code in the
other posting already adds a data label to each series point (last
parameter of AddXOHLC shown). To activate it set the Style of the
Chart.BottomAxis.Marks to smsLabel, and don't forget to link the
ListSource of the series (that's where your AddXOHLC data go to) to the
Source of the BottomAxis.Marks.

However, the x labels will be quite crowded and overlapping. There are
several ways to get rid of that: Use some logics in creating the data
labels - for example, if you want labels only for Monday set the
DateToStr(lDate) to the data label only if the DayOfWeek(lDate) is 2
(Monday), and use an empty string otherwise. Or you can play with the
Intervals property of the BottomAxis to increase the distance of the
labels, e.g. Intervals.MinLength=100, Intervals.MaxLength=200. Or you
can rotate the label by 90 degrees
(BottomAxis.Marks.LabelFont.Orientation = 900)




Thanks! Werner, the chart is starting to look very good.

Now, I need to define the range of left axis. By default it starts on 0 
(bottom left) and ends in the highest value of my data. How can I change 
the starting value, to the minimum value of the data source?.


Currently all the data poins are displayed at the top part of the chart, 
and from 0 to 70 is empty.



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

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


Re: [Lazarus] TAChart Date Axis Remove Weekends

2014-09-14 Thread Leonardo M. Ramé

On 14/09/14 08:35, Leonardo M. Ramé wrote:

On 14/09/14 06:57, Werner Pamler wrote:

Don't use the real date as x value. Instead, use a counter value that is
incremented every time you add a value to the series. Don't add data if
the DayOfWeek of their date is 6 (Friday) or 7 (Saturday). In the data
you posted in your previous message the weekends are already messing,
therefore you can simply use the line index I for the x coordinate of
the data point.

The problem left is the display of the axis labels. Your code in the
other posting already adds a data label to each series point (last
parameter of AddXOHLC shown). To activate it set the Style of the
Chart.BottomAxis.Marks to smsLabel, and don't forget to link the
ListSource of the series (that's where your AddXOHLC data go to) to the
Source of the BottomAxis.Marks.

However, the x labels will be quite crowded and overlapping. There are
several ways to get rid of that: Use some logics in creating the data
labels - for example, if you want labels only for Monday set the
DateToStr(lDate) to the data label only if the DayOfWeek(lDate) is 2
(Monday), and use an empty string otherwise. Or you can play with the
Intervals property of the BottomAxis to increase the distance of the
labels, e.g. Intervals.MinLength=100, Intervals.MaxLength=200. Or you
can rotate the label by 90 degrees
(BottomAxis.Marks.LabelFont.Orientation = 900)




Thanks! Werner, the chart is starting to look very good.

Now, I need to define the range of left axis. By default it starts on 0
(bottom left) and ends in the highest value of my data. How can I change
the starting value, to the minimum value of the data source?.

Currently all the data poins are displayed at the top part of the chart,
and from 0 to 70 is empty.




Please forget about this, solved by setting Chart1.Extent.UseYMax and 
UseYMin.


Regards,

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

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


[Lazarus] TAChart CandleStick Chart

2014-09-14 Thread Leonardo M. Ramé
Hi, I inherited TOpenHighLowCloseSeries to implement CandleStick Charts: 
http://en.wikipedia.org/wiki/Candlestick_chart


I only implemented the Draw method, but it would be nice to have this 
properties in the final version also:


CandleColor: fill color of default or UP candle.
DownCandleColor: fill color of down candle

By now I use LinePen.Color and DownLinePen.Color as color of brush (fill 
of candle color) and the border is allways clBlack.


Can someone include it in TAMultiseries?

// interface

{ TCandleStickChart }

TCandleStickChart = class(TOpenHighLowCloseSeries)
public
  procedure Draw(ADrawer: IChartDrawer); override;
end;

// implementation

procedure TCandleStickChart.Draw(ADrawer: IChartDrawer);

  function MaybeRotate(AX, AY: Double): TPoint;
  begin
if IsRotated then
  Exchange(AX, AY);
Result := ParentChart.GraphToImage(DoublePoint(AX, AY));
  end;

  procedure DoLine(AX1, AY1, AX2, AY2: Double);
  begin
ADrawer.Line(MaybeRotate(AX1, AY1), MaybeRotate(AX2, AY2));
  end;

  function GetGraphPointYIndex(AIndex, AYIndex: Integer): Double;
  begin
if AYIndex = 0 then
  Result := GetGraphPointY(AIndex)
else
  Result := AxisToGraphY(Source[AIndex]^.YList[AYIndex - 1]);
  end;

  procedure DoRect(AX1, AY1, AX2, AY2: Double);
  var
r: TRect;
  begin
with ParentChart do begin
  r.TopLeft := MaybeRotate(AX1, AY1);
  r.BottomRight := MaybeRotate(AX2, AY2);
end;
ADrawer.FillRect(r.Left, r.Top, r.Right, r.Bottom);
ADrawer.Rectangle(r);
  end;

var
  my: Cardinal;
  ext2: TDoubleRect;
  i: Integer;
  x, tw, yopen, yhigh, ylow, yclose: Double;
  p: TPen;
begin
  my := MaxIntValue([YIndexOpen, YIndexHigh, YIndexLow, YIndexClose]);
  if IsEmpty or (my = Source.YCount) then exit;

  ext2 := ParentChart.CurrentExtent;
  ExpandRange(ext2.a.X, ext2.b.X, 1.0);
  ExpandRange(ext2.a.Y, ext2.b.Y, 1.0);

  PrepareGraphPoints(ext2, true);

  for i := FLoBound to FUpBound do begin
x := GetGraphPointX(i);
yopen := GetGraphPointYIndex(i, YIndexOpen);
yhigh := GetGraphPointYIndex(i, YIndexHigh);
ylow := GetGraphPointYIndex(i, YIndexLow);
yclose := GetGraphPointYIndex(i, YIndexClose);
tw := GetXRange(x, i) * PERCENT * TickWidth;

if (DownLinePen.Color = clTAColor) or (yopen = yclose) then
  p := LinePen
else
  p := DownLinePen;
ADrawer.BrushColor:= P.Color;
// set border black
ADrawer.SetPenParams(p.Style, clBlack);
DoLine(x, yhigh, x, ylow);
DoRect(x - tw, yopen, x + tw, yclose);
  end;
end;

I attached a screenshot of the result.
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] TAChart OHLC

2014-09-13 Thread Leonardo M. Ramé
Hi, I'm trying to create a basic Open High Low Close chart using 
TAChart, but I'm getting a RunError(201) on tacustomsource.pas line 
433, aparently YList is not initialized.


Here's the lfm:

object Form1: TForm1
  Left = 364
  Height = 354
  Top = 255
  Width = 582
  Caption = 'Form1'
  ClientHeight = 354
  ClientWidth = 582
  OnShow = FormShow
  LCLVersion = '1.3'
  object Chart1: TChart
Left = 0
Height = 354
Top = 0
Width = 582
AxisList = 
  item
Minors = 
Title.LabelFont.Orientation = 900
  end
  item
Alignment = calBottom
Minors = 
  end
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Text.Strings = (
  'TAChart'
)
Align = alClient
ParentColor = False
object Chart1OpenHighLowCloseSeries1: TOpenHighLowCloseSeries
end
  end
end

And Here's the .pas

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, TAGraph, TASources, TAIntervalSources,
  TAMultiSeries, Forms, Controls, Graphics, Dialogs,
  StrUtils, DateUtils, TACustomSeries;

type

  { TForm1 }

  TForm1 = class(TForm)
Chart1: TChart;
Chart1OpenHighLowCloseSeries1: TOpenHighLowCloseSeries;
procedure FormShow(Sender: TObject);
  private
{ private declarations }
  public
{ public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }


procedure TForm1.FormShow(Sender: TObject);
var
  lCSV: TStringList;
  lLine: TStringList;
  I: Integer;
  lDate: TDate;
  lOpen: double;
  lHigh: double;
  lLow: double;
  lClose: double;
  lStr: string;
begin
  lCSV := TStringList.Create;
  lLine := TStringList.Create;
  DefaultFormatSettings.DateSeparator:='-';
  DefaultFormatSettings.ShortDateFormat:='D-MMM-Y';
  DefaultFormatSettings.ShortMonthNames[1] := 'Jan';
  DefaultFormatSettings.ShortMonthNames[2] := 'Feb';
  DefaultFormatSettings.ShortMonthNames[3] := 'Mar';
  DefaultFormatSettings.ShortMonthNames[4] := 'Apr';
  DefaultFormatSettings.ShortMonthNames[5] := 'May';
  DefaultFormatSettings.ShortMonthNames[6] := 'Jun';
  DefaultFormatSettings.ShortMonthNames[7] := 'Jul';
  DefaultFormatSettings.ShortMonthNames[8] := 'Aug';
  DefaultFormatSettings.ShortMonthNames[9] := 'Sep';
  DefaultFormatSettings.ShortMonthNames[10] := 'Oct';
  DefaultFormatSettings.ShortMonthNames[11] := 'Nov';
  DefaultFormatSettings.ShortMonthNames[12] := 'Dec';
  try
lCSV.LoadFromFile('aapl.csv');
for I := 0 to lCSV.Count - 1 do
begin
  if I = 0 then
continue;
  lLine.CommaText:= lCSV[I];
  lDate := ScanDateTime('d-mmm-y', lLine[0]);
  lOpen := StrToFloat(lLine[1]);
  lHigh := StrToFloat(lLine[2]);
  lLow := StrToFloat(lLine[3]);
  lClose := StrToFloat(lLine[4]);
  Chart1OpenHighLowCloseSeries1.AddXOHLC(I, lOpen, lHigh, lLow, 
lClose, DateToStr(lDate));

end;
  finally
lLine.Free;
lCSV.Free;
  end;
end;

end.

Also I attached the file aapl.csv I'm using to feed the data.

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
Date,Open,High,Low,Close,Volume
10-Sep-14,98.01,101.11,97.76,101.00,100869587
9-Sep-14,99.08,103.08,96.14,97.99,189846255
8-Sep-14,99.30,99.31,98.05,98.36,46356742
5-Sep-14,98.80,99.39,98.31,98.97,58457035
4-Sep-14,98.85,100.09,97.79,98.12,85718221
3-Sep-14,103.10,103.20,98.58,98.94,125420521
2-Sep-14,103.06,103.74,102.72,103.30,53564262
29-Aug-14,102.86,102.90,102.20,102.50,44595247
28-Aug-14,102.13,102.78,101.56,102.25,68459801
27-Aug-14,101.02,102.57,100.70,102.13,52369011
26-Aug-14,101.42,101.50,100.86,100.89,33151984
25-Aug-14,101.79,102.17,101.28,101.54,40270173
22-Aug-14,100.29,101.47,100.19,101.32,44183834
21-Aug-14,100.57,100.94,100.11,100.58,33478198
20-Aug-14,100.44,101.09,99.95,100.57,52699192
19-Aug-14,99.41,100.68,99.32,100.53,69399270
18-Aug-14,98.49,99.37,97.98,99.16,47572413
15-Aug-14,97.90,98.19,96.86,97.98,48951331
14-Aug-14,97.33,97.57,96.80,97.50,28115566
13-Aug-14,96.15,97.24,96.04,97.24,31916439
12-Aug-14,96.04,96.88,95.61,95.97,33795352
11-Aug-14,95.27,96.08,94.84,95.99,36584844
8-Aug-14,94.26,94.82,93.28,94.74,41865193
7-Aug-14,94.93,95.95,94.10,94.48,46711179
6-Aug-14,94.75,95.48,94.71,94.96,38558342
5-Aug-14,95.36,95.68,94.36,95.12,55932663
4-Aug-14,96.37,96.58,95.17,95.59,39958144
1-Aug-14,94.90,96.62,94.81,96.13,48511286
31-Jul-14,97.16,97.45,95.33,95.60,56842647
30-Jul-14,98.44,98.70,97.67,98.15,33010001
29-Jul-14,99.33,99.44,98.25,98.38,43143095
28-Jul-14,97.82,99.24,97.55,99.02,55317689
25-Jul-14,96.85,97.84,96.64,97.67,43469117
24-Jul-14,97.04,97.32,96.42,97.03,45728843
23-Jul-14,95.42,97.88,95.17,97.19,92917719
22-Jul-14,94.68,94.89,94.12,94.72,55196597
21-Jul-14,94.99,95.00,93.72,93.94,39079002
18-Jul-14,93.62,94.74,93.02,94.43,49987593
17-Jul-14,95.03,95.28,92.57,93.09,57298243
16-Jul-14,96.97,97.10,94.74,94.78,53502415
15-Jul-14,96.80,96.85,95.03,95.32,45696176
14-Jul-14,95.86,96.89,95.65,96.45,42810155
11-Jul

[Lazarus] TAChart Date Axis Remove Weekends

2014-09-13 Thread Leonardo M. Ramé
Hi, I'm using TAChart to plot OHLC Stock prices and would like to ignore 
weekends. Is it possible to do that?.


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

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


[Lazarus] StrToDate and DefaultFormatSettings

2014-09-12 Thread Leonardo M. Ramé

Hi, I need to convert strings with format d-mmm-y to TDateTime.

For example: '12-Sep-14'

Here's my code:

DefaultFormatSettings.DateSeparator:='-';
DefaultFormatSettings.ShortDateFormat:='D-MMM-Y';
DefaultFormatSettings.ShortMonthNames[1] := 'Jan';
DefaultFormatSettings.ShortMonthNames[2] := 'Feb';
DefaultFormatSettings.ShortMonthNames[3] := 'Mar';
DefaultFormatSettings.ShortMonthNames[4] := 'Apr';
DefaultFormatSettings.ShortMonthNames[5] := 'May';
DefaultFormatSettings.ShortMonthNames[6] := 'Jun';
DefaultFormatSettings.ShortMonthNames[7] := 'Jul';
DefaultFormatSettings.ShortMonthNames[8] := 'Aug';
DefaultFormatSettings.ShortMonthNames[9] := 'Sep';
DefaultFormatSettings.ShortMonthNames[10] := 'Oct';
DefaultFormatSettings.ShortMonthNames[11] := 'Nov';
DefaultFormatSettings.ShortMonthNames[12] := 'Dec';
lStr := DateToStr(now); // This works Ok.
lDate := StrToDate(lStr); // Here I get EConvert exception.

Am I missing something?.


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

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


Re: [Lazarus] Anchordocking on Lazarus 1.3

2014-08-29 Thread Leonardo M. Ramé

El 29/08/14 a las 06:36, Mattias Gaertner escibió:

On Thu, 28 Aug 2014 14:45:36 -0300
Leonardo M. Ramé l.r...@griensu.com wrote:


Hi, since a couple of months ago I noted Anchordocking is not working as
expected.

I can arrange a nice layout, and save it as my default layout, but when
I start Lazarus again, it was commpletely messed up.

Does anyone faced the same issue?.


Do you use page docking?

Mattias



Re sent with a smaller image file.

Sorry, what is page docking?.

I attached a screenshot of how my Lazarus looks after arranging my 
layout, also the file anchordocklayout.xml after going to Tools - Save 
design...


After closing Lazarus, the layout is completely messed up.


Regards,

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
?xml version=1.0 encoding=UTF-8?
CONFIG
  MainConfig
Nodes ChildCount=1
  Item1 Name=MainIDE Type=CustomSite Monitor=1 ChildCount=1
Bounds Left=1505 Top=48 Width=1044 Height=625
  WorkArea
Rect Left=1360 Top=25 Right=2726 Bottom=768/
  /WorkArea
/Bounds
Item1 Name=AnchorDockSite4 Type=Layout ChildCount=7
  Bounds Top=72 Width=1044 Height=532 SplitterPos=68/
  Anchors Align=Bottom/
  Item1 Name=SourceNotebook Type=Control
Bounds Left=234 Width=527 Height=446/
Anchors Left=AnchorDockSplitter4 Right=AnchorDockSplitter3 Bottom=AnchorDockSplitter2/
Header Position=left/
  /Item1
  Item2 Name=AnchorDockSplitter2 Type=SplitterHorizontal
Bounds Left=234 Top=446 Width=527 Height=4/
Anchors Left=AnchorDockSplitter4 Right=AnchorDockSplitter3/
  /Item2
  Item3 Name=MessagesView Type=Control
Bounds Left=234 Top=450 Width=527 Height=82/
Anchors Left=AnchorDockSplitter4 Top=AnchorDockSplitter2 Right=AnchorDockSplitter3/
  /Item3
  Item4 Name=AnchorDockSplitter3 Type=SplitterVertical
Bounds Left=761 Width=4 Height=532/
  /Item4
  Item5 Name=ProjectInspector Type=Control
Bounds Left=765 Width=279 Height=532/
Anchors Left=AnchorDockSplitter3/
  /Item5
  Item6 Name=AnchorDockSplitter4 Type=SplitterVertical
Bounds Left=230 Width=4 Height=532/
  /Item6
  Item7 Name=ObjectInspectorDlg Type=Control
Bounds Width=230 Height=532/
Anchors Right=AnchorDockSplitter4/
  /Item7
/Item1
  /Item1
/Nodes
  /MainConfig
  Restores Count=1
Item1 Names=CodeExplorerView
  Nodes Name=MainIDE Type=CustomSite Monitor=1 ChildCount=1
Bounds Left=1461 Top=52 Width=1044 Height=555
  WorkArea
Rect Left=1360 Top=25 Right=2726 Bottom=768/
  /WorkArea
/Bounds
Item1 Name=AnchorDockSite4 Type=Layout ChildCount=5
  Bounds Top=72 Width=1044 Height=462 SplitterPos=68/
  Anchors Align=Bottom/
  Item1 Name=SourceNotebook Type=Control
Bounds Width=795 Height=393/
Anchors Right=AnchorDockSplitter3 Bottom=AnchorDockSplitter2/
Header Position=left/
  /Item1
  Item2 Name=AnchorDockSplitter2 Type=SplitterHorizontal
Bounds Top=393 Width=795 Height=4/
Anchors Right=AnchorDockSplitter3/
  /Item2
  Item3 Name=MessagesView Type=Control
Bounds Top=397 Width=795 Height=65/
Anchors Top=AnchorDockSplitter2 Right=AnchorDockSplitter3/
  /Item3
  Item4 Name=AnchorDockSplitter3 Type=SplitterVertical
Bounds Left=795 Width=4 Height=462/
  /Item4
  Item5 Name=CodeExplorerView Type=Control
Bounds Left=799 Width=245 Height=462/
Anchors Left=AnchorDockSplitter3/
  /Item5
/Item1
  /Nodes
/Item1
  /Restores
/CONFIG

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


Re: [Lazarus] Anchordocking on Lazarus 1.3

2014-08-29 Thread Leonardo M. Ramé

El 29/08/14 a las 09:46, Mattias Gaertner escibió:

On Fri, 29 Aug 2014 09:11:07 -0300
Leonardo M. Ramé l.r...@griensu.com wrote:


El 29/08/14 a las 06:36, Mattias Gaertner escibió:

On Thu, 28 Aug 2014 14:45:36 -0300
Leonardo M. Ramé l.r...@griensu.com wrote:


Hi, since a couple of months ago I noted Anchordocking is not working as
expected.

I can arrange a nice layout, and save it as my default layout, but when
I start Lazarus again, it was commpletely messed up.

Does anyone faced the same issue?.


Do you use page docking?

Mattias



Re sent with a smaller image file.

Sorry, what is page docking?.

I attached a screenshot of how my Lazarus looks after arranging my
layout, also the file anchordocklayout.xml after going to Tools - Save
design...

After closing Lazarus, the layout is completely messed up.


Thanks. Please create a bug report.



Done: http://mantis.freepascal.org/view.php?id=26646

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

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


[Lazarus] Anchordocking on Lazarus 1.3

2014-08-28 Thread Leonardo M. Ramé
Hi, since a couple of months ago I noted Anchordocking is not working as 
expected.


I can arrange a nice layout, and save it as my default layout, but when 
I start Lazarus again, it was commpletely messed up.


Does anyone faced the same issue?.

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

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


Re: [Lazarus] Translating php://input into fcl-web

2014-08-24 Thread Leonardo M. Ramé

On 24/08/14 00:08, silvioprog wrote:

Oops,

On Sun, Aug 24, 2014 at 12:02 AM, silvioprog silviop...@gmail.com
mailto:silviop...@gmail.com wrote:

On Sat, Aug 23, 2014 at 9:07 PM, Leonardo M. Ramé
l.r...@griensu.com mailto:l.r...@griensu.com wrote:

[...]
Thank you very much Silvio for testing.

My setup is XUbuntu 14.04 64bits, and Apache/2.4.7 (Ubuntu).
Also I'm testing on Firefox 31 For Ubuntu with the latest
version of Flash Plugin.

What confuses me is the same setup, but instead of the CGI, if I
use PHP, the file is stored with the complete audio.


Worked on Ubuntu too, please try it online here:

_https://brookframework.org/leo/_

I used chmod 777 -R /var/www/html/leo/tmp/ to my CGI can write
waves into this directory.

The modified source code (i'm using jQuery in this demo to less
coding hehe):

http://tempsend.com/06FD41FF11


Please try online demo again. And in your code change this lines:

...
stopButton.on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).prop('disabled', true);
startButton.prop('disabled', false);
Wami.stopRecording();
setTimeout(function() {
downloadLink.removeClass('hidden');
}, 3000);
});
...
--
Silvio Clécio
My public projects - github.com/silvioprog http://github.com/silvioprog



Thanks, this works perfectly. I'm using the same browser, the same swf 
but your Ubuntu server and your CGI example. Can you send me your 
cgiproject1.bf (the compiled version) to check it in my PC?.


I deployed my example to an external Ubuntu 12.04 server, with the CGI 
compiled in my machine, and the result is a file of correct size, 
playable with mplayer but just about 1 second of audio then mute until 
the playing ends, the same result as my local config.


I'm starting to think there must be something wrong in my fpc version...


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

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


Re: [Lazarus] Translating php://input into fcl-web

2014-08-24 Thread Leonardo M. Ramé

On 24/08/14 07:31, Leonardo M. Ramé wrote:

On 24/08/14 00:08, silvioprog wrote:

Oops,

On Sun, Aug 24, 2014 at 12:02 AM, silvioprog silviop...@gmail.com
mailto:silviop...@gmail.com wrote:

On Sat, Aug 23, 2014 at 9:07 PM, Leonardo M. Ramé
l.r...@griensu.com mailto:l.r...@griensu.com wrote:

[...]
Thank you very much Silvio for testing.

My setup is XUbuntu 14.04 64bits, and Apache/2.4.7 (Ubuntu).
Also I'm testing on Firefox 31 For Ubuntu with the latest
version of Flash Plugin.

What confuses me is the same setup, but instead of the CGI, if I
use PHP, the file is stored with the complete audio.


Worked on Ubuntu too, please try it online here:

_https://brookframework.org/leo/_

I used chmod 777 -R /var/www/html/leo/tmp/ to my CGI can write
waves into this directory.

The modified source code (i'm using jQuery in this demo to less
coding hehe):

http://tempsend.com/06FD41FF11


Please try online demo again. And in your code change this lines:

...
stopButton.on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).prop('disabled', true);
startButton.prop('disabled', false);
Wami.stopRecording();
setTimeout(function() {
downloadLink.removeClass('hidden');
}, 3000);
});
...
--
Silvio Clécio
My public projects - github.com/silvioprog http://github.com/silvioprog



Thanks, this works perfectly. I'm using the same browser, the same swf
but your Ubuntu server and your CGI example. Can you send me your
cgiproject1.bf (the compiled version) to check it in my PC?.

I deployed my example to an external Ubuntu 12.04 server, with the CGI
compiled in my machine, and the result is a file of correct size,
playable with mplayer but just about 1 second of audio then mute until
the playing ends, the same result as my local config.

I'm starting to think there must be something wrong in my fpc version...




Confirmed!, I completely removed my fpc and Lazarus, then downloaded 
from svn and rebuilded everything and it works now.


Thanks you Silvio again for your help.


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

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


[Lazarus] Translating php://input into fcl-web

2014-08-23 Thread Leonardo M. Ramé
Hi, I'm trying to translate this PHP code to fcl-web (actually 
brookframework):


?php
$content = file_get_contents('php://input');
$fh = fopen('output.wav', 'w') or die(can't open file);
fwrite($fh, $content);
fclose($fh);
?

The difficult part is the line with file_get_contents('php://input'), 
it contains the whole POST content as binary.


What I already did was this:

procedure TActAudio.Post;
var
  lWav: TMemoryStream;
begin
  lWav := TMemoryStream.Create;
  try
lWav.Write(HttpRequest.Content[1], HttpRequest.ContentLength);
lWav.Position:= 0;
lWav.SaveToFile('/tmp/output.wav');
  finally
lWav.Free;
  end;
end;

But the output.wav result is corrupt, while the php one is correct.

Any hint?.

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

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


Re: [Lazarus] Translating php://input into fcl-web

2014-08-23 Thread Leonardo M. Ramé

On 23/08/14 17:18, silvioprog wrote:

On Sat, Aug 23, 2014 at 3:12 PM, Leonardo M. Ramé l.r...@griensu.com
mailto:l.r...@griensu.com wrote:

Hi, I'm trying to translate this PHP code to fcl-web (actually
brookframework):

?php
$content = file_get_contents('php://__input');
$fh = fopen('output.wav', 'w') or die(can't open file);
fwrite($fh, $content);
fclose($fh);
?

The difficult part is the line with
file_get_contents('php://__input'), it contains the whole POST
content as binary.

What I already did was this:

procedure TActAudio.Post;
var
   lWav: TMemoryStream;
begin
   lWav := TMemoryStream.Create;
   try
 lWav.Write(HttpRequest.__Content[1], HttpRequest.ContentLength);
 lWav.Position:= 0;
 lWav.SaveToFile('/tmp/output.__wav');
   finally
 lWav.Free;
   end;
end;

But the output.wav result is corrupt, while the php one is correct.

Any hint?.

Regards,


Worked fine here:

procedure TMyAction.Post;
begin
   with TFileStream.Create('out.txt', fmCreate) do
   try
 Write(TheRequest.Content[1], TheRequest.ContentLength);
   finally
 Free;
   end;
end;

POST /cgi1.br http://cgi1.br HTTP/1.1

{key1:value1,key2:value2}

out.txt:
{key1:value1,key2:value2}

Or:

procedure TMyAction.Post;
begin
   with TMemoryStream.Create do
   try
 Write(TheRequest.Content[1], TheRequest.ContentLength);
 SaveToFile('post.txt');
   finally
 Free;
   end;
end;

P.S.: php://input is not available with enctype=multipart/form-data.



Yes, with plain text everything works ok, the problem raises when I try 
to receive binary data, in this case a WAV file, enctype: audio/x-wav.


The client (a Flash app running on the browser) is sending a POST 
message without params, just the binary data.



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

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


Re: [Lazarus] Translating php://input into fcl-web

2014-08-23 Thread Leonardo M. Ramé

On 23/08/14 18:40, Leonardo M. Ramé wrote:

On 23/08/14 17:18, silvioprog wrote:

On Sat, Aug 23, 2014 at 3:12 PM, Leonardo M. Ramé l.r...@griensu.com
mailto:l.r...@griensu.com wrote:

Hi, I'm trying to translate this PHP code to fcl-web (actually
brookframework):

?php
$content = file_get_contents('php://__input');
$fh = fopen('output.wav', 'w') or die(can't open file);
fwrite($fh, $content);
fclose($fh);
?

The difficult part is the line with
file_get_contents('php://__input'), it contains the whole POST
content as binary.

What I already did was this:

procedure TActAudio.Post;
var
   lWav: TMemoryStream;
begin
   lWav := TMemoryStream.Create;
   try
 lWav.Write(HttpRequest.__Content[1], 
HttpRequest.ContentLength);

 lWav.Position:= 0;
 lWav.SaveToFile('/tmp/output.__wav');
   finally
 lWav.Free;
   end;
end;

But the output.wav result is corrupt, while the php one is correct.

Any hint?.

Regards,


Worked fine here:

procedure TMyAction.Post;
begin
   with TFileStream.Create('out.txt', fmCreate) do
   try
 Write(TheRequest.Content[1], TheRequest.ContentLength);
   finally
 Free;
   end;
end;

POST /cgi1.br http://cgi1.br HTTP/1.1

{key1:value1,key2:value2}

out.txt:
{key1:value1,key2:value2}

Or:

procedure TMyAction.Post;
begin
   with TMemoryStream.Create do
   try
 Write(TheRequest.Content[1], TheRequest.ContentLength);
 SaveToFile('post.txt');
   finally
 Free;
   end;
end;

P.S.: php://input is not available with enctype=multipart/form-data.



Yes, with plain text everything works ok, the problem raises when I 
try to receive binary data, in this case a WAV file, enctype: 
audio/x-wav.


The client (a Flash app running on the browser) is sending a POST 
message without params, just the binary data.




I made an example using fcl-web (without Brook) and the problem persists.

I attached an example for anyone to test, please, copy the following 
files to your apache documents folder (/var/www/html on Ubuntu):


testwami.html
swfobject.js
wamirecorder.js

Also please download the file Wami.sfw from here: 
https://wami-recorder.googlecode.com/hg/example/client/Wami.swf and copy 
to the same folder as the previous files. I cannot attach it here 
because of email size restrictions of the mailing list.


Also please compile the project cgiproject.lpi contained in wami.tar.gz, 
then copy the executable to your /cgi-bin/ directory.



Regards,

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



wami.tar.gz
Description: application/gzip
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Translating php://input into fcl-web

2014-08-23 Thread Leonardo M. Ramé

On 23/08/14 18:40, Leonardo M. Ramé wrote:

On 23/08/14 17:18, silvioprog wrote:

On Sat, Aug 23, 2014 at 3:12 PM, Leonardo M. Ramé l.r...@griensu.com
mailto:l.r...@griensu.com wrote:

Hi, I'm trying to translate this PHP code to fcl-web (actually
brookframework):

?php
$content = file_get_contents('php://__input');
$fh = fopen('output.wav', 'w') or die(can't open file);
fwrite($fh, $content);
fclose($fh);
?

The difficult part is the line with
file_get_contents('php://__input'), it contains the whole POST
content as binary.

What I already did was this:

procedure TActAudio.Post;
var
   lWav: TMemoryStream;
begin
   lWav := TMemoryStream.Create;
   try
 lWav.Write(HttpRequest.__Content[1],
HttpRequest.ContentLength);
 lWav.Position:= 0;
 lWav.SaveToFile('/tmp/output.__wav');
   finally
 lWav.Free;
   end;
end;

But the output.wav result is corrupt, while the php one is correct.

Any hint?.

Regards,


Worked fine here:

procedure TMyAction.Post;
begin
   with TFileStream.Create('out.txt', fmCreate) do
   try
 Write(TheRequest.Content[1], TheRequest.ContentLength);
   finally
 Free;
   end;
end;

POST /cgi1.br http://cgi1.br HTTP/1.1

{key1:value1,key2:value2}

out.txt:
{key1:value1,key2:value2}

Or:

procedure TMyAction.Post;
begin
   with TMemoryStream.Create do
   try
 Write(TheRequest.Content[1], TheRequest.ContentLength);
 SaveToFile('post.txt');
   finally
 Free;
   end;
end;

P.S.: php://input is not available with enctype=multipart/form-data.



Yes, with plain text everything works ok, the problem raises when I
try to receive binary data, in this case a WAV file, enctype:
audio/x-wav.

The client (a Flash app running on the browser) is sending a POST
message without params, just the binary data.



I made an example using fcl-web (without Brook) and the problem persists.

As I cannot attach files here, please download this:

http://tempsend.com/6088747E14/DBFE/wami.tar.gz

That's an example for anyone to test, please uncompress and copy the 
following files to your apache documents folder (/var/www/html on Ubuntu):


testwami.html
swfobject.js
wamirecorder.js

Also please download the file Wami.sfw from here: 
https://wami-recorder.googlecode.com/hg/example/client/Wami.swf and copy 
to the same folder as the previous files. I cannot attach it here 
because of email size restrictions of the mailing list.


Also please compile the project cgiproject.lpi contained in wami.tar.gz, 
then copy the executable to your /cgi-bin/ directory.



Regards,

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



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


Re: [Lazarus] Translating php://input into fcl-web

2014-08-23 Thread Leonardo M. Ramé

On 23/08/14 20:54, silvioprog wrote:
On Sat, Aug 23, 2014 at 8:09 PM, Leonardo M. Ramé 
l.r...@griensu.com mailto:l.r...@griensu.com wrote:
 I made an example using fcl-web (without Brook) and the problem 
persists.

[...]

Strange. I made some changes to work here in my PC and it worked fine:

http://tempsend.com/63FEC90D7A

Listen my ugly audio3.wav file. :-P

Lazarus 1.2.4 r45510 FPC 2.6.4 i386-win32-win32/win64

My Apache: 
https://archive.apache.org/dist/httpd/binaries/win32/httpd-2.2.22-win32-x86-openssl-0.9.8t.msi


Thank you very much Silvio for testing.

My setup is XUbuntu 14.04 64bits, and Apache/2.4.7 (Ubuntu). Also I'm 
testing on Firefox 31 For Ubuntu with the latest version of Flash Plugin.


What confuses me is the same setup, but instead of the CGI, if I use 
PHP, the file is stored with the complete audio.


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

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


[Lazarus] Cannot find -lpthread

2014-08-21 Thread Leonardo M. Ramé
Hi, I'm trying to build fpc and lazarus from sources in XUbuntu 14.04. 
While trying to link fpc I get this:


/usr/bin/ld: aviso: link.res contiene secciones de salida. ¿Olvidó -T?
/usr/bin/ld: no se puede encontrar -lpthread
/usr/bin/ld: no se puede encontrar -ldl
/usr/bin/ld: no se puede encontrar -lc
fpmake.pp(44,1) Error: Error while linking

Does anyone know which package I'm missing? I've installed 
build-essential and libpthread-stubs0, but it still cannot find pthread...


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

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


Re: [Lazarus] Cannot find -lpthread

2014-08-21 Thread Leonardo M. Ramé


El 21/08/14 a las 12:34, Henry Vermaak escibió:

On Thu, Aug 21, 2014 at 12:22:45PM -0300, Leonardo M. Ramé wrote:

Hi, I'm trying to build fpc and lazarus from sources in XUbuntu
14.04. While trying to link fpc I get this:

/usr/bin/ld: aviso: link.res contiene secciones de salida. ¿Olvidó -T?
/usr/bin/ld: no se puede encontrar -lpthread
/usr/bin/ld: no se puede encontrar -ldl
/usr/bin/ld: no se puede encontrar -lc
fpmake.pp(44,1) Error: Error while linking


These are generally in libc6-dev, but that should be pulled in by
build-essential.

Try installing apt-file and using:

apt-file search libpthread.so

Henry

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



Here's the result, apparently it is already installed:

libc6: /lib/x86_64-linux-gnu/libpthread.so.0
libc6-arm64-cross: /usr/aarch64-linux-gnu/lib/libpthread.so.0
libc6-armel-armhf-cross: /usr/arm-linux-gnueabihf/libsf/libpthread.so.0
libc6-armel-cross: /usr/arm-linux-gnueabi/lib/libpthread.so.0
libc6-armhf-armel-cross: /usr/arm-linux-gnueabi/libhf/libpthread.so.0
libc6-armhf-cross: /usr/arm-linux-gnueabihf/lib/libpthread.so.0
libc6-dev: /usr/lib/x86_64-linux-gnu/libpthread.so
libc6-dev-arm64-cross: /usr/aarch64-linux-gnu/lib/libpthread.so
libc6-dev-armel-armhf-cross: /usr/arm-linux-gnueabihf/libs/libpthread.so
libc6-dev-armel-cross: /usr/arm-linux-gnueabi/lib/libpthread.so
libc6-dev-armhf-armel-cross: /usr/arm-linux-gnueabi/libhf/libpthread.so
libc6-dev-armhf-cross: /usr/arm-linux-gnueabihf/lib/libpthread.so
libc6-dev-i386: /usr/lib32/libpthread.so
libc6-dev-powerpc-cross: /usr/powerpc-linux-gnu/lib/libpthread.so
libc6-dev-ppc64-powerpc-cross: /usr/powerpc-linux-gnu/lib6/libpthread.so
libc6-dev-ppc64el-cross: /usr/powerpc64le-linux-gnu/lib/libpthread.so
libc6-dev-x32: /usr/libx32/libpthread.so
libc6-i386: /lib32/libpthread.so.0
libc6-powerpc-cross: /usr/powerpc-linux-gnu/lib/libpthread.so.0
libc6-ppc64-powerpc-cross: /usr/powerpc-linux-gnu/lib64/libpthread.so.0
libc6-ppc64el-cross: /usr/powerpc64le-linux-gnu/lib/libpthread.so.0
libc6-x32: /libx32/libpthread.so.0

Any hint?

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

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


Re: [Lazarus] Cannot find -lpthread

2014-08-21 Thread Leonardo M. Ramé

El 21/08/14 a las 14:44, Péter Gábor escibió:

Hello!

If you try static linking with a library you need the development
package of it which contains the required binary
statements/codes/records for the static linking.
For example: libpthread-stubs0-dev or libpthread-dev or something similar...



Yes I have installed libpthread-stubs0-dev (libpthread-dev does not 
exists here), but the error persists. I need to know what is that 
something similar package needed by fpc...


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

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


Re: [Lazarus] CGI Response.ContentStream client break

2014-07-04 Thread Leonardo M . Ramé
On 2014-07-04 08:22:30 +0200, Michael Van Canneyt wrote:
 
 
 On Thu, 3 Jul 2014, silvioprog wrote:
 
 2014-07-03 17:33 GMT-03:00 Leonardo M. Ramé l.r...@griensu.com:
 [...]
   Mmm, no, too fast.
 
   Maybe the problem is on the client side. I'm using Synapse library as
   client, and I'm issuing THttpSend's Abort method to stop downloading.
 
 
 You can change your 'broker' to a embedded HTTP server, and put a break 
 point and debug both (client/server).
  
   Is the cgi notified when the client does an Abort call?.
 
 
 Hm... AFAIK, no.
 
 Indeed. The CGI program is just terminated.
 
 Normally the file stream is then closed by the OS, so this should not have 
 any side effects.
 (unless the OS is buggy).
 
 If you do observe side effects, try opening the file without share locks.
 using flags (fmOpenRead or fmShareDenyNone), I think.
 
 Michael.

Thanks Michael, using (fmOpenRead or fmShareDenyNone) params did the
trick!.

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

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


[Lazarus] CGI Response.ContentStream client break

2014-07-03 Thread Leonardo M . Ramé
Hi, I have a CGI program that serves some files using this code in an
action:

AResponse.ContentStream := TFileStream.Create(lImagePath, fmOpenRead);

The problem I'm facing is that some times the client breaks the
connection to the server, aparently leaving the file open. If the client
tries to download the file again, a code 500 is returned.

Is there a way to detect the connection break and destroy the stream
gracefully?.

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

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


Re: [Lazarus] CGI Response.ContentStream client break

2014-07-03 Thread Leonardo M . Ramé
On 2014-07-03 17:20:53 -0300, silvioprog wrote:
 2014-07-03 16:51 GMT-03:00 Leonardo M. Ramé l.r...@griensu.com:
 
  Hi, I have a CGI program that serves some files using this code in an
  action:
 
  AResponse.ContentStream := TFileStream.Create(lImagePath, fmOpenRead);
 
  The problem I'm facing is that some times the client breaks the
  connection to the server, aparently leaving the file open. If the client
  tries to download the file again, a code 500 is returned.
 
  Is there a way to detect the connection break and destroy the stream
  gracefully?.
 
 
 You can use the FreeContentStream property and free your stream manually,
 e.g.:
 
 var
   f: TFileStream;
 begin
   f := TFileStream.Create(...);
   try
 HttpResponse.FreeContentStream := False;
 HttpResponse.ContentType := 'application/octet-stream';
 HttpResponse.ContentStream := f;
 HttpResponse.SendContent;
   finally
 f.Free;
   end;
 end;
 

Thanks Silvio, it seems to work.

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

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


Re: [Lazarus] CGI Response.ContentStream client break

2014-07-03 Thread Leonardo M . Ramé
On 2014-07-03 17:28:41 -0300, Leonardo M. Ramé wrote:
 On 2014-07-03 17:20:53 -0300, silvioprog wrote:
  2014-07-03 16:51 GMT-03:00 Leonardo M. Ramé l.r...@griensu.com:
  
   Hi, I have a CGI program that serves some files using this code in an
   action:
  
   AResponse.ContentStream := TFileStream.Create(lImagePath, fmOpenRead);
  
   The problem I'm facing is that some times the client breaks the
   connection to the server, aparently leaving the file open. If the client
   tries to download the file again, a code 500 is returned.
  
   Is there a way to detect the connection break and destroy the stream
   gracefully?.
  
  
  You can use the FreeContentStream property and free your stream manually,
  e.g.:
  
  var
f: TFileStream;
  begin
f := TFileStream.Create(...);
try
  HttpResponse.FreeContentStream := False;
  HttpResponse.ContentType := 'application/octet-stream';
  HttpResponse.ContentStream := f;
  HttpResponse.SendContent;
finally
  f.Free;
end;
  end;
  
 
 Thanks Silvio, it seems to work.
 

Mmm, no, too fast.

Maybe the problem is on the client side. I'm using Synapse library as
client, and I'm issuing THttpSend's Abort method to stop downloading. Is
the cgi notified when the client does an Abort call?.

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

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


[Lazarus] Errors while linking

2014-06-19 Thread Leonardo M . Ramé
':
drawer.pas:(.debug_info+0x2b8): undefined reference to 
`DBG_$CONTROLS_$$_TMouseWheelEvent'
drawer.pas:(.debug_info+0x3d0): undefined reference to 
`DBG_$FORMS_$$_THintWindow'
drawer.pas:(.debug_info+0x4b4): undefined reference to 
`DBG_$CONTROLS_$$_TMouseWheelEvent'
drawer.pas:(.debug_info+0x6b3): undefined reference to 
`DBG_$CONTROLS_$$_TMouseButton'
drawer.pas:(.debug_info+0x829): undefined reference to 
`DBG_$CONTROLS_$$_TMouseButton'
drawer.pas:(.debug_info+0xd66): undefined reference to `DBG_$CONTROLS_$$_TAlign'
drawer.pas:(.debug_info+0xefa): undefined reference to 
`DBG_$CONTROLS_$$_TDragState'
/home/leonardo/Desarrollo/griensu/GViewerIII/lib/x86_64-linux/series.o: In 
function `.La67':
series.pas:(.debug_info+0x80ec): undefined reference to 
`DBG2_$EXTCTRLS_$$_TPaintBox'
series.pas:(.debug_info+0x81e6): undefined reference to 
`DBG_$CONTROLS_$$_TMouseButton'
series.pas:(.debug_info+0x8230): undefined reference to 
`DBG_$CONTROLS_$$_TMouseButton'
/home/leonardo/Desarrollo/griensu/GViewerIII/lib/x86_64-linux/layout.o: In 
function `.La2':
layout.pas:(.debug_info+0x264): undefined reference to 
`DBG_$EXTCTRLS_$$_TPaintBox'
/home/leonardo/Desarrollo/griensu/GViewerIII/lib/x86_64-linux/layout.o: In 
function `.La6':
layout.pas:(.debug_info+0x818): undefined reference to 
`DBG_$CONTROLS_$$_TMouseWheelEvent'
layout.pas:(.debug_info+0x876): undefined reference to `DBG_$EXTCTRLS_$$_TPanel'
layout.pas:(.debug_info+0x887): undefined reference to 
`DBG_$CONTROLS_$$_TControl'
layout.pas:(.debug_info+0xa66): undefined reference to 
`DBG_$CONTROLS_$$_TControl'
layout.pas:(.debug_info+0xacd): undefined reference to `DBG_$EXTCTRLS_$$_TPanel'
layout.pas:(.debug_info+0xafe): undefined reference to 
`DBG_$CONTROLS_$$_TMouseWheelEvent'
layout.pas:(.debug_info+0x120b): undefined reference to 
`DBG_$CONTROLS_$$_TWinControl'
layout.pas:(.debug_info+0x134f): undefined reference to 
`DBG_$EXTCTRLS_$$_TPaintBox'
layout.pas:(.debug_info+0x15a9): undefined reference to 
`DBG_$CONTROLS_$$_TCursor'
/home/leonardo/Desarrollo/griensu/GViewerIII/lib/x86_64-linux/dlglayout.o: In 
function `.La1':
dlglayout.pas:(.debug_info+0xa3): undefined reference to `DBG2_$FORMS_$$_TForm'
dlglayout.pas:(.debug_info+0xb9): undefined reference to 
`DBG_$BUTTONPANEL_$$_TButtonPanel'
dlglayout.pas:(.debug_info+0xcb): undefined reference to 
`DBG_$STDCTRLS_$$_TGroupBox'
dlglayout.pas:(.debug_info+0xdd): undefined reference to 
`DBG_$STDCTRLS_$$_TGroupBox'
dlglayout.pas:(.debug_info+0xf3): undefined reference to 
`DBG_$BUTTONS_$$_TSpeedButton'
dlglayout.pas:(.debug_info+0x10a): undefined reference to 
`DBG_$BUTTONS_$$_TSpeedButton'

more similar errors


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

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


Re: [Lazarus] Errors while linking

2014-06-19 Thread Leonardo M . Ramé
On 2014-06-19 17:26:40 +0200, Mattias Gaertner wrote:
 On Thu, 19 Jun 2014 11:49:46 -0300
 Leonardo M. Ramé l.r...@griensu.com wrote:
 
  Hi People, while trying to compile an app that uses BGRabitmap I've got
  many linking errors when compiling with debugging information enabled.
  
  I'm using Lazarus and FPC from trunk (updated today) on a Ubuntu 12.04
  64bit machine.
  
  Here's the output with errors:
  
  /home/leonardo/Desarrollo/griensu/GViewerIII/lib/x86_64-linux/main.o: In 
  function `.La4':
  main.pas:(.debug_info+0x16e): undefined reference to 
  `DBG2_$ACTNLIST_$$_TAction'
  /home/leonardo/Desarrollo/griensu/GViewerIII/lib/x86_64-linux/main.o: In 
  function `.La5':
 
 Have you tried a clean rebuild?
 Run / Clean up build files?
 

Yes, and the problem persists. Also deleted the debugger directory of my
svn lazarus directory and updated again, but I've got the same.


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

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


Re: [Lazarus] Errors while linking

2014-06-19 Thread Leonardo M . Ramé
On 2014-06-19 17:32:00 +0200, Reinier Olislagers wrote:
 On 19/06/2014 16:49, Leonardo M. Ramé wrote:
  I'm using Lazarus and FPC from trunk (updated today) on a Ubuntu 12.04
  64bit machine.
  
  Here's the output with errors:
  
  /home/leonardo/Desarrollo/griensu/GViewerIII/lib/x86_64-linux/main.o: In 
  function `.La4':
  main.pas:(.debug_info+0x16e): undefined reference to 
  `DBG2_$ACTNLIST_$$_TAction'
 
 What options did you use when compiling - e.g. one or more of the -g...
 options?
 
 

Hmm, it was DWARF3 (beta), I changed to -g and it worked.

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

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


[Lazarus] Run command disabled

2014-06-11 Thread Leonardo M . Ramé
Hi people, I don't know what I did but the Run command (F9) is disabled
in my program. Do you know how can I enable it again?.

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

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


Re: [Lazarus] Run command disabled

2014-06-11 Thread Leonardo M . Ramé
On 2014-06-11 09:27:14 -0300, silvioprog wrote:
 2014-06-11 9:06 GMT-03:00 Leonardo M. Ramé l.r...@griensu.com:
 
  Hi people, I don't know what I did but the Run command (F9) is disabled
  in my program. Do you know how can I enable it again?.
 
 
 Shift+Ctrl+F11; Project Options  Miscellaneous; and check Project is
 runnable.
 

Thanks Silvio, it worked.



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

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


Re: [Lazarus] [ANN] Brook 3.0.0 release!

2014-05-22 Thread Leonardo M . Ramé
On 2014-05-18 23:45:23 -0300, silvioprog wrote:
 2014-05-15 8:45 GMT-03:00 Leonardo M. Ramé l.r...@griensu.com:
 
  On 2014-05-13 20:10:20 -0300, silvioprog wrote:
   The Brook team is glad to announce the release 3.0.0.
  
   This version was compiled and tested successfully with Free Pascal 2.6.4.
   Here is the list of changes between version 2.6.4 and 3.0.0 of the Brook:
  
  
  https://github.com/silvioprog/brookframework/compare/57f8e01868dbec9708129bc789940df2a93c1637...v3.0.0(or
   short URL here:
   http://goo.gl/kr9oX0)
  
   The release is available for download on Github:
  
   https://github.com/silvioprog/brookframework/releases/tag/v3.0.0
  
   Or through the Latest Release button on the project home page:
  
   http://silvioprog.github.io/brookframework/
  
   Minimum requirements:
  
   Free Pascal 2.6.4. If you prefer the Lazarus interface, choose the 1.2.2
   version.
  
   Enjoy!
  
 
  Hi Silvio, congratulations for the new release. I'm using it on one of
  my apps, and it's fantastic!.
 
  Can you add a What's new item in the home page or in the Wiki?. I
  know we are programmers and shouldn't have problems reading the git
  diff, but I'll be easy for us to know what additions and improvements
  you made.
 
  Regards,
  --
  Leonardo M. Ramé
  http://leonardorame.blogspot.com
 
 
 Hello Leonardo,
 
 I'm flattered with your comment.
 
 We can add a new file, called WHATS_NEW.txt, and it can be rewritten in
 all new versions, showing what's new in this released version.
 
 What do you think of this idea?
 

Great!, that's what I was thinking of.

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

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


Re: [Lazarus] [ANN] Brook 3.0.0 release!

2014-05-15 Thread Leonardo M . Ramé
On 2014-05-13 20:10:20 -0300, silvioprog wrote:
 The Brook team is glad to announce the release 3.0.0.
 
 This version was compiled and tested successfully with Free Pascal 2.6.4.
 Here is the list of changes between version 2.6.4 and 3.0.0 of the Brook:
 
 https://github.com/silvioprog/brookframework/compare/57f8e01868dbec9708129bc789940df2a93c1637...v3.0.0(or
 short URL here:
 http://goo.gl/kr9oX0)
 
 The release is available for download on Github:
 
 https://github.com/silvioprog/brookframework/releases/tag/v3.0.0
 
 Or through the Latest Release button on the project home page:
 
 http://silvioprog.github.io/brookframework/
 
 Minimum requirements:
 
 Free Pascal 2.6.4. If you prefer the Lazarus interface, choose the 1.2.2
 version.
 
 Enjoy!
 

Hi Silvio, congratulations for the new release. I'm using it on one of
my apps, and it's fantastic!.

Can you add a What's new item in the home page or in the Wiki?. I
know we are programmers and shouldn't have problems reading the git
diff, but I'll be easy for us to know what additions and improvements
you made.

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

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


[Lazarus] BSD Magazine featuring Free Pascal!

2014-04-27 Thread Leonardo M. Ramé
Congrats /Michael Van Canneyt/ for your article in the BSD Magazine 
april issue!.


Please download the latest edition from: http://bsdmag.org/

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

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


Re: [Lazarus] Prevent visual updates

2014-03-30 Thread Leonardo M. Ramé

On 30/03/14 08:40, Jürgen Hestermann wrote:


Am 2014-03-30 12:45, schrieb Chris Crori:

Hi gyus,
   is there a way to prevent LCL (visual) updates for a short period?
i am thinking of something like  BeginUpdate/EndUpade in Grids, so i
can make some changes drasticaly and avoid the flickering effect


Functions BeginUpdate/EndUpdate exist.
Just use them.



Did you try setting DoubleBuffererd := True; in the Form OnCreate event?.


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

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


  1   2   3   4   5   >