* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
Databases / Re: DBF Packtable
« Last post by avra on Today at 05:51:07 pm »
I am sure that de DBF is not used, so normal "exclusive" must be OK.
If you forgot to uncheck TDBF's Active property in design mode, then in runtime you have 2 active users on the same DBF.  ::)
2
Beginners / Signalize from object to main form
« Last post by tudi_x on Today at 05:42:17 pm »
hi All,
as per attached i need to signalize when edit completed so i can move to next screen.
is it possible to produce an event inside the screen 1 object that would trigger procedure in main form?

thank you

Lazarus 1.8RC4 , cross platform

Code: Pascal  [Select]
  1. unit screen_1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, ExtCtrls, Graphics, Controls, StdCtrls;
  9.  
  10. type
  11.   TScreen1 = class
  12.   private
  13.     E1: TEdit;
  14.     procedure FinishInput(ASender: TObject);
  15.   public
  16.     constructor Create(AParent: TCustomForm);
  17.     procedure IsVisible(AVisible: boolean);
  18.   end;
  19.  
  20. implementation
  21.  
  22. constructor TScreen1.Create(AParent: TCustomForm);
  23. begin
  24.   E1 := TEdit.Create(AParent);
  25.   E1.OnChange:= @FinishInput;     //hook the check
  26.   E1.Text := 'screen 1';
  27.   E1.Visible := False;
  28.   E1.Parent := AParent;
  29. end;
  30.  
  31. procedure TScreen1.IsVisible(AVisible: boolean);
  32. begin
  33.   E1.Visible := AVisible;
  34. end;
  35.  
  36. procedure TScreen1.FinishInput(ASender: TObject);
  37. begin
  38.   if E1.Text = 'x' then
  39.   begin
  40.     //signalize to switch to screen 2 - to run ShowScreen2
  41.   end;
  42. end;
  43.  
  44. end.
  45.  
3
General / Re: Delete-Insert Logic escapes me!
« Last post by wp on Today at 05:42:09 pm »
A For loop ist definitely faster than Delete and/or Insert, but if you really need some speed then check out this post...

Search: LazForum:
Best way to clean large text files: Reply #4 (himitsu StrReplace) = Really F A S T   !!!
Just looking at the lines of code in this unit I do not believe that they will be faster than the simple "for" loop in this particular case. The only two methods to speed it up are, in my opinion, using assembler or using PChar instead of the character indexes.
4
LCL / Re: Mouse pointer disappeared in DBlookupCombo Box
« Last post by MVD on Today at 05:35:11 pm »
You didn't mention your OS and Lazarus version.
But I see the same behavior with TComboBox even with AutoDropDown to false on Windows with Laz trunk.

Seems like a bug.

(In Delphi the mousepointer stays visible)

Edit: If you set ArrowKeysTraverseList to false you keep the mousepointer.
(but then the first character does nothing)

I see it is the same behavior as in TEdit. When typing the mousepointer disappears unless inside the edit box.
Somehow in Delphi for the TComboBox the mousepointer stays visible. In Lazarus not.

sorry , I am working in Windows 10 and with Lazarus 1.8.0RC4.

Thanks for the explination. What to do if it is a bug?
5
General / Re: Delete-Insert Logic escapes me!
« Last post by Thaddy on Today at 05:19:01 pm »
Note you can also do (AnsiString assumed):
Code: Pascal  [Select]
  1. program program1;
  2. {$ifdef fpc}{$mode delphi}{$H+}{$endif}
  3. uses sysutils;
  4. var buffer:string = '*blaat*;*,blaat,blaat blaat*,bl*at';
  5. begin
  6.  writeln(buffer.replace('*',' ',[rfReplaceAll]));
  7. end.

Uses the new typehelpers for string... fast enough..It does only delete when necessary ('') else it replaces. It is usually fast enough even on long strings or stringlists.text  :D
6
General / Re: Delete-Insert Logic escapes me!
« Last post by RAW on Today at 05:16:14 pm »
A For loop ist definitely faster than Delete and/or Insert, but if you really need some speed then check out this post...

