[Lazarus] Iterate TStringToStringTree

2010-06-15 Thread Juha Manninen
Hi

Is there a cleaner way to iterate TStringToStringTree? This is the 
codetoolsstructs version but the LCL version is almost the same.


var
  MapToEdit: TStringToStringTree;
  Node: TAVLTreeNode;
  Item: PStringToStringTreeItem;
begin
  ...
Node:=MapToEdit.Tree.FindLowest;
while Nodenil do begin
  Item:=PStringToStringTreeItem(Node.Data);

  // *** use Item^.Name and Item^.Value ***

  Node:=MapToEdit.Tree.FindSuccessor(Node);
end;



Regards,
Juha

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


[Lazarus] Regexp syntax

2010-06-15 Thread Juha Manninen
Hi

any regexp gurus out there?
For converter I need a regexp that matches a string starting with Tnt, not 
followed by LX and captures everything after Tnt. This actually works:

  ^Tnt([^L][^X].+)

but I am sure it could be written in a cleaner way.


Then there is another regexp that captures string after TntLX:

  ^TntLX(.+)

and that is no problem.

Juha

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


Re: [Lazarus] Iterate TStringToStringTree

2010-06-15 Thread Mattias Gaertner
On Tue, 15 Jun 2010 11:05:34 +0300
Juha Manninen juha.manni...@phnet.fi wrote:

 Hi
 
 Is there a cleaner way to iterate TStringToStringTree? This is the 
 codetoolsstructs version but the LCL version is almost the same.

With fpc 2.5.1 you could write an enumerator:
http://wiki.lazarus.freepascal.org/for-in_loop

 
 var
   MapToEdit: TStringToStringTree;
   Node: TAVLTreeNode;
   Item: PStringToStringTreeItem;
 begin
   ...
 Node:=MapToEdit.Tree.FindLowest;
 while Nodenil do begin
   Item:=PStringToStringTreeItem(Node.Data);
 
   // *** use Item^.Name and Item^.Value ***
 
   Node:=MapToEdit.Tree.FindSuccessor(Node);
 end;


Mattias

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


Re: [Lazarus] Regexp syntax

2010-06-15 Thread Mattias Gaertner
On Tue, 15 Jun 2010 11:12:52 +0300
Juha Manninen juha.manni...@phnet.fi wrote:

 Hi
 
 any regexp gurus out there?
 For converter I need a regexp that matches a string starting with Tnt, not 
 followed by LX and captures everything after Tnt. This actually works:
 
   ^Tnt([^L][^X].+)

This would miss TIntLa and TIntaX

 
 but I am sure it could be written in a cleaner way.

^Tnt(([^L]|.[^X]).+)

 
 Then there is another regexp that captures string after TntLX:
 
   ^TntLX(.+)
 
 and that is no problem.


Mattias

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


[Lazarus] Multiple editor windows bug

2010-06-15 Thread Torsten Bonde Christiansen

Hi List.

I believe i have found a bug when using multiple editor windows in the 
most recent svn version. I can confirm this exists in both Win32 and 
Linux (GTk2), but I would like someone else to confirm this too:


1) Start a new project
2) Open a new/existing source file (could be any, eg. FileUtils) in the 
same editor window.

3) Right click on current editor windows, select Move to new Window
4) Select first editor windows again and open another source file (eg. 
Forms).
5) Now try to close this file again (using Ctrl+F4, right clicking, 
using the X... )


Now the tab page with the closed file should still be present, and 
opening any further file, closing then again leaves a long list of 
dangling pages.


It is only possible to close these dangling pages again when editor 
window #2 is closed again.


Kind regards,
Torsten Bonde Christiansen.

ps. if someone can confirm this I will create a bug report in mantis 
about this.


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


Re: [Lazarus] Functions, procedures etc for using Dbase3/4 files ... what are they in Lazarus? (I used XBase1 in Delphi 5)

2010-06-15 Thread Joost van der Sluis
On Tue, 2010-06-15 at 14:54 +1000, Peter E Williams wrote:
 Hi All,
 
 On Mon, 2010-06-14 at 17:37 +0200, Michael Van Canneyt wrote:
  You may want to look at the TDBF component. I think the package is
  called
  lazdbf or dbflaz.
  
  Michael.
 
 On Mon Jun 14 18:00:51 CEST 2010, Howard Page-Clark wrote:
  For a general introduction have a look at
  http://wiki.lazarus.freepascal.org/Lazarus_Database_Tutorial
 
 I have looked at this document
 
  For using Tdbf have a look at
  http://wiki.lazarus.freepascal.org/Lazarus_Tdbf_Tutorial
 
 and printed out and read this one.
 
 and I have studied the Address Example and the other database example.
 
 // need changing 0.50.alpha
 //(Sender as Taction).Enabled:=Active;
 if (GetFieldByName('x1_pos') = str_x[1]) and
 
 I cannot find what to change XBase1's GetFieldByName(string) function
 to. It accepts a field name as a parameter and returns a string.

