Jump to content

Kryvich

Members
  • Content Count

    437
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Kryvich

  1. Kryvich

    Question on a report writer

    Kryvich's Delphi Reporter - Simple reporting tool with templates in RTF, Word XML, Excel XML, HTML, plain text formats. For basic reports without images, charts, with a simple structure.
  2. Kryvich

    Change of column widths of ListField in TDBLookupComboBox

    @Squall_FF8 DataModule.LookupDatasetField1.DisplayWidth := 10; DataModule.LookupDatasetField2.DisplayWidth := 20; DataModule.LookupDatasetField3.DisplayWidth := 30;
  3. Kryvich

    Change of column widths of ListField in TDBLookupComboBox

    You need to set the DisplayWidth property for the list fields of the list lookup dataset. AFAIK no.
  4. Kryvich

    Tool for finding non-literal format strings

    Definitely. But time is money. If Copilot can do it for you - why not? for Line in Lines do --> Line := Lines.Text;
  5. Kryvich

    Tool for finding non-literal format strings

    Copilot. The result: program FormatStringExtractor; uses SysUtils, Classes; function ContainsPlusBeforeComma(const S: string): Boolean; var PlusPos, CommaPos: Integer; begin PlusPos := Pos('+', S); CommaPos := Pos(',', S); Result := (PlusPos > 0) and (CommaPos > PlusPos); end; procedure ProcessFile(const FileName: string; LogFile: TStrings); var Lines: TStringList; Line, SubStr: string; StartPos, EndPos: Integer; begin Lines := TStringList.Create; try Lines.LoadFromFile(FileName); for Line in Lines do begin StartPos := Pos('Format(', Line); while StartPos > 0 do begin EndPos := PosEx('])', Line, StartPos); if EndPos > 0 then begin SubStr := Copy(Line, StartPos, EndPos - StartPos + 2); if ContainsPlusBeforeComma(SubStr) then LogFile.Add(SubStr); // Move the start position forward to find the next occurrence StartPos := PosEx('Format(', Line, EndPos + 2); end else Break; end; end; finally Lines.Free; end; end; procedure ProcessFolder(const Folder: string; LogFile: TStrings); var SearchRec: TSearchRec; FullPath: string; begin if FindFirst(Folder + '\*.*', faAnyFile, SearchRec) = 0 then begin repeat FullPath := Folder + '\' + SearchRec.Name; if (SearchRec.Attr and faDirectory) = faDirectory then begin if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then ProcessFolder(FullPath, LogFile); end else if ExtractFileExt(SearchRec.Name).ToLower = '.pas' then begin ProcessFile(FullPath, LogFile); end; until FindNext(SearchRec) <> 0; FindClose(SearchRec); end; end; var Folder: string; LogFile: TStringList; begin Write('Enter folder path to scan: '); ReadLn(Folder); LogFile := TStringList.Create; try ProcessFolder(Folder, LogFile); LogFile.SaveToFile('format.log'); WriteLn('Strings saved to format.log'); finally LogFile.Free; end; end.
  6. Kryvich

    ANN: Skia4Delphi v6.4.0 Beta 1

    Can you please elaborate this? Maybe a short article on this topic. P.S. I've noticed that there have been several interesting Delphi projects from Brazilian developers lately. Skia for Delphi, D2Bridge Framework are the most notable.
  7. Kryvich

    Delphi 12.3 is available

    Multiline strings '''...''' were a very nice addition to the language. Still waiting for constructions like case string1 of 'aaa':... DoubleValue := Variant1 if not VarIsNull(Variant1) else 0.0;
  8. Kryvich

    How do I synchronize two TMemo scrolling? [Solved]

    There are three things you can watch forever: fire, water, and code improving. procedure TLinkMemo.CNCommand(var Message: TWMCommand); begin inherited; case Message.NotifyCode of EN_VSCROLL: SyncLink(True); EN_HSCROLL: SyncLink(False); end; end; procedure TLinkMemo.SyncLink(Vertical: Boolean); const BAR_FLAGS: array[Boolean] of Integer = (SB_HORZ, SB_VERT); MSGS: array[Boolean] of Cardinal = (WM_HSCROLL, WM_VSCROLL); var scrollInfo: TScrollInfo; begin if LinkedMemo = nil then Exit; var savedLink := LinkedMemo.LinkedMemo; try LinkedMemo.LinkedMemo := nil; scrollInfo.cbSize := SizeOf(scrollInfo); scrollInfo.fMask := SIF_POS; if GetScrollInfo(Handle, BAR_FLAGS[Vertical], scrollInfo) then LinkedMemo.Perform(MSGS[Vertical], MAKEWPARAM(SB_THUMBPOSITION, scrollInfo.nPos), 0); finally LinkedMemo.LinkedMemo := savedLink; end; end; procedure TLinkMemo.WMHScroll(var Message: TMessage); begin inherited; SyncLink(False); end; procedure TLinkMemo.WMVScroll(var Message: TMessage); begin inherited; SyncLink(True); end;
  9. 1. Python -- First appeared 20 February 1991; 34 years ago 2. C++ -- First appeared 1985; 40 years ago 3. Java -- First appeared May 23, 1995; 29 years ago 4. С -- First appeared 1972; 53 years ago ... 10. Delphi -- Initial release 1995 Attention! Dinosaurs have won prizes!
  10. Kryvich

    How do I synchronize two TMemo scrolling? [Solved]

    @limelect How do you scroll horizontally? I know some programs allow this by holding the shift key down while you operate the scroll wheel. But in our case it doesn't work. I can scroll horizontally by dragging the bottom slider on the scroll bar, or by moving the cursor to the end of the line with the keys.
  11. Kryvich

    How do I synchronize two TMemo scrolling? [Solved]

    OK I checked my code on Windows 7 in VirtualBox. Works like a charm.
  12. Kryvich

    How do I synchronize two TMemo scrolling? [Solved]

    @limelect It's strange. Works fine for me on Windows 10. (Screencast attached). SyncScroll.mp4
  13. Kryvich

    How do I synchronize two TMemo scrolling? [Solved]

    OK, my take. unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TLinkMemo = class(TMemo) private FLinkedMemo: TLinkMemo; procedure SyncLink; protected procedure WndProc(var Message: TMessage); override; public property LinkedMemo: TLinkMemo read FLinkedMemo write FLinkedMemo; end; TMemo = class(TLinkMemo); TForm1 = class(TForm) Memo1: TMemo; Memo2: TMemo; procedure FormCreate(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.dfm} procedure TLinkMemo.WndProc(var Message: TMessage); begin inherited; if (LinkedMemo = nil) or not LinkedMemo.HandleAllocated then Exit; case Message.Msg of WM_HSCROLL, WM_VSCROLL, WM_KEYDOWN, WM_MOUSEFIRST..WM_MOUSELAST: SyncLink; end; end; procedure TLinkMemo.SyncLink; procedure UpdateScrollBar(BarFlag: Integer; Msg: Cardinal); var scrollInfo: TScrollInfo; begin scrollInfo.cbSize := SizeOf(scrollInfo); scrollInfo.fMask := SIF_POS; if GetScrollInfo(Handle, BarFlag, scrollInfo) then LinkedMemo.Perform(Msg, MAKEWPARAM(SB_THUMBPOSITION, scrollInfo.nPos), 0); end; var savedLink: TLinkMemo; begin savedLink := LinkedMemo.LinkedMemo; try LinkedMemo.LinkedMemo := nil; UpdateScrollBar(SB_HORZ, WM_HSCROLL); UpdateScrollBar(SB_VERT, WM_VSCROLL); finally LinkedMemo.LinkedMemo := savedLink; end; end; procedure TForm1.FormCreate(Sender: TObject); begin Memo1.LinkedMemo := Memo2; Memo2.LinkedMemo := Memo1; end; end.
  14. Kryvich

    How do I synchronize two TMemo scrolling? [Solved]

    @limelect I guess you've over-engineered it a bit. @Uwe Raabe gave a great variant, it just needs a bit of tweaking. unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TLinkMemo = class(TMemo) private FLinkedMemo: TLinkMemo; procedure WMVScroll(var Message: TMessage); message WM_VSCROLL; procedure WMHScroll(var Message: TMessage); message WM_HSCROLL; procedure CNCommand(var Message: TWMCommand); message CN_COMMAND; procedure SyncLink; public property LinkedMemo: TLinkMemo read FLinkedMemo write FLinkedMemo; end; TMemo = class(TLinkMemo); TForm1 = class(TForm) Memo1: TMemo; Memo2: TMemo; procedure FormCreate(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.dfm} procedure TLinkMemo.SyncLink; var savedLink: TLinkMemo; myLine, linkLine: Integer; begin if LinkedMemo = nil then Exit; savedLink := LinkedMemo.LinkedMemo; try LinkedMemo.LinkedMemo := nil; LinkedMemo.CaretPos := CaretPos; LinkedMemo.Perform(EM_SCROLLCARET, 0, 0); myLine := Perform(EM_GETFIRSTVISIBLELINE, 0, 0); linkLine := LinkedMemo.Perform(EM_GETFIRSTVISIBLELINE, 0, 0); if myLine <> linkLine then LinkedMemo.Perform(EM_LINESCROLL, 0, myLine - linkLine); finally LinkedMemo.LinkedMemo := savedLink; end; end; procedure TLinkMemo.CNCommand(var Message: TWMCommand); begin inherited; if (Message.NotifyCode = EN_VSCROLL) or (Message.NotifyCode = EN_HSCROLL) then SyncLink; end; procedure TLinkMemo.WMVScroll(var Message: TMessage); begin inherited; SyncLink; end; procedure TLinkMemo.WMHScroll(var Message: TMessage); begin inherited; SyncLink; end; procedure TForm1.FormCreate(Sender: TObject); begin Memo1.LinkedMemo := Memo2; Memo2.LinkedMemo := Memo1; end; end.
  15. Never seen such error in Delphi 12, until today: [dcc32 Fatal Error] CompilerError.dpr(17): F2084 Internal Error: GPFC0000094-152D5B90(15290000)-0 100% repeatability. program CompilerError; {$pointermath on} type PRec = ^TRec; TRec = record end; PArr = ^Arr; Arr = array [0..0] of TRec; var P: Pointer; begin P:=@PArr(P)[0]; P:=@PRec(P)[0]; end. (C) notme
  16. Kryvich

    F2084 Internal Error in Delphi compiler

    @Uwe Raabe I hope the original author (notme) of the snippet has already done this. I've posted it here as a curious fact for those interested (like me). I haven't encountered any internal compiler errors in Delphi in recent years. Although, perhaps this bug has already been fixed in 12.2. (I have 12.1 CE).
  17. Kryvich

    F2084 Internal Error in Delphi compiler

    @Lars Fosdal Meaningless synthetic code. For the compiler developers, to fix an internal error. If they visit this forum. Although this information may not help you, it can help us (Embarcadero) track down the problem if and when you report the error.
  18. Kryvich

    Namespaces in Spring4d code

    @Anders Melander Of course, I wrote about specifying short identifiers like Integer, PByteArray without a namespace inside a code section. Is there anyone here who writes System.Integer, Data.Win.ADODB.TADOQuery etc. in your code? And why? And the second question: if you don't do this for identifiers in your code, then why do it in the uses clause for system unit names?
  19. Kryvich

    Namespaces in Spring4d code

    I mean, you don't have to remember which system unit declares which type. You just write Integer, PByteArray instead of System.Integer, System.Sysutils.PByteArray and that's it! It makes sense to specify a namespace for System/RTL identifiers only in case of ambiguity.
  20. Get paid by the number of lines? (Just kidding)
  21. Kryvich

    Namespaces in Spring4d code

    Embarcadero can sometimes move system types and functions from one RTL unit to another. Should we care in which specific RTL module a particular system type is declared? The Unit Scope Names setting helps abstract away implementation details.
  22. Kryvich

    How to NOT save changes when compiling?

    As a note: I am currently researching LLMs and how to apply them to Delphi programming. This type of question AI like free Copilot answers quite well.
  23. If you have experience with CAI NEURAL API, you can help me. I need to create and train a neural network in Delphi like in TensorFlow, using the linear regression method:: import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense # Model Definition model = Sequential() model.add(Dense(64, input_dim=14, activation='relu')) # Input layer + first hidden layer model.add(Dense(128, activation='relu')) # Second hidden layer model.add(Dense(64, activation='relu')) # Third Hidden Layer model.add(Dense(46, activation='linear')) # Output layer # Compiling the model model.compile(optimizer='adam', loss='mean_squared_error') # Train the model ( X_train and y_train - training data) model.fit(X_train, y_train, epochs=50, batch_size=10, validation_split=0.2) # Prediction for a new order predicted_materials = model.predict(new_order) print(predicted_materials) I created a CAI NEURAL API model, prepared training data, and started training. NN := TNNet.Create(); NFit := TNeuralFit.Create(); CreateWorkMatPairLists(80{%}, 10{%}, 10{%}, TrainingPairs, ValidationPairs, TestPairs); NN.AddLayer([ TNNetInput.Create(WORKS_COUNT), TNNetFullConnectReLU.Create(64), TNNetFullConnectReLU.Create(128), TNNetFullConnectReLU.Create(64), TNNetFullConnectLinear.Create(MATERIALS_COUNT) ]); NFit.InitialLearningRate := 0.001; NFit.LearningRateDecay := 0.01; NFit.L2Decay := 0.00001; NFit.Fit(NN, TrainingPairs, ValidationPairs, TestPairs, {batchsize=}10, {epochs=}50); But I don't know how to set up the optimizer correctly (TensorFlow uses Adam). And how to set the loss function - mean squared error. Does the CAI NEURAL API have such functionality, or do I need to write it myself?
  24. Kryvich

    ANN: HTMl Library 4.9 released. WebUI and more

    Is WebUI optimized for mobile devices, or just for devices with large screens (computers)?
  25. Kryvich

    Two CE Versions on same PC

    In DAV_Compiler.inc file, try adding the following code right after the {$IFDEF VER350}..{$ENDIF VER350} block: {$IFDEF VER360} // RAD Studio 12 Athens {$DEFINE BDS} {$DEFINE COMPILER27} {$IFDEF BCB} {$DEFINE BCB27} {$ELSE} {$DEFINE DELPHI27} {$DEFINE DELPHIRX2} // synonym to DELPHI27 {$DEFINE DELPHICOMPILER27} {$ENDIF BCB} {$IFDEF CPUX64} {$DEFINE 64BIT} {$DEFINE CPU64} {$DEFINE CPUx86_64} {$UNDEF CPU386} {$UNDEF CPU32} {$ELSE} {$DEFINE 32BIT} {$DEFINE CPU32} {$ENDIF} {$DEFINE RTL350_UP} {$UNDEF UNKNOWN_COMPILER_VERSION} {$ENDIF VER360} This is the same code, only {$IFDEF VER350} is replaced with {$IFDEF VER360}. See Compiler versions: https://docwiki.embarcadero.com/RADStudio/Athens/en/Compiler_Versions
×