Members

7

1578

Members

6

382

Members

4

659

Members

3

109

Popular Content

Showing content with the highest reputation on 11/19/20 in all areas

1. Hex2Binary

@David Heffernan Few remarks about your code if you don't mind : 1- Its pointless to use string when characters are fixed in size ... Simply use static array of X char. 2- Its also pointless to calculate index when you already used a case ... Simply declare your array using char-range. In your case, compiler generated additional instructions to compute the index. function HexToBin2(const HexValue: string): string; type TChar4 = array [0 .. 3] of Char; PChar4 = ^TChar4; const Table1: array ['0' .. '9'] of TChar4 = ('0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001'); Table2: array ['a' .. 'f'] of TChar4 = ('1010', '1011', '1100', '1101', '1110', '1111'); var HexDigit: Char; P: PChar4; begin SetLength(Result, Length(HexValue) * 4); P := PChar4(Result); for HexDigit in HexValue do begin case HexDigit of '0' .. '9': P^ := Table1[HexDigit]; 'a' .. 'f': P^ := Table2[HexDigit]; 'A' .. 'F': P^ := Table2[Chr(Ord(HexDigit) xor \$20)]; else raise EConvertError.CreateFmt('Invalid hex digit ''%s'' found in ''%s''', [HexDigit, HexValue]); end; Inc(P); end; end;
2. Hex2Binary

I'd probably write it something like this: function HexToBin(const HexValue: string): string; const BinaryValues: array [0..15] of string = ( '0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111' ); var HexDigit: Char; HexDigitValue: Integer; Ptr: PChar; begin SetLength(Result, Length(HexValue) * 4); Ptr := Pointer(Result); for HexDigit in HexValue do begin case HexDigit of '0'..'9': HexDigitValue := Ord(HexDigit) - Ord('0'); 'a'..'f': HexDigitValue := 10 + Ord(HexDigit) - Ord('a'); 'A'..'F': HexDigitValue := 10 + Ord(HexDigit) - Ord('A'); else raise EConvertError.CreateFmt('Invalid hex digit ''%s'' found in ''%s''', [HexDigit, HexValue]); end; Move(Pointer(BinaryValues[HexDigitValue])^, Ptr^, 4 * SizeOf(Char)); Inc(Ptr, 4); end; end; Some notes: A case statement makes this quite readable in my view. You really don't want to be wasting time using Pos to search within a string. You can get the value directly with arithmetic. I prefer to perform just a single allocation, rather than use repeated allocations with concatenation. You might want to consider how to treat leading zeros. For instance how should you treat 0F, should that be 00001111 or 1111? I'd expect that both would be desirable in different situations, so an option in an extra argument to the function would be needed.

I used Delphi Professional for years, and had the Firedac add-on as together they gave me all I wanted from the product. I'm not into cross-platform development or server development so Enterprise was of no interest. Until they stopped the FireDac add-on in Profession a few years back. However, at the same time, they did a very good deal (so I thought!) to migrate to Enterprise, which includes Firedac. Which I did. Pity, I should have bitten the bullet then and used a different method of connecting databases, and stuck with Professional. All my projects used Firedac quite intensively so to move away from Enterprise now would be a major step. The cost of an Enterprise licence went up over 30% this year, completely unjustifiable in my opinion, and I've therefore lapsed my licence. 10.4.1 is where I am and where I'll stay for the foreseeable future.
4. Welcome, users of C++Builder

Even though we are a Delphi forum, we have a considerable number of users of the C++Builder among us. Without shifting the basic focus of this forum, we are aware of the long and close connection between Delphi and C++Builder and therefore want to give its users space for their questions. https://en.delphipraxis.net/forum/41-general-help/

They mainly push us there, which a large part of users do not want. Personally, I only need the Windows platform (VCL). Unfortunately, I'm not alone ...
7. Hex2Binary

You can also optimize David's Move by replacing it with this
8. Hex2Binary

Ugh. You can't rely on getting an AV. Don't ever write code like this.

10. Hex2Binary

@emailx45 I am fan of you do what ever you like, so here a better version of yours without try..except and it is safe And you also can remove UpperCase by adding the small case letters to the table.
11. 64 bit compiler running out of memory

The easiest way to kill the compiler is to have huge cyclic unit dependencies. Try to reduce that. Also if the project was created before unit scope names were introduced you should add the scope names to the units in the uses lists and remove from project options in Unit Scope Names.
12. Hex2Binary

No guarantee that an out of bounds array access leads to an exception. You have just been unlucky that you've seen one every time you ran your code. Once again, nobody should ever write code like that.

Change from FireDAC to another set of components like Devart is not going to be a problem in my case. My software follows a strict MVC architecture. All the Models are independent of the rest for the application and in fact, there are tested as a separate unity. I have a project of Unit-Tests that test separately all the models without link any Controller. Only some functionalities of FireDAC I'm going to miss, but I'm sure that in a new set of components I'm going to find new functionalities too, that is going to make more special the experience. The problem, in my case, is the frustration of making plans and see how Embarcadero doesn't take you into account. To see that Embarcadero trace his own plans without the worry about the plans of his customers. What's Next? Eliminate Professional version, perhaps? They coming bad times to all of us. Times in which the price can be a very, very, very important thing in all the ambits. In these new times, decisions based exclusively on money are going to be frequent.
14. DPM Package Manager - Progress update