Dataset.FieldByName('fieldname').AsString;

 //  how do I do this
 HexxData_DBF.UpdFieldStr('x' + inttostr(x) + '_left',
 option_2_str(pattern1.option[x, 1]));
 
 I cannot find what to change XBase1's UpdFieldStr(string, string)
 function. The first parameter is the field name e.g. 'x1_left' and the
 second parameter is a string value to assign to the first parameter.

Dataset.FieldByName('FieldName').AsString := NewValue;

 HexxData_DBF.AppendBlank;
 Is this how I append a blank record? The documents quoted above don't
 mention appending a blank record.

Dataset.Append; nothing in between, so it's blank Dataset.Post;

 HexxData_DBF_rec_no := HexxData_DBF.RecNo;
 I need to get the record number and assign it to a longint

Using records numbers is evil! But it'll work in the tDbf (Dbase) case:
Rec_No := dataset.RecNo;

 HexxData_DBF.GotoRecord(HexxData_DBF_rec_no); // ### needs changing
 Then I need a Function to Goto the Record saved in the above assignment

Dataset.RecNo := Rec_No;

But you shouldn't use that. Use bookmarks instead.

Joost.


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


[Lazarus] Updating an app on the fly

2010-06-15 Thread Mark Morgan Lloyd
To what extent could a Lazarus app replace itself with a new version 
without interruption?


For example, if the main form had a menu at the top, synedit with popups 
and a status bar at the bottom, presumably much of the intelligence 
could be moved into dll/so libraries which could be closed and reopened.


Would the dynamic libraries be able to get at properties (e.g. main 
menu) of the visible components? Would they be able to display forms and 
dialogs on their own account?


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

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


Re: [Lazarus] Regexp syntax

2010-06-15 Thread Juha Manninen
  but I am sure it could be written in a cleaner way.
 
 ^Tnt(([^L]|.[^X]).+)

Hmmm... It doesn't look very clean. It may be more correct but I am not sure 
of that.

Does  [^L]|.[^X]  mean:
anything but 'L' or anything, followed by anything but 'X' ?

Juha

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


Re: [Lazarus] Regexp syntax

2010-06-15 Thread Mattias Gaertner
On Tue, 15 Jun 2010 15:21:52 +0300
Juha Manninen juha.manni...@phnet.fi wrote:

   but I am sure it could be written in a cleaner way.
  
  ^Tnt(([^L]|.[^X]).+)
 
 Hmmm... It doesn't look very clean. It may be more correct but I am not sure 
 of that.

It is not very clean. It does not match TntL and TntL1.

 
 Does  [^L]|.[^X]  mean:
 anything but 'L' or anything, followed by anything but 'X' ?

The pipe is like an 'or' operator. [^L]|.[^X] means:
Any character but L OR any character followed by any character but X.
It matches a, b, La, Lb, but not LX and not L.

Even better regexp is:

^Tnt(([^L]|L[^X]).*|L$)


Mattias

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


Re: [Lazarus] Regexp syntax

2010-06-15 Thread Graeme Geldenhuys

 ^Tnt(([^L]|.[^X]).+)

 Hmmm... It doesn't look very clean.


I don't think *any* regex looks clean.  ;-)


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

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


Re: [Lazarus] Iterate TStringToStringTree

2010-06-15 Thread Graeme Geldenhuys
On 15/06/2010, Juha Manninen wrote:

 Is there a cleaner way to iterate TStringToStringTree? This is the
 codetoolsstructs version but the LCL version is almost the same.


With any FPC version your can simply create a new Iterator descendant.
See the link below for a description. The code is included in the
article mentioned.

http://www.mail-archive.com/fpc-de...@lists.freepascal.org/msg15082.html


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

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


Re: [Lazarus] Regexp syntax

