Jump to content

Lajos Juhász

Members
  • Content Count

    851
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Lajos Juhász

  1. The only problem with it is that you've to write your code in form: lObj:=TMyClass.Create(....); try ..... finally lObj.Free; end; Anyway you would write it in this form. So there is no problem. I believe it's just another phobia. People can be afraid from correct coding style but will happily use FreeAndNil everywhere in the code.
  2. You missed the example with nested try finally. It should be: LA := TRaiseOnMinus.Create( AInputA ); //<== PossibleRaise try LB := TRaiseOnMinus.Create( AInputB ); //<== Possible Raise try finally LB.Free; end; finally LA.Free; end;
  3. You can use multiple try finally or> LA := nil; LB := nil; try LA := TRaiseOnMinus.Create( AInputA ); //<== PossibleRaise LB := TRaiseOnMinus.Create( AInputB ); //<== Possible Raise finally LA.Free; LB.Free; end; In this case before try LA and LB are both nil in case a constructor raises an exception it will still be NIL thus Free will do nothing.
  4. Lajos Juhász

    IDE being destroyed by new versions

    Wrong. The compiler doesn't accept 452 as a member of set of byte. You cannot define a set over a smallint range.
  5. Lajos Juhász

    Application Error

    It's a missing property for TIDMessage class and it's not related to win10. Search in dfm files for DeleteTempFiles and remove the property. In Indy10 TIdMessage doesn't have that property. I don't know whenever it ever had that property (I've never worked with that old version of Indy). Edit: The only case when the application is compiled to use runtime packages. In that case if you provide the wrong bpls for Indy could result this error.
  6. Lajos Juhász

    FDMemTable - exception on EmptyDataset

    I cannot reproduce this in a simple test program. What I did is placed a TFDMemTable into a form: object FDMemTable1: TFDMemTable FetchOptions.AssignedValues = [evMode] FetchOptions.Mode = fmAll ResourceOptions.AssignedValues = [rvSilentMode] ResourceOptions.SilentMode = True UpdateOptions.AssignedValues = [uvCheckRequired, uvAutoCommitUpdates] UpdateOptions.CheckRequired = False UpdateOptions.AutoCommitUpdates = True Left = 304 Top = 224 object FDMemTable1a: TIntegerField FieldName = 'a' end object FDMemTable1b: TStringField FieldName = 'b' Size = 150 end end and a button with the following onclick event: procedure TForm1.Button1Click(Sender: TObject); begin if not FDMemTable1.Active then FDMemTable1.CreateDataSet else begin // FDMemTable1.Open; <- There is no need to do this Active is true FDMemTable1.EmptyDataSet; end; FDMemTable1.Append; FDMemTable1['a']:=1; FDMemTable1['b']:='1'; FDMemTable1.Append; FDMemTable1['a']:=2; FDMemTable1['b']:='2'; FDMemTable1.Append; FDMemTable1['a']:=3; FDMemTable1['b']:='3'; FDMemTable1.Append; FDMemTable1['a']:=4; FDMemTable1['b']:='4'; FDMemTable1.Post; end; It's working with multiple clicks.
  7. Lajos Juhász

    Which version BDE

    since Delphi 2.
  8. Lajos Juhász

    Which version BDE

    In case you're connecting to remote servers you have to buy Enterprise or Architect version. Professional supports only local databases and doesn't include the source code for FD. Before you open the project you have to migrate your project using the included refind utility using the included FireDAC_Migrate_BDE.txt.
  9. Lajos Juhász

    Which version BDE

    FireDAC was written to be replacement for the BDE and there is a script that converts the properties. It really depends the database and methods from BDE you are using in your code. Unfortunately if you're using persistent fields you will have to recreate them as most probably FD will require another class. (You can try to map the data types in the TFDConnection object to the old classes, however I like to keep mapping to minimum.)
  10. Lajos Juhász

    Which version BDE

    BDE is deprecated for 20 years. You can upgrade Delphi but that will change nothing how BDE interacts with Windows. The only solution is to migrate the application to anothe DAC.
  11. In Delphi 11 F11 will eventually focus that part of the object inspector.
  12. Lajos Juhász

    Copy a record from TTable to kbmMemTable??

    Maybe you should try the old way. Append the memtable and set the value for the fields. Depending if you have only couple of fields you can write an the assign statements otherwise use a for loop. Something like this should work (you're copying the structure thus the order of the fields should be the same): var i: integer; begin kbmMemTable.Append; for i:=0 to kbmMemTable.fieldCount-1 do kbmMemTable.fields.value:=myTEDBTable.fields.value; end;
  13. When you're displaying the forms this way they are useless there are no input values to the form and the form doesn't produce any result. You're destroying the instance before the calling code could read the results back. I am aware that you can initialize the form in the formcreate and write the results back in formdestroy but that is a bad design.
  14. I think this is a bad idea, however here is a code for VCL: procedure ShowForm ( ThisForm: TFormClass ) ; var lForm: TForm; begin lForm := ThisForm.Create(nil); try lForm.ShowModal; finally lForm.Free; end; end; {Example to use} procedure TForm1.Button1Click(Sender: TObject); begin ShowForm(Tform1); end; procedure TForm1.Button2Click(Sender: TObject); begin ShowForm(Tform2); end; The difference between VCL and Fmx is that in Fmx you've to define TFormClass: type TFormClass = class of TForm;
  15. Lajos Juhász

    How to set TBytes array to the file size ?

    It guess with the edit the source was removed. HexViewSource.zip
  16. Lajos Juhász

    How to set TBytes array to the file size ?

    Here is the content (I assume by Gary Darby): HexView will display the contents of any file using hexadecimal (base 16) digits. There are 16 hexadecimal digits with values 0 through 15 but labeled "0" through "9" and "A" though "F" for convenience. Each hex digit could also be written with 4 binary bits (0000 to 1111). Hexadecimal numbers are convenient for use in displaying computer memory or files because two of those 4 bit hex digits can represent the basic unit of memory storage, the 8-bit "byte" I've had a version of this one floating around for my own use for years, but just recently realized that i had never posted it. Use of the program is self explanatory; , select a file to browse and use PgUp, PgDn keys to page through it. Ctrl+PgUp will jump to page 1, Ctrl+PgDn will jump to the last page. The "Esc" escape key will close the file. Characters which represent valid characters will be displayed on each line beside the hexadecimal data. Programmer's Notes A TFileStream control is used to access the file to be displayed. In order to avoid memory problems with large files, the amount of data (BufLen) to fill a page is calculated for each display operation based on the current size of the TMemo control. For each page, procedure ShowPage seeks to the start of the next page to be displayed (CurPage*BufLen) and reads BufLen bytes of data. Hexchars is the array containing the 16 hexadecimal character labels. The Delphi code uses a loop on N and J to convert each byte for each line into two display characters and add it to the string, Hex. N reflects the position of the current line start within the buffer and J points tpo the current character being converted. The conversion line of code looks like this: hex:=hex+hexchars[(buffer[n+j] and $F0) shr 4] + hexchars[(buffer[n+j] and $0F)]; The left hand "nibble" (4 bits of a byte) is converted by "and"ing it with hex F0 (11110000 binary) to clear out the right side nibble and then shifted right (= divided by 16) to get it back in the range 0-15 which is then used as an index into the Hexchars array. The right half of the bite is then converted similarly except that there's no need to divide by 16.HexViewSource.zip The displayed lines are added to a TStringlist (List) whose strings are assigned to the Memo1.Lines property after the page has been built. This eliminated a flicker problem that occurred when lines were built directly into Memo1. One more interesting problem that I ran into and which might save some time for you in the future. When a control is aligned to the bottom of the form (like the TStatictext control in this case), and the form is resized to a smaller height, the control is placed below any existing controls. Adjusting the sizes in the OnResize exit is too late to prevent this problem. The solution is to use the OnCanResize exit to predict where the bottom aligned control will be and readjust the size and tops of the other controls in advance of the actual resize operation..
  17. Lajos Juhász

    How to set TBytes array to the file size ?

    You can take a look at http://delphiforfun.org/programs/utilities/hexview.htm.
  18. Lajos Juhász

    How to set TBytes array to the file size ?

    The file doesn't contains UTF-16LE text. You should check for the encoding of the file.
  19. Lajos Juhász

    How to set TBytes array to the file size ?

    In that case load it directly to the field you're going to use to store it in the database.
  20. Lajos Juhász

    How to set TBytes array to the file size ?

    If it's a textfile you can use memo.lines.loadfromfile or read it using TFileStream. For example: var f: TFileStream; buff: TBytes; begin f:=TfileStream.Create('d:\temp\test.txt', fmOpenRead+fmShareDenyNone); try SetLength(buff, f.Size); f.ReadBuffer(buff, f.Size); memo1.lines.text:=TEncoding.ANSI.GetString(buff); finally f.Free; end; end;
  21. Lajos Juhász

    How to set TBytes array to the file size ?

    Why are you doing this? You are allocating 33 bytes and in the next line assign the variable to a new array that is returned by TBinaryReader.ReadBytes.
  22. Lajos Juhász

    How to set TBytes array to the file size ?

    Why do you think that you have to convert NativeInt to Integer?
  23. Lajos Juhász

    Opinions about Pascal vs C/C++ IDE

    You mean something like this? https://blogs.embarcadero.com/start-building-apps-for-single-board-computers-with-delphi-or-c-builder-now/ I didn't watched it as it is not my thing.
  24. Lajos Juhász

    TControlList - Jump to Selected

    I've tested with Delphi 10.4.2 1. A dirty trick would be first set the ItemIndex under the control you would like to select on the top: ControlList1.ItemIndex:=40+(ControlList1.Height div ControlList1.ItemHeight); ControlList1.ItemIndex:=40; 2. OnItemClicked is fired when the itemIndex changes (both from code or user navigation).
  25. Lajos Juhász

    TTitleBarPanel and System/Custom Buttons

    For me it was also hard to set it up correctly for the first time. Unfortunately even in Delphi 11 it has some drawing issues RSP-36291.
×