Hi All For those who are interested, I have made some progress on this project, and have uploaded an installer with the command line tool and IDE plugins for XE2-10.4 - it's still very much an alpha version (not feature complete or stable) but at least shows the direction I'm heading in. I have added some quick notes on how to get started with dpm https://github.com/DelphiPackageManager/DPM/blob/master/GettingStarted.md The installer can be found here https://github.com/DelphiPackageManager/DPM The IDE plugin is still a bit rough around the edges but reasonably stable. Note that installing design time packages is still being worked on. Most of my open source projects have package binaries under the releases tab (the getting started notes show what to do with them). It's still some way from being ready for production use, we are still working on a website/package repository. If you are a library author, please do take a look. Creating packages is not at all difficult.
15. Hex2Binary

Copies four characters from the BinaryValues constant array item at index HexDigitValue to the location pointed by Ptr.

FireDAC "A D D - O N " is discontinued.
17. TwSocket Udp Client how to receive Bytes Properly ?

Response of Lajos is correct. But anyway, it is better to use a fixed size array as buffer to avoid allocation freeing a dynamic array as each data packet is coming. So write something like this instead: procedure TMainForm.WSocketDataAvailable(Sender: TObject; Error: Word); const BUF_SIZE = 1000; // Or whatever size fits your needs var ABytes : array [0..BUF_SIZE] of bytes; Len : Integer; begin Len := WSocket.Receive(@ABytes[0], BUF_SIZE); if Len = 0 then Exit; if Len < 0 then begin ShowMessage('Error receiving data'); Exit; end; // Process data... end;
18. TwSocket Udp Client how to receive Bytes Properly ?

First you've to initialize aBytes. Try something like this: setLength(aBytes, 1024); wsocket.Receive(aBytes, length(aBytes));
19. Hex2Binary

This is what I use: // aHex is expected hex string of chars: 0..9, A..F function Hex2Bin(const aHex: string): string; const // Array of [hex, binary] pairs cBinArray: Array[0..15, 0..1] of string = (('0', '0000'), ('1', '0001'), ('2', '0010'), ('3', '0011'), ('4', '0100'), ('5', '0101'), ('6', '0110'), ('7', '0111'), ('8', '1000'), ('9', '1001'), ('A', '1010'), ('B', '1011'), ('C', '1100'), ('D', '1101'), ('E', '1110'), ('F', '1111')); var i: integer; x: string; begin Result:=''; // Iterate hex string for x in aHex do // For each hex char find binary result in cBinArray for i := Low(cBinArray) to High(cBinArray) do if cBinArray[i, 0] = x then begin // Concatenate binary results Result := Result + cBinArray[i, 1]; Break; end; end; Note: it expects valid Hex string input (0..9 and A..F chars), so if you need to validate if input is valid hex string, or make it UpperCase (a..f -> A..F), make necessary checks.

That's a honest question, when you know the answer?

Use UniDAC, which is not too expensive and is a good independent alternative to FireDAC. It also supports Lazarus and older versions of Delphi. Switching from FireDAC is not difficult. https://www.devart.com/unidac/

The database access components from DevArt are a good alternative to FireDAC.
23. WinUI in Delphi (planned for 10.5?)

Hm, when will Microsoft start to rewrite Office to use WinUI? Until that happens, I am skeptical whether this will be worth the effort. But I am only a disgruntled old white man^d^d^d^d^d^d^d^d^dVCL developer.
24. Project Bitmaps2Video on GitHub

This is my video-project on GitHub: https://github.com/rmesch/Bitmaps2Video I am presenting it here, because it is useful as it is, but could use some ideas for improvement. Features: A Delphi-class to support encoding of a series of bitmaps and video clips to a video file Requires the ffmpeg-library and is intended as an easy to use interface to this library Versions for Win32/Win64 and a cross-platform version currently supporting Win32/Win64/Android32/Android64 Most popular file formats and codecs supported, more codecs contained in FFMpeg can be registered Rudimentary support for adding an audio-stream Demos for both versions, set up to compile and run "out of the box", as library files and support for their deployment to Android are included There are some problem areas though, the most important one in my opinion being threading issues with TBitmap under Android. For more see the readme and the demos. Critique, ideas, bug reports most welcome, maybe someone would even like to contribute, that would be delightful. There have been valuable contributions so far, but there are some areas which could use the input of an expert. Thanks for reading, Renate
25. Update: C++Builder and Platforms Support

I didn't miss the point, i will always be with quality over pile of pricey useless or half useful stuff, but they missed the point too ! So what is their decision exactly ? that something i need to know and understand to make opinion or decision too, so if anyone can show me what was the decision that is talking about focusing on Windows while the roadmap doesn't show a hint what Windows will get. Is the plan to delay the crossplatform needed work, to work on Windows by investing time and resources in code insight and visual assist ? these two is what on the top of the list for quality and feature, their words, their post. Read the lines and between them. There is no chance to enhance a jack, while they will start to work on Code Insight and Visual Assist, just like LSP, and next road map it will be LSP 2.1 Just yesterday we were struggling to help in porting few API's "For Windows, Built By Microsoft last Monday (It must be)", Delphi and CBuilder were always for Windows, yet they failed or may be succeeded to make each and every developer run left and right to add newer functionality when sometimes it is just one API addition, this is going on since 20 years, and they are talking about quality and focusing on Windows. Kill CBuilder, it is out dated failed and still failing to build something modern and useful of any real projects out there, and when it build it, it is slow, so what is the point of having or wasting resources on failure compiler to make it support C++17 in 2020, just pull the plug and let it rest, and focus on Delphi, make Delphi generate static lib's that can be compiled by real 2020 C++ compilers, and let it use their static libs, that a feature will worth 100X of what called CBuilder, just like JBuilder kill it, or PHP builder . Quality is out of question when the correction is to be done with the same management with same logic, 20 years is enough for a ride, while one years proof of failing for a developer is enough to let go.
×