2010-06-15 Thread Alexander Klenin
On Tue, Jun 15, 2010 at 23:55, Mattias Gaertner
nc-gaert...@netcologne.de wrote:
 On Tue, 15 Jun 2010 15:21:52 +0300
 Juha Manninen juha.manni...@phnet.fi wrote:

   but I am sure it could be written in a cleaner way.
 
  ^Tnt(([^L]|.[^X]).+)

 Hmmm... It doesn't look very clean. It may be more correct but I am not sure
 of that.

 It is not very clean. It does not match TntL and TntL1.


 Does  [^L]|.[^X]  mean:
 anything but 'L' or anything, followed by anything but 'X' ?

 The pipe is like an 'or' operator. [^L]|.[^X] means:
 Any character but L OR any character followed by any character but X.
 It matches a, b, La, Lb, but not LX and not L.

 Even better regexp is:

 ^Tnt(([^L]|L[^X]).*|L$)

The correct (and clean) answer is actually:
^Tnt(?!LX)(.+)$

Sadly, assertions are poorly supported by many languages/libraries.
Use Perl if you want the full power of regexps ;-)

-- 
Alexander S. Klenin

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


Re: [Lazarus] Regexp syntax

2010-06-15 Thread Hans-Peter Diettrich

Mattias Gaertner schrieb:


Even better regexp is:

^Tnt(([^L]|L[^X]).*|L$)


I wonder who will be able to understand and update such expressions, at 
any later time. To me it looks like typical write-only code :-(


DoDi


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


[Lazarus] Rotated Text for Label or Panel

2010-06-15 Thread Andrew Brunner
Is there a component that offers rotated text drawn on component like
TLabel or TPanel?

Rotation via the orientation property on the font object does not seem
to work (at least on the Windows 7 box I'm presently on).

Anyone have something that works within LCL?

Thanks.

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


Re: [Lazarus] Rotated Text for Label or Panel

2010-06-15 Thread Mattias Gaertner
On Tue, 15 Jun 2010 14:20:59 -0500
Andrew Brunner andrew.t.brun...@gmail.com wrote:

 Is there a component that offers rotated text drawn on component like
 TLabel or TPanel?

Feel free to improve TLabel and TPanel to support that.

 
 Rotation via the orientation property on the font object does not seem
 to work (at least on the Windows 7 box I'm presently on).

Rotating text works. Just TLabel and TPanel don't support it.
 

 Anyone have something that works within LCL?

Mattias


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


[Lazarus] Accessing WinControls from DLL

2010-06-15 Thread SteveG
I believe that 'writing' (without syncronization) to a TWinControl from 
a thread or dll function is BAD(tm), but just wondering if the same 
applies to 'reading' (properties / etc) ?


another way - can 'non-mainthread' access to WinControls be considered 
'ReadOnly'


Thanks - SteveG

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


Re: [Lazarus] Functions, procedures etc for using Dbase3/4 files ... what are they in Lazarus? (I used XBase1 in Delphi 5)

2010-06-15 Thread Peter E Williams
Hi Joost  All,

On Tue, 2010-06-15 at 11:40 +0200, Joost van der Sluis wrote:
 On Tue, 2010-06-15 at 14:54 +1000, Peter E Williams wrote:
  
  On Mon Jun 14 18:00:51 CEST 2010, Howard Page-Clark wrote:
   For a general introduction have a look at
   http://wiki.lazarus.freepascal.org/Lazarus_Database_Tutorial
  
  I have looked at this document
  
   For using Tdbf have a look at
   http://wiki.lazarus.freepascal.org/Lazarus_Tdbf_Tutorial
  
 Dataset.FieldByName('fieldname').AsString;
 Dataset.FieldByName('FieldName').AsString := NewValue;
 Dataset.Append; nothing in between, so it's blank Dataset.Post;
 Dataset.RecNo := Rec_No;

I have spent all morning making those changes. Thank you,
Joost !!! :-)))

 
 
 But you shouldn't use that. Use bookmarks instead.

Do you have a url for a tutorial about bookmarks or some sample code? I
would really appreciate it.

 Joost.
 

Peter 

-- 
Proudly developing Quality Cross Platform Open Source Games
Since 1970 with a Commodore PET 4016 with 16 KRAM
http://pews-freeware-games.org (--- brand new)


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


Re: [Lazarus] Regexp syntax

2010-06-15 Thread Jürgen Hestermann




Hans-Peter Diettrich schrieb:

^Tnt(([^L]|L[^X]).*|L$)
I wonder who will be able to understand and update such expressions, at 
any later time. To me it looks like typical write-only code :-(


Yes, I also never got accustomed to regex syntax. 
But I know that some are using it frequently. 
And only then you will be able to manage such 
special character monsters I think. 



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