Search: LazForum:
Best way to clean large text files: Reply #4 (himitsu StrReplace) = Really F A S T   !!!
7
General / Re: Delete-Insert Logic escapes me!
« Last post by J-G on Today at 05:08:15 pm »
Thanks Fred/RVK  -  my mind is still stuck in the realms of Turbo Pascal :(   so I haven't fully investigated SysUtils and this project was going to be a 'ten minute' job about 3 hours ago!!

Yes 'Buffer' is a string - rather than a short string - I haven't done much string handling where the length is greater than 255 and this was one of the reasons for the project.

I have found a reason for the error - and as RVK suggests it is something else in the code. There are a number of search and replace routines and one of them involved a semicolon which I mistakenly thought would always be present after an ampersand and when it wasn't, the further processing made the buffer length 'infinite' --- well certainly greater than 'word' --- which totally confused the 'pos' function.

Now StringReplace and ReplaceStr have been brought to my attention I'll look at them  - - -  though WPs suggestion (thanks) might be better  - - -  I'll see which is the quickest.

8
Windows / Re: Using C# DLL in Lazarus
« Last post by Cyrax on Today at 05:01:54 pm »
Code: Pascal  [Select]
  1. void Add3(int left)

translates to

Code: Pascal  [Select]
  1. procedure Add3(left:integer)

If you want result from your subroutine, you need to change C# code to

Code: Pascal  [Select]
  1. int Add3(int left)

and Pascal version to

Code: Pascal  [Select]
  1. function Add3(left:integer) : integer
9
Windows / Re: Using C# DLL in Lazarus
« Last post by JohnRambo on Today at 04:53:56 pm »
OK I made it. :D
Firstly we need to get some information: https://stackoverflow.com/a/9353800
"In C#/C++ you will need to define the Result as out Parameter, in order to maintain binary code compatibility of stdcall calling conventions" - thats the key. In my C# code I was use return. For Delphi its ok, but for Lazarus it is problematic. So I retyped my c# code from:
Code: C#  [Select]
  1.    [ComVisible(true)]
  2.     [ClassInterface(ClassInterfaceType.None)]
  3.     public class DotNetAdder : DelphiNET.IDotNetAdder
  4.     {
  5.         public void Add3(int left)
  6.         {
  7.             return= left + 3;
  8.            
  9.         }
  10.     }

to
Code: C#  [Select]
  1.    [ComVisible(true)]
  2.     [ClassInterface(ClassInterfaceType.None)]
  3.     public class DotNetAdder : DelphiNET.IDotNetAdder
  4.     {
  5.         public void Add3(int left,out int result)
  6.         {
  7.             result= left + 3;
  8.            
  9.         }
  10.     }
And change my pascal code from:
Code: Pascal  [Select]
  1. //interface:
  2.   type
  3.   IDotNetAdder = interface
  4.   ['{ACEEED92-1A35-43fd-8FD8-9BA0F2D7AC31}']
  5.     function Add3(left : integer):integer; stdcall;
  6.   end;
  7.  
  8. //execution:
  9. var
  10.   adder : IDotNetAdder;
  11. begin
  12.   try
  13.    CreateDotNetAdder(adder);
  14.    Writeln('4 + 3 = ', adder.Add3(4));

to
Code: Pascal  [Select]
  1.  
  2. //interface:
  3.   type
  4.   IDotNetAdder = interface
  5.   ['{ACEEED92-1A35-43fd-8FD8-9BA0F2D7AC31}']
  6.     function Add3(left : integer;out result:integer); stdcall;
  7.   end;
  8.  
  9. //execution:
  10.  CreateDotNetAdder(adder);
  11.    i:=4;
  12.    finally
  13.    adder.Add3(i,x);
  14.   showmessage('4 + 3 = '+ (inttostr(x)));
  15.  
10
General / Re: Delete-Insert Logic escapes me!
« Last post by wp on Today at 04:52:18 pm »
If you want to replace the '*' by a single character a simple "for" loop might be more efficient than the sequence of Delete/Insert and probably even ReplaceStr:

Code: Pascal  [Select]
  1. var
  2.   i: Integer;
  3. begin
  4.   for i:=1 to Length(Buffer) do
  5.     if Buffer[i] = '*' then Buffer[i] := ' ';
  6. end;
Pages: [1] 2 3 ... 10

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus