I came across a situation in Delphi where a string had to be saved in database columns with a limit of 512 characters. To handle this I cooked up the following Unit with a helper function. I did this in its own unit in case more string manipulation helpers are needed in the future.
unit TopNodeHelpers; interface function Break512(OriginalString: string): TArray; implementation uses System.Math, windows, sysutils; function Break512(OriginalString: string): TArray ; var I, FChunk: integer; FReminder: UInt64; Fparts, FLength: UInt64; begin FChunk := 512; setLength(Result, 0); if length(OriginalString) > 0 then begin Fparts := 0; FLength := length(OriginalString); DivMod(FLength, FChunk, Fparts, FReminder); setLength(Result, Fparts +1); for I := 0 to Fparts do begin OutputDebugString(Pchar(IntToStr(I))); OutputDebugString(Pchar(OriginalString)); Result[I] := Copy(OriginalString, (I * FChunk) + 1, (I + 1) * FChunk); end; end; end; end.