Leaderboard
Popular Content
Showing content with the highest reputation on 10/14/24 in all areas
-
function: how to return nil
Brandon Staggs replied to jesu's topic in Algorithms, Data Structures and Class Design
You're better off doing something like function myfunc(const InVal: String; out OutVal: Double): Boolean; Return True if the value was set and false if not. There are other ways to handle this but the worst way is a magic value in Double. There's no reason to do that when it is so easy to indicate explicitly whether or not the value is valid. -
For anyone else coming across this link, it has moved to: https://chapmanworld.com/calling-linux-commands-from-delphi/
-
function: how to return nil
Der schöne Günther replied to jesu's topic in Algorithms, Data Structures and Class Design
Jesu mentioned using Data.DB.TParams.ParamByName which returns a Data.DB.TParam object. TParam has a property Value which is a Variant. As much as I loathe these things, the approach by @Virgo seems to be the most fitting. -
It works with Indy. In programs I have distributed, I give the user the choice of using FTP or SFTP; the FTP is handled with Indy, SFTP with SecureBridge. You can use it independently but SecureBridge does have an "IOHandler" for providing integration with Indy components, both versions 9 and 10. I have only used it with Windows so cannot speak from experience but their products and support are good and I would expect they are fully supported. From their help manual: From their help manual: I do not have to ship OpenSSL libraries or DLLs with programs I distribute. If there's an update to SSL and clients require newer security protocols, I simply update my SecureBridge components, rebuild the project, and send it out. If I build with packages, I need to include one additional BPL, sbridge290.bpl (for Delphi 12). If you have more detailed questions, they have good support and are happy to answer pre-sales questions. I've been a Devart customer for many years, having used several of their xxxDAC products.
-
Creating forms and running animation are all tasks that need to run in the main thread. Adding background threads would not help here.
-
function: how to return nil
Anders Melander replied to jesu's topic in Algorithms, Data Structures and Class Design
NaN -
@wierdo12 Those examples really helped, thanks! Adding code to the events really slowed the import down, but at least it's working. I'll take out the logging and see how it goes. I didn't realize that GuessFormat actually changed field defs. I was executing it in design mode and that's what was keeping the date field in the dfm as I would save after running in design mode. So these changes worked: Reset my fields after Guess changes them bmFleetDay.GuessFormat; txrdrFleetDayData.DataDef.Fields[13].DataType := atString; txrdrFleetDayData.DataDef.Fields[13].FieldSize := 15; txrdrFleetDayData.DataDef.Fields[26].DataType := atString; txrdrFleetDayData.DataDef.Fields[26].FieldSize := 15; { TODO : Surround with exception handler } result := bmFleetDay.Execute <> 0; procedure TdmLocations.bmFleetDayWriteValue(ASender: TObject; AItem: TFDBatchMoveMappingItem; var AValue: Variant); begin if (AItem.DestField.FieldName = 'StartTime') or (AItem.DestField.FieldName = 'ArrivalTime') then if not VarIsNull(AValue) then if AValue = '--' then begin SiMain.LogMessage(Format('Field: %s Value: %s', [AItem.DestField.FieldName, AValue])); FSkipRecord := True; end; end; Skip record procedure TdmLocations.bmFleetDayWriteRecord(ASender: TObject; var AAction: TFDBatchMoveAction); begin if FSkipRecord then begin SiMain.LogMessage('Skipping Record'); AAction := paSkip; FSkipRecord := False; end; end; I think I'll track skipped records and show user a message with count of corrupted rows Thanks again for the help
-
In file CCR.Exif.BaseUtils.pas you have to change the following lines: From function Realloc(var NewCapacity: Longint): Pointer; override; To function Realloc(var NewCapacity: {$IF CompilerVersion >= 35}NativeInt{$ELSE}LongInt{$IFEND}): Pointer; override; {$IF CompilerVersion < 33} protected {$ELSE} public {$IFEND} And From function TMetadataBlock.TDataStream.Realloc(var NewCapacity: Longint): Pointer; To function TMetadataBlock.TDataStream.Realloc(var NewCapacity: {$IF CompilerVersion >= 35}NativeInt{$ELSE}LongInt{$IFEND}): Pointer;
-
All the CCR realted files should be in the project directory, or you must add the path lib where these files are located (in the project options or in the tool/language/ Delphi options). If the CCR is a standalone project group (runtime o designtime) you must build it after the changes (and the path that you should use is the path where the CCR project group save the DCU files). If the CCR is only a set of Pascal source, your path lib must be the path where the sources are located. Bye
-
It is easier if you paste a text instead a picture. they have changed the signature of the Realloc method: function TMemoryStream.Realloc(var NewCapacity: NativeInt): Pointer;
-
What is the algorithm used to derive the key to a TMyEncryptor ?
Kas Ob. replied to dormky's topic in Databases
Just to fix your problem and workarounds The hash of the password is generated from the WideString of encoded password so const PASSWORD = 'pass'; var keyBytes, PassBytes: TBytes; HashSHA1: THashAlgorithm; HashMD5: THashAlgorithm; begin PassBytes := BytesOf(@WideString(PASSWORD)[1], Length(PASSWORD) * SizeOf(WideChar)); HashSHA1 := THash_SHA1.Create; try HashSHA1.Initialize; HashSHA1.ComputeHash(PassBytes); HashMD5 := THash_MD5.Create; try HashMD5.Initialize; HashMD5.ComputeHash(PassBytes); keyBytes := HashSHA1.Hash + HashMD5.Hash; SetLength(keyBytes, 32); // doing it here is better, triming here 32 for BlowFish or we can later use specify length at 32 with SetKey finally HashMD5.Free; end; finally HashSHA1.Free; end; .... table2.Encryption.Encryptor.SetKey(keyBytes, 0, Length(keyBytes)); // length should be 32 but we don't want to overflow 1) Any hash library will do the same you are free to use your own 2) The length is critical so make sure you are feeding 32 bytes, (and no more ! as strangely enough it does affect the output, meaning the SetKey is not protected from overflowing) 3) There is two version of SetKey, one is bugged and wrong the other does work fine, use the one with the offset and require TBytes as parameter, the one with 3 parameters. -
Best way to store and compare PC configuration data
dormky replied to Shrinavat's topic in Algorithms, Data Structures and Class Design
Doing a file-based comparison will always lead you into problems where something changes, but it's not something that actually impact the configuration in real-life. Better to write code to handle the comparison. If you really don't want to do that, you need empty spaces ie reserve 30 lines for drives and when saving, always sort alphabetically. Each field would have a specific length so no offset changes. But it's going to be a pain. Maybe separate the data you actually want to compare ; even in a single file you can have a marker like a line of '|' after which the data resides and you have a very small script to compare that part of the file and not the rest.