Re: [Lazarus] global items in TApplication
On 2013-09-15 15:57, Martin wrote: global war, but in implementation Correct, or just use a lazyman's singleton function. 8-8-8-8-8 interface function GlobalFoo: TFoo; implementation var uFoo: TFoo; function GlobalFoo: TFoo; begin if uFoo = nil then uFoo := TFoo.Create; Result := uFoo; end; initialization uFoo := nil; finalization uFroo.Free; 8-8-8-8-8 Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Project additions and overrides
On Sun, 15 Sep 2013 23:54:48 +0300 patspiper patspi...@gmail.com wrote: Hi, I am trying to add a new target (eg: abc) for the project options/additions and overrides. Once OK is pressed, re-entering the additions and overrides shows * instead of the specified target! Lazarus 1.3 r42824 FPC 2.6.3 i386-linux-gtk 2 Is it my installation, or shall I open a bug report? Fixed. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] DB aware components
Hi Folks. Is it normal that when a TDBGrid is dropped onto a TFrame (or descendant) the DataSource property cannot be assigned to a TSqlQuery dropped onto a TDataModule ? In other words, in the properties inspectior of the TDBGrid, the Datasource property shows nothing. The TDataModule is in the uses clause of the TFrame Interface. Otherwise when the TDbGrid is doppêd onto a TForm, the DataSource shows all TDataset descendants dropped into the TDataModule. It appears to be the same for all data aware components that I have tested so far. Finally, assigning the datasource at runtime appears to work. But this is a workaround. Antonio. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Form size locked
Mattias Gaertner wrote: On Sun, 15 Sep 2013 13:17:42 + Mark Morgan Lloyd markmll.laza...@telemetry.co.uk wrote: It appears that a bsDialog form has its actual width and height locked once it has been displayed by ShowModal. Components inside the form, e.g. a PageControl with client alignment, see the dimensions that have been set under program control but the actual form size can be significantly different (larger or smaller). What I've got is a form that displays either a single page if the program is doing a simple login to a host computer, or multiple pages if it's also offering facilities that the host can use; in the case of the single page the pagecontrol tabs are disabled and the overall form shrunk to fit. The first time the form is displayed it's always sized correctly, but if the required login type changes the form size cannot be adjusted. I'm able to use this sort of thing as a workaround: BorderStyle := bsSizeable; Application.ProcessMessages; Width := Tag div 1000; Height := Tag mod 1000; Application.ProcessMessages; BorderStyle := bsDialog; Application.ProcessMessages; PageControl1.ShowTabs := true; PageControl1.ActivePage := TabSheet1; Gtk2, Lazarus 1.0, LCL 1.0.1.3. Please create a bug report with a complete example. Done, http://bugs.freepascal.org/view.php?id=25035 -- 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] DB aware components
On Mon, 16 Sep 2013 10:52:08 +0200 Antonio Fortuny a.fort...@sitasoftware.lu wrote: Hi Folks. Is it normal that when a TDBGrid is dropped onto a TFrame (or descendant) the DataSource property cannot be assigned to a TSqlQuery dropped onto a TDataModule ? In other words, in the properties inspectior of the TDBGrid, the Datasource property shows nothing. The TDataModule is in the uses clause of the TFrame Interface. Otherwise when the TDbGrid is doppêd onto a TForm, the DataSource shows all TDataset descendants dropped into the TDataModule. It appears to be the same for all data aware components that I have tested so far. Finally, assigning the datasource at runtime appears to work. But this is a workaround. Maybe a result of Juha's change: http://wiki.freepascal.org/Lazarus_1.2.0_release_notes#TComponentPropertyEditor_behavior_was_changed Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] DB aware components
Le 16/09/2013 11:12, Mattias Gaertner a écrit : On Mon, 16 Sep 2013 10:52:08 +0200 Antonio Fortuny a.fort...@sitasoftware.lu wrote: Hi Folks. Is it normal that when a TDBGrid is dropped onto a TFrame (or descendant) the DataSource property cannot be assigned to a TSqlQuery dropped onto a TDataModule ? In other words, in the properties inspectior of the TDBGrid, the Datasource property shows nothing. The TDataModule is in the uses clause of the TFrame Interface. Otherwise when the TDbGrid is doppêd onto a TForm, the DataSource shows all TDataset descendants dropped into the TDataModule. It appears to be the same for all data aware components that I have tested so far. Finally, assigning the datasource at runtime appears to work. But this is a workaround. Maybe a result of Juha's change: http://wiki.freepascal.org/Lazarus_1.2.0_release_notes#TComponentPropertyEditor_behavior_was_changed Could be but I'm currently using 1.0.12 and not 1.2. I'm moving and re-engineering a Delphi application and I wonder how much time I'll loose recoding the Datasources properties :-( Mattias -- ___ 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] Project additions and overrides
On 16/09/13 11:35, Mattias Gaertner wrote: On Sun, 15 Sep 2013 23:54:48 +0300 patspiper patspi...@gmail.com wrote: Hi, I am trying to add a new target (eg: abc) for the project options/additions and overrides. Once OK is pressed, re-entering the additions and overrides shows * instead of the specified target! Lazarus 1.3 r42824 FPC 2.6.3 i386-linux-gtk 2 Is it my installation, or shall I open a bug report? Fixed. Thanks! Note: If a target is defined with nothing beneath it, it gets deleted automatically when the compiler options are reopened. Is this by design? Stephano -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Project additions and overrides
On Mon, 16 Sep 2013 13:20:58 +0300 patspiper patspi...@gmail.com wrote: [...] Note: If a target is defined with nothing beneath it, it gets deleted automatically when the compiler options are reopened. Is this by design? Yes. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] DB aware components
In the same way, travelling within a TFrame components doesn't work too. When clicking over any component on the TFrame using either TAB or any other arrow key has no effect. At runtime, it works. Antonio. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] DB aware components
Same for TImageList. A TImageList is dropped onto a TDataModule, included in the interface uses, but a TToolBar does not see the TImagesList in the TDataModule. This breaks completely the porting from Delphi. I'm really very disapponted. I've made another test as explained in the Wiki page http://wiki.freepascal.org/Frames - build a new TFrame - add the unit to the project units list (otherwise it is not droppable) - drop it onto a TTabSheet of a TPageCpntrol in the main form - drop a TSqlQuery onto the TFrame: this time, the objects in the TDataModule created before, are displayed in properties of the TFrame components (database for TSqlQuery, i.e.). It's a long way to ... This way does not allow to create independent TFrames and fill them with all pertinent components and code and that's exactly what I need. All the TFrames are independent and dynamically created as the user runs thru the application. Antonio. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Mac (or other BigEndian machine) users needed to test new Utf8StringOfChar code
Hi, Current code for Utf8StringOfChar that I wrote (in LazUtf8 unit) may fail due to Utf8 - UTF16 - FillWord - Utf8 conversions, which only work for UCS2, as Mattias pointed out to me. I constructed a new Utf8StringOfChar function that builds UTF8 without conversions. For speed reasons it uses FillWord or FillDWord when appropriate. To be sure this is Endian safe (It works AFAICS on Windows i386) I need Mac users (or testers with other BigEndian architecture) to test the code: function Utf8StringOfChar(AUtf8Char: Utf8String; N: Integer): Utf8String; var UCharLen, i: Integer; W: Word; DW: DWORD; C1, C2, C3: Char; PC: PChar; begin Result := ''; if Utf8Length(AUtf8Char) 1 then Exit; UCharLen := Length(AUtf8Char); Case UCharLen of 1: Result := StringOfChar(AUtf8Char[1], N); 2: begin SetLength(Result, 2 * N); W := Byte(AUtf8Char[1]) + (Word(Byte(AUtf8Char[2])) shl 8); W := LeToN(W); System.FillWord(Result[1], N, W);; end; 3: begin SetLength(Result, 3 * N); C1 := AUtf8Char[1]; C2 := AUtf8Char[2]; C3 := AUtf8Char[3]; PC := PChar(Result); for i:=1 to N do begin PC^ := C1; inc(PC); PC^ := C2; inc(PC); PC^ := C3; inc(PC); end; end; 4: begin SetLength(Result, 4 * N); DW := Byte(AUtf8Char[1]) + (Word(Byte(AUtf8Char[2])) shl 8) + (Byte(AUtf8Char[3]) + (Word(Byte(AUtf8Char[4])) shl 8)) shl 16; DW := LeToN(DW); System.FillDWord(Result[1], N, DW); end; else begin //In November 2003 UTF-8 was restricted by RFC 3629 to four bytes to match //the constraints of the UTF-16 character encoding. //http://en.wikipedia.org/wiki/UTF-8 Result := StringOfChar('?', N); end; end; end; End here's the testing code in an OnClick event of a Button: It uses a console for output, so either run it from console, redirect output, or replace the write/writeln with e.g. memo1.lines.add(). procedure TForm1.Button6Click(Sender: TObject); var ResS: String; UChar: String; Expected: String; i,j,k: Integer; const N = 4; Utf8Sample: Array[1..3] of String = (#$C2#$A2,// ¢ #$E2#$82#$AC,// € #$F0#$A4#$AD#$A2 // 䭢 ); begin for k := 1 to 3 do begin UChar := Utf8Sample[k]; Expected := ''; for i := 1 to N do Expected := Expected + UChar; ResS := Utf8StringOfChar(UChar, N); write('Testing: '); write(Length(UChar),'-byte codepoint: '); for j := 1 to length(UChar) do write('$',IntToHex(Ord(UChar[j]),2),' '); writeln; writeln('Expected Length = ',Length(Expected)); writeln('Found Length= ',Length(ResS)); write('Expected: '); for i := 1 to length(Expected) do write('$',IntToHex(Ord(Expected[i]),2),' '); writeln; write('Found : '); for i := 1 to length(ResS) do write('$',IntToHex(Ord(ResS[i]),2),' '); writeln; if ResS Expected then begin if Length(ResS) Length(Expected) then writeln('Different Lengths') else begin i := 1; while (length(ResS) = i) and (ResS[i] = Expected[i]) do Inc(i); writeln('Fail: at position ',i,': Expected = $',IntToHex(Ord(Expected[i]),2),' Found = $',IntToHex(Ord(ResS[i]),2)); end; end else writeln('Success!'); writeln; end; end; B.t.w the new code isn't in trunk yet, I'ld rather first fix it if it's broke on BigEndian machines. Thanks in advance. Bart -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PascalScript and Self instance
On 16/09/2013 18:03, silvioprog wrote: Hello, I'm trying to set an instance to after to call a method (called as WriteLn) of it, but the result is: [Error] (1:7): Unknown identifier 'WriteLn' In attached the small project showing my implementation. So, how to I set an instance to be used as default in my scripts? Thank you! MAybe later more. Have you looked at the editormacroscript package? IT does exactly that -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PascalScript and Self instance
2013/9/16 silvioprog silviop...@gmail.com 2013/9/16 Martin laza...@mfriebe.de Ok, found the answer in the lpr. I would not expect that to work, after all you cant do it in normal pascal either? the main begin end is a program does not belong to a class. Writeln was only by way of illustration, it could be anything else. :) Problem solved with: program project1; {$mode objfpc}{$H+} uses uPSComponent, myclass, uPSI_myclass; type TApp = class private Fobj: TMyClass; Fps: TPSScript; public constructor Create; destructor Destroy; override; procedure OnCompile(Sender: TPSScript); procedure OnExecute(Sender: TPSScript); property ps: TPSScript read Fps; property obj: TMyClass read Fobj write Fobj; end; constructor TApp.Create; begin Fps := TPSScript.Create(nil); Fps.OnCompile := @OnCompile; Fps.OnExecute := @OnExecute; end; destructor TApp.Destroy; begin Fps.Free; inherited Destroy; end; procedure TApp.OnCompile(Sender: TPSScript); begin Sender.AddRegisteredVariable('Self', 'TMyClass'); end; procedure TApp.OnExecute(Sender: TPSScript); begin Sender.SetVarToInstance('SELF', Fobj); end; var app: TApp; i: integer; obj: TMyClass; pl: TPSImport_myclass; begin app := TApp.Create; pl := TPSImport_myclass.Create(nil); obj := TMyClass.Create; try app.obj := obj; TPSPluginItem(app.ps.Plugins.Add).Plugin := pl; app.ps.Script.Text := 'begin Self.WriteLn(''OK''); end.'; if app.ps.Compile then app.ps.Execute; WriteLn(obj.Data); WriteLn('--'); for i := 0 to Pred(app.ps.Comp.MsgCount) do WriteLn(app.ps.Comp.Msg[I].MessageToString); finally obj.Free; pl.Free; app.ps.Free; end; ReadLn; end. Thank you very much! (y) Or: program project1; {$mode objfpc}{$H+} uses uPSCompiler, uPSRuntime, uPSC_std, uPSR_std, myclass, uPSI_myclass; function ScriptOnUses(Sender: TPSPascalCompiler; const Name: string): boolean; begin if Name = 'SYSTEM' then begin SIRegister_Std(Sender); SIRegister_myclass(Sender); AddImportedClassVariable(Sender, 'Self', 'TMyClass'); Result := True; end else Result := False; end; procedure ExecuteScript(const Script: string); var Compiler: TPSPascalCompiler; Exec: TPSExec; Data: string; CI: TPSRuntimeClassImporter; obj: TMyClass; begin Compiler := TPSPascalCompiler.Create; Compiler.OnUses := @ScriptOnUses; if not Compiler.Compile(Script) then begin Compiler.Free; Exit; end; Compiler.GetOutput(Data); Compiler.Free; CI := TPSRuntimeClassImporter.Create; RIRegister_Std(CI); RIRegister_myclass(CI); Exec := TPSExec.Create; RegisterClassLibraryRuntime(Exec, CI); if not Exec.LoadData(Data) then begin Exec.Free; Exit; end; obj := TMyClass.Create; SetVariantToClass(Exec.GetVarNo(Exec.GetVar('SELF')), obj); Exec.RunScript; WriteLn(obj.Data); Exec.Free; obj.Free; CI.Free; end; begin ExecuteScript('begin Self.WriteLn(''OK'') end.'); ReadLn; end. -- Silvio Clécio My public projects - github.com/silvioprog -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PascalScript and Self instance
On 16/09/2013 18:58, silvioprog wrote: 2013/9/16 Martin laza...@mfriebe.de mailto:laza...@mfriebe.de What do you mean passing the self const as default? I'm trying it: TMyClass = class private FData: string; public procedure WriteLn(const S: string); ... var obj: TMyClass; ps.SetVarToInstance('SELF', obj); So when I call WriteLn, it must call WriteLn of my obj instance. Please see the full code in attached in previous e-mail. yes found it. Never used SetVarToInstance, dont know if it does what you want. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Mac (or other BigEndian machine) users needed to test new Utf8StringOfChar code
On 9/16/13, Hans-Peter Diettrich drdiettri...@aol.com wrote: Did you also test the simpler approach, replicating the pattern in one loop? It's independent of endianness, and can boil down to a single machine instruction (x86: REP MOVS). It would be repeating either 2,3, or 4-bytes each time. How would you code that? Simplified version, should be Endian safe: function Utf8StringOfChar(AUtf8Char: Utf8String; N: Integer): Utf8String; var UCharLen, i: Integer; C1, C2, C3: Char; PC: PChar; begin Result := ''; if (N = 0) or (Utf8Length(AUtf8Char) 1) then Exit; UCharLen := Length(AUtf8Char); Case UCharLen of 1: Result := StringOfChar(AUtf8Char[1], N); 2: begin SetLength(Result, 2 * N); System.FillWord(Result[1], N, PWord(Pointer(AUtf8Char))^);; end; 3: begin SetLength(Result, 3 * N); C1 := AUtf8Char[1]; C2 := AUtf8Char[2]; C3 := AUtf8Char[3]; PC := PChar(Result); for i:=1 to N do begin PC^ := C1; inc(PC); PC^ := C2; inc(PC); PC^ := C3; inc(PC); end; end; 4: begin SetLength(Result, 4 * N); System.FillDWord(Result[1], N, PDWord(Pointer(AUtf8Char))^); end; else begin //In November 2003 UTF-8 was restricted by RFC 3629 to four bytes to match //the constraints of the UTF-16 character encoding. //http://en.wikipedia.org/wiki/UTF-8 Result := StringOfChar('?', N); end; end; end; Bart -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PascalScript and Self instance
2013/9/16 Martin laza...@mfriebe.de What do you mean passing the self const as default? I'm trying it: TMyClass = class private FData: string; public procedure WriteLn(const S: string); ... var obj: TMyClass; ps.SetVarToInstance('SELF', obj); So when I call WriteLn, it must call WriteLn of my obj instance. Please see the full code in attached in previous e-mail. -- Silvio Clécio My public projects - github.com/silvioprog -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PascalScript and Self instance
2013/9/16 Martin laza...@mfriebe.de On 16/09/2013 18:03, silvioprog wrote: Hello, I'm trying to set an instance to after to call a method (called as WriteLn) of it, but the result is: [Error] (1:7): Unknown identifier 'WriteLn' In attached the small project showing my implementation. So, how to I set an instance to be used as default in my scripts? Thank you! Maybe later more. Have you looked at the editormacroscript package? IT does exactly that Hm... I saw all units of editormacroscript, but I still don't understand how the Lazarus team pass the SELF instance as default. :( Thank you anyway! -- Silvio Clécio My public projects - github.com/silvioprog -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PascalScript and Self instance
2013/9/16 Martin laza...@mfriebe.de Ok, found the answer in the lpr. I would not expect that to work, after all you cant do it in normal pascal either? the main begin end is a program does not belong to a class. Writeln was only by way of illustration, it could be anything else. :) Problem solved with: program project1; {$mode objfpc}{$H+} uses uPSComponent, myclass, uPSI_myclass; type TApp = class private Fobj: TMyClass; Fps: TPSScript; public constructor Create; destructor Destroy; override; procedure OnCompile(Sender: TPSScript); procedure OnExecute(Sender: TPSScript); property ps: TPSScript read Fps; property obj: TMyClass read Fobj write Fobj; end; constructor TApp.Create; begin Fps := TPSScript.Create(nil); Fps.OnCompile := @OnCompile; Fps.OnExecute := @OnExecute; end; destructor TApp.Destroy; begin Fps.Free; inherited Destroy; end; procedure TApp.OnCompile(Sender: TPSScript); begin Sender.AddRegisteredVariable('Self', 'TMyClass'); end; procedure TApp.OnExecute(Sender: TPSScript); begin Sender.SetVarToInstance('SELF', Fobj); end; var app: TApp; i: integer; obj: TMyClass; pl: TPSImport_myclass; begin app := TApp.Create; pl := TPSImport_myclass.Create(nil); obj := TMyClass.Create; try app.obj := obj; TPSPluginItem(app.ps.Plugins.Add).Plugin := pl; app.ps.Script.Text := 'begin Self.WriteLn(''OK''); end.'; if app.ps.Compile then app.ps.Execute; WriteLn(obj.Data); WriteLn('--'); for i := 0 to Pred(app.ps.Comp.MsgCount) do WriteLn(app.ps.Comp.Msg[I].MessageToString); finally obj.Free; pl.Free; app.ps.Free; end; ReadLn; end. Thank you very much! (y) -- Silvio Clécio My public projects - github.com/silvioprog -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Creating a binary install file.
On Mon, 16 Sep 2013 11:29:35 -0500 Terry A. Haimann te...@haimann.us wrote: I have a Lazarus App that I would like to create a dpkg and maybe an rpm. Never done this and don't know how. The App currently uses MySQL and connects to it with ZeosDbo. Any help would be greatly appreciated. Maybe this page helps: http://wiki.lazarus.freepascal.org/Deploying_Your_Application Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PascalScript and Self instance
On 16/09/2013 18:42, silvioprog wrote: 2013/9/16 Martin laza...@mfriebe.de mailto:laza...@mfriebe.de On 16/09/2013 18:03, silvioprog wrote: Hello, I'm trying to set an instance to after to call a method (called as WriteLn) of it, but the result is: [Error] (1:7): Unknown identifier 'WriteLn' In attached the small project showing my implementation. So, how to I set an instance to be used as default in my scripts? Thank you! Maybe later more. Have you looked at the editormacroscript package? IT does exactly that Hm... I saw all units of editormacroscript, but I still don't understand how the Lazarus team pass the SELF instance as default. :( Thank you anyway! What do you mean passing the self const as default? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PascalScript and Self instance
On 16/09/2013 18:54, Martin wrote: Hm... I saw all units of editormacroscript, but I still don't understand how the Lazarus team pass the SELF instance as default. :( Thank you anyway! What do you mean passing the self const as default? Ok, found the answer in the lpr. I would not expect that to work, after all you cant do it in normal pascal either? the main begin end is a program does not belong to a class. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Creating a binary install file.
I have a Lazarus App that I would like to create a dpkg and maybe an rpm. Never done this and don't know how. The App currently uses MySQL and connects to it with ZeosDbo. Any help would be greatly appreciated. Thx in Advance, Terry -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Mac (or other BigEndian machine) users needed to test new Utf8StringOfChar code
Bart schrieb: Hi, Current code for Utf8StringOfChar that I wrote (in LazUtf8 unit) may fail due to Utf8 - UTF16 - FillWord - Utf8 conversions, which only work for UCS2, as Mattias pointed out to me. I constructed a new Utf8StringOfChar function that builds UTF8 without conversions. For speed reasons it uses FillWord or FillDWord when appropriate. Did you also test the simpler approach, replicating the pattern in one loop? It's independent of endianness, and can boil down to a single machine instruction (x86: REP MOVS). DoDi -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Save/Discard dialog, keyboard answers
When I close a file in Lazarus and is has been modified I am asked: File xxx..xxx has changed. Save? and there are 3 buttons: Save Discard changes Abort but only the Save button has an underlined letter (S) which I can type on the keybord to answer. If I want to Discard changes I don't know what to type because there is no underlined letter that can be typed for this answer. Neither D nor N work. The same for Abort (although escape works and is quite natural). Is this intended or a bug? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PascalScript and Self instance
2013/9/16 silvioprog silviop...@gmail.com 2013/9/16 Martin laza...@mfriebe.de What do you mean passing the self const as default? I'm trying it: TMyClass = class private FData: string; public procedure WriteLn(const S: string); ... var obj: TMyClass; ps.SetVarToInstance('SELF', obj); So when I call WriteLn, it must call WriteLn of my obj instance. Please see the full code in attached in previous e-mail. OMG, I think that I found an useful sample(*). I'll try it. :) (*) http://forum.lazarus.freepascal.org/index.php?topic=15563.0 -- Silvio Clécio My public projects - github.com/silvioprog -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] TThread.CurrentThread fails on Linux
Hello all. In it's current form (r23227) CurrentThreadVar it's not initialized before calling Execute in the TThread implementation for Linux (Unix). Due to this the calls to TThread.CurrentThread always returns references to TExternalThread instances, guessing that the current thread is not a FPC thread (due to CurrentThreadVar being nil), even for actual TThread threads. Adding the line: CurrentThreadVar := LThread; somewhere before calling Execute in ThreadFunc in rtl/unix/tthread.inc solves this problem. Also: the TExternalThread instances created by TThread.CurrentThread are never freed, and so effectively leaked, isn't it? Thanks, Mario -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TThread.CurrentThread fails on Linux
On 16.09.2013 23:13, Mario R. Carro wrote: Hello all. In it's current form (r23227) CurrentThreadVar it's not initialized before calling Execute in the TThread implementation for Linux (Unix). Due to this the calls to TThread.CurrentThread always returns references to TExternalThread instances, guessing that the current thread is not a FPC thread (due to CurrentThreadVar being nil), even for actual TThread threads. Adding the line: CurrentThreadVar := LThread; somewhere before calling Execute in ThreadFunc in rtl/unix/tthread.inc solves this problem. Why the hell does the Unix implementation use a different thread function which does the same in the end?! O.o Please create a bug report. Also: the TExternalThread instances created by TThread.CurrentThread are never freed, and so effectively leaked, isn't it? They are freed at the end of the program. Regards, Sven -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Mac (or other BigEndian machine) users needed to test new Utf8StringOfChar code
Bart schrieb: Did you also test the simpler approach, replicating the pattern in one loop? It's independent of endianness, and can boil down to a single machine instruction (x86: REP MOVS). It would be repeating either 2,3, or 4-bytes each time. How would you code that? I would not care. function Utf8StringOfChar(AUtf8Char: Utf8String; N: Integer): Utf8String; var UCharLen, i,nb: Integer; PC: PChar; begin Result := ''; UCharLen := Length(AUtf8Char); nb := N*UCharLen; if nb = 0 then exit; //3: Result := AUtf8Char; SetLength(Result, nb); PC := Result; for i:=1 to nb-UCharLen do begin PC[UCharLen] := PC[0] inc(PC); end; end; DoDi -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TTreenode.data
Thanks Antonio, that worked fine. Goodness knows what I was originally doing! Richard Details are missing about your implementation: Lzarus FPC, OS, etc. I've made a little test on Win32 and Linux_X64, Lazarus 1.0.12 I added some nodes to the TTreeView like this: var SData: Integer=179; procedure TFrmMain.BtnTestTvClick(Sender: TObject); var wNode: TTreeNode = nil; s: String; begin Inc(SData); wNode := Ttv.Items.AddChildObject(nil, 'node new', Pointer(SData)); s := Format('node %s data:%d', [wNode.Text, PtrInt(wNode.Data)]); MessageDlg('Titre', s, mtInformation, [mbOK], 0, mbOK); end; The I added an event to Ttv.OnChange event like that: procedure TFrmMain.TtvChange(Sender: TObject; Node: TTreeNode); var wData: Integer; begin if Assigned(Node) then begin wData := PtrInt(Node.Data); MessageDlg('Titre',Format('data for %s %d', [Node.Text, wData]), mtInformation, [mbOK], 0, mbOK); end; end; I get a new node on every BtnTestTvClick and a value starting from 180 on every OnChange event On both platforms. Antonio. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus