Jump to content

Clément

Members
  • Content Count

    360
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Clément

  1. Clément

    10.3.1 has been released

    Hi, I installed 10.3.1 without any problems. My machine is old and I still have Delphi XE, Berlin, Tokyo and Rio installed. I mostly use Tokyo, but I'm confident and I'm migrating my projects to Rio Update 1. I use the migration tool to export my settings from 10.3 to a file. (Very important step!!!) Used the feature install ( Tools -> Manage platform is present ). Emb. should change the way to distinguish between one and another. Messing up a delphi installation by using the wrong installer would cost at day or two to reinstall everything. Selected "NO" since I WANT TO KEEP MY REGISTRY settings. Please consider change this too. Instead of YES or NO, please use something like: "Keep your settings" / "New installation". Selected all the features I want installed Waited for an hour Clicked "Start working" and voilá(*) *I was almost ready. Some components where there, but other no. Especially my Library path. This is why you need the migration tool. Import the file and you're done! The 10.3.1 IDE is more stable than 10.3. This week I will migrate more projects and I will be able to compare against 10.2, but it seems 10.3.1 is a LOT better than 10.2 I'm working on a Win64 project (Multithreaded TCP/UDP communication with InterThread messaging). With 10.3 I had 4 or 5 crashes a day. With 10.3.1 NONE ( so far ). With 10.2 I had to use IDE Fix pack (No crashes at all for days). So far I'm not using IDE fix pack in 10.3.1 and I don't feel like I need it.
  2. Hi, I wrote this code using XE. It might help you. type TMyRecord = Record item1: string; item2: Integer; Item3: Currency End; TForm68 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } function GetProperties( aTypeInfo : PTypeInfo; var aRec ) : String; end; implementation {$R *.dfm} procedure TForm68.FormCreate(Sender: TObject); var R : TMyRecord; begin Caption := GetProperties( TypeInfo(TMyRecord), R ); end; function TForm68.GetProperties(aTypeInfo: PTypeInfo; var aRec): String; var rtc : TRttiContext; lTyp: TRttiType; lFld : TRttiField; begin rtc := TRttiContext.Create; lTyp := rtc.GetType(aTypeInfo); for lFld in lTyp.GetFields do Result := Result + ' '+ lFld.Name; end; As you can see, all you need is Typeinfo. You can pass aRec as pointer if you need an instance to assign values. The result is obviously: Item1 item2 item3 Hope this helps,
  3. Hi, The fastest way to delete the last character is to not add it. Compare the two following routines: procedure TForm61.Button1Click(Sender: TObject); var i : integer; lList : TStringlist; lResult : String; begin lList := TStringList.Create; lList.Add('Item1'); lList.Add('Item2'); lList.Add('Item3'); lList.Add('Item4'); try lResult := ''; for i := 0 to lList.Count-1 do lResult := lResult+ lList[i]+','; SetLength(lResult, Length(lResult) - 1 ); // Here I must delete the last char finally lList.Free; end; end; procedure TForm61.Button2Click(Sender: TObject); var i : integer; lList : TStringlist; lResult : String; begin lList := TStringList.Create; lList.Add('Item1'); lList.Add('Item2'); lList.Add('Item3'); lList.Add('Item4'); try if lList.Count>0 then begin lResult := lList[0]; for i := 1 to lList.Count-1 do lResult := lResult+','+ lList[i]; end; finally lList.Free; end; end; Every time I get the chance I use the second routine. It's faster and requires less memory reallocation.
  4. Clément

    Pointers are dangerous

    Let's say you receive a string with null chars in several places separating information. For instance: delphipraxis#0pointers are dangerous#0but worth the risk#0000#000#000000#0 How can you quickly process the information, check if they are valid and answer to that request. You have to return a modified string to the client. In that example you have to answer: delphipraxis#0pointers are dangerous#0but worth the risk#0101#022#014995#0 Of course the trick here is to avoid copying string over and over. Allocating and deallocating classes or complex structures to process the input information. With a simple array of pointers I can use this very same memory spot pointing to the beginning of each string without allocating or copying information. The alternative would be to create a class (TStringList for example), set some properties, use "DelimitedText", have a copy of each string , allocate another "Answer string" and at the end deallocating everything ->defragmentation nightmare. (The input string length varies!) Just picture this example in a network with hundred (or thousands) of devices sending requests of 10k bytes ( strings just like the above one but with 10k null separated values), and you get your performance example. Fragmentation is kept to a minimum and a service running for months without any problem. Is it even possible to improve the compiler as much?
  5. Clément

    Pointers are dangerous

    Pointers are part of the package. I use them for performance and low memory footprint especially when dealing with low level code (bytes, records or low level TCP communication). The gain pointers bring to the table is worth the risk.
  6. Hi. I also ended up writing my own JSON serializer/deserializer based on delphi TJsonObject. (Using another JSON class created incompatibilities with RTL). It works on generics (TDictionary<>, TObjectDictionary<>, Tlist<>, etc), Tdataset, TStringList, enum and nested classes. Quite fast. I needed a special TDataset handling (speed wise) that none of the library I tried solved. Anyway, sometimes it's worth reinventing the wheel!
  7. Clément

    http://community.idera.com/ login woes

    Hello, I successfully managed to login to Idera's forum. They fixed the "reset password". I received the email with the link to proceed!
  8. Hi, Are you using FastMM bundled or downloaded (https://github.com/pleriche/FastMM4) ? The downloaded version has a lot more options and gives you more information including line numbers, very handy.
  9. Clément

    Detailed logging (for debugging)

    Hi, Why can't you write your log in levels. For example: MyLog.Info('Entering method X'); Mylog.Debug(1, 'Connecting to database'); MyLog.Debug(2, 'Connected to database = '+FDatabase.ConnectionString ); And the constructor Mylog := TMyLog.Create( 0 ); // No Debug information Mylog := TMyLog.Create( 1 ); // Only Debug 1 Mylog := TMyLog.Create( 2 ); // Debug up to level 2. This way you can activate debug using a INI file. [Settings] Debuglevel = 0; // Or 1 or 2 HTH, Clément
  10. Clément

    New in 10.3: IDE UI Improvements in the Main Window

    Very nice!! I spend every day of the week and sometimes weekend using delphi. The dark theme helped a lot! Those visual enhancements looks really nice! Please make this version very stable! I don't want to wait for an update to start using it!
  11. Clément

    Directions for ARC Memory Management

    Why can't we just write a simple collection of interfaces. That's what I did for some classes. Take for example TStringList: IARCStringList = Inteface procedure Add( aString : string ); procedure AddStrings( aString : string ); function AsStringList : TStringList; ... end; TARCStringList = Class( TInterfacedObject, IARCStringList ) private FList : TStringList; public // Implement all IStringListARC methods and properties. destructor destroy; // Will call FList.Free; end; Usage would be very simple: procedure DoSomething; Var S : IARCStringList; begin S := TARCStringList.Create; S.Add('One'); S.Add('Two'); ListBox1.Items.AddString( S.AsStringList ); // Will return FList end; I wrote for other classes such as TARCDictionary, TARCObjectDictionary, TARCDictionary<K,V>, TARCObjectDictionary<K,O>, etc. I use "const" wherever is required when I use those ARC interfaces. What problems do you see with such implementations (other than writing a lot of code)?
×