Lindawb 0 Posted February 25, 2022 (edited) I have this function, i can't convert the vtString and vtChar from Delphi 2006 to Delphi XE10.1 Berlin also as you know vtString not supported after Delphi 2009, what will be alternative to it In Delphi XE 10.1 and how get it working in this function. function checkval(const Values:array of const):boolean; var I:integer; P:byte; S:ShortString; v,d:double; OldPos:integer; ls:boolean; FISize,FISize2:byte; FRecNo:integer; begin SetLength(s,FISize); P:=1; ls:=False; SetLength(s,FISize); P:=1; ls:=False; for I := 0 to High(Values) do with Values do case VType of vtString: // Short string (only the last field in index can be of ShortString type) begin S[P]:=AnsiChar (Length(VString^)); System.Move(VString^[1],S[P+1],Length(VString^)); Inc(P,Length(VString^)+1); ls:=I=High(Values); end; vtChar: begin System.Move(VChar,S[P],SizeOf(VChar)); Inc(P,SizeOf(VChar)); end; end; if P<=FISize then begin if ls then FillChar(S[P],FISize-P+1,#0) else MessageDlg('not valid size.', mtError, [mbOK], 0); end else if P>FISize+1 then raise Exception.Create('Too many Find parameters.'); end; Thank you for any help, I appreciate your time and knowledge , I don't understand explanation , if you can help please reply with complete code . Edited February 25, 2022 by Lindawb Share this post Link to post
qubits 20 Posted February 25, 2022 54 minutes ago, Lindawb said: as you know vtString not supported after Delphi 2009 this was in my help file for d11. function MakeStr(const Args: array of const): string; var I: Integer; begin Result := ''; for I := 0 to High(Args) do with Args[I] do case VType of vtInteger: Result := Result + IntToStr(VInteger); vtBoolean: Result := Result + BoolToStr(VBoolean); vtChar: Result := Result + VChar; vtExtended: Result := Result + FloatToStr(VExtended^); vtString: Result := Result + VString^; vtPChar: Result := Result + VPChar; vtObject: Result := Result + VObject.ClassName; vtClass: Result := Result + VClass.ClassName; vtWideChar: Result := Result + VWideChar; vtPWideChar: Result := Result + VPWideChar; vtAnsiString: Result := Result + string(AnsiString(VAnsiString)); vtUnicodeString: Result := Result + string(UnicodeString(VUnicodeString)); vtCurrency: Result := Result + CurrToStr(VCurrency^); vtVariant: Result := Result + string(VVariant^); vtWideString: Result := Result + string(WideString(VWideString)); vtInt64: Result := Result + IntToStr(VInt64^); end; end; looks like it's still there to me.. Share this post Link to post
Lindawb 0 Posted February 25, 2022 (edited) Thank you, I tried that one too, I appreciate you and Remy for helping , I'm trying to post someone else's complete code, but looks no way till post complete unit, the code posted on the internet log time ago , now I'm trying to convert to Delphi XE10. here Delphi 2006 code, Edited February 26, 2022 by Lindawb Share this post Link to post
qubits 20 Posted February 25, 2022 for me that unit is. unit memSortList; { Copyright (c) 2003. Danijel Tkalcec } {$A-}{$O-} (* This class (with it's source) is given as freeware, with no guarantees. If it doesn't work, or puts your computer to smoke, destroys your data or whatever, DON'T BLAME ME ! It was part of his RemoteTools, which was remote control software, like vnc. I purchased that years ago, don't think it's around anymore. I haven't bothered to try to migrate it, there's been allot of changes and additions since it's creation. Make yourself a GitHub account and post the code there, it's free, or drag the file to the bottom which would attach it to your post. But sorry, no time right now, for this. ~q Share this post Link to post
qubits 20 Posted February 25, 2022 (edited) I should add in case you don't realize.. My unit says "freeware" yours does not, so you should not post it without prior consent from original copyright owner. original author is active here. Edited February 25, 2022 by qubits add content Share this post Link to post
Lindawb 0 Posted February 25, 2022 (edited) 38 minutes ago, qubits said: for me that unit is. unit memSortList; { Copyright (c) 2003. Danijel Tkalcec } {$A-}{$O-} (* This class (with it's source) is given as freeware, with no guarantees. If it doesn't work, or puts your computer to smoke, destroys your data or whatever, DON'T BLAME ME ! It was part of his RemoteTools, which was remote control software, like vnc. I purchased that years ago, don't think it's around anymore. I haven't bothered to try to migrate it, there's been allot of changes and additions since it's creation. Make yourself a GitHub account and post the code there, it's free, or drag the file to the bottom which would attach it to your post. But sorry, no time right now, for this. ~q Thank you, the read me txt says downloaded from http://delphi.icm.edu.pl/newl/midxd30f.htm ( [ sortlist.zip ] [ 5,976 bytes ] ) and modified the code used tor chat program only with ICS tools and I'm converting to Delphi XE 10, I done with most part. Edited February 25, 2022 by Lindawb Share this post Link to post
qubits 20 Posted February 25, 2022 most everything there is super old like me and now that i think about it, i was using RemoteTools with Delphi 5. Share this post Link to post
qubits 20 Posted February 25, 2022 a sorted list of users.. just finished that. i just used a list, like this.. fGamerz:TList<tGamer>; and i sort em like this.. procedure tGameData.SortGamerz; begin // sort gamerz by bestscore fGamerz.Sort( TComparer<TGamer>.Construct( function(const Left, Right: TGamer): Integer begin Result := Left.bestscore - Right.bestscore; end ) ); fGamerz.Reverse; end; should be finished in a day or so, then it'll all be up on my GitHub. ~q Share this post Link to post
Remy Lebeau 1394 Posted February 25, 2022 8 hours ago, Lindawb said: i can't convert the vtString and vtChar from Delphi 2006 to Delphi XE10.1 Berlin Why not? Can you be more specific about the problems you are having with it? 8 hours ago, Lindawb said: also as you know vtString not supported after Delphi 2009 Yes, it is. Where did you get that idea from? 8 hours ago, Lindawb said: how get it working in this function. Did that code ever work to begin with? The very first thing it is doing is calling SetLength() (twice!) on a ShortString using an uninitialized FISize variable. Did you remove code not shown here? Where is FISize calculated? In any case, vtChar represents an AnsiChar. System.Char was changed from AnsiChar to WideChar in D2009, so you need to handle vtWideChar now, converting/truncating it to an AnsiChar before copying it into your ShortString. I already showed you earlier how to properly handle vtString, vtAnsiString, vtWideString, and vtUnicodeString and copy them into the ShortString. That said, it is really hard to help you when you keep showing PIECES of code, and not the WHOLE code. It is really hard to understand what your target ShortString is supposed to actually look like given various inputs (or why are you even using ShortString to begin with!!!). And you haven't shown ANY examples of what the input array even looks like to begin with. Share this post Link to post
Remy Lebeau 1394 Posted February 25, 2022 (edited) 5 hours ago, Lindawb said: function TSortList.FindKey(const Values:array of const):boolean; var ... begin // Fill scan-string "s" SetLength(s,FISize); P:=1; ls:=False; In this code, FISize is not a local variable! It is a class member instead. That makes a big difference. Quote vtPWideChar,vtAnsiString: // Long string (only the last field in index can be of ShortString type) begin S[P]:=AnsiChar(Length(String(VPChar))); System.Move(String(VPChar)[1],S[P+1],Length(String(VPChar))); Inc(P,Length(String(VPChar))+1); ls:=I=High(Values); end; That is completely wrong, and shouldn't have worked even before D2009. vtPWideChar and vtAnsiString are completely different and incompatible types, they need to be handled separately (like I showed you earlier). vtPChar (TVarRec.VPChar) is a null-terminated PAnsiChar, whereas vtPWideChar (TVarRec.VPWideChar) is a null-terminated PWideChar, and TVarRec.VAnsiString is a pointer to an AnsiString's internal payload. You can't treat those 3 pointers the same way. For the purpose of this code, TVarRec.VPChar can be used as-is, but TVarRec.VPWideChar would need to be assigned to a temp AnsiString, and TVarRec.VAnsiString would need to be type-casted into an AnsiString, before their characters can be copied into the ShortString (like I showed you earlier). Edited February 25, 2022 by Remy Lebeau Share this post Link to post
qubits 20 Posted February 26, 2022 here's the unit i got, same author. looks like it anyway. if you're curious.. there's no vtWide anything in there.. memSortList.pas Share this post Link to post
Lindawb 0 Posted February 26, 2022 Hello, Thank you all for all your help and valuable time, I gave up :( I worked on the project for months and end up with dropping it, beyond my knowledge, BTW: I did download the memSortList.pas and compared with that zipped with files, looks same, there is no UnicodeString in them means very old code. Thank you all again, I will edit that my post and remove it . Share this post Link to post
Remy Lebeau 1394 Posted February 28, 2022 (edited) On 2/25/2022 at 4:21 PM, qubits said: there's no vtWide anything in there.. That code pre-dates Delphi's shift to Unicode in D2009. But vtWideString and vtPWChar did exist prior to that shift. That code simply does not support Unicode strings at all. Edited February 28, 2022 by Remy Lebeau Share this post Link to post