Overview
I want to check if the property name is 'caption' or 'text'. In windows or OSX if do this by comparing the string.
if (PListe^[IdxProp]^.Name = 'Caption') or (PListe^[IdxProp]^.Name = 'Text') then
When compiling for mobile, I've found that using NEXTGEN compiler, the name property is no longer a ShortString but a Byte.
If I look at the Name property of TPropInfo in System.TypInfo, Name : TSymbolName :
type
{$IFDEF NEXTGEN}
TSymbolName = Byte;
{$ELSE NEXTGEN}
TSymbolNameBase = string[255];
TSymbolName = type TSymbolNameBase;
{$ENDIF NEXTGEN}
Then I can not now compare with string 'text' or 'caption' directly. I've tried to convert 'text' and 'caption' string to array of Byte :
Code Snippet
var
PListe : PPropList;
IdxProp: Integer;
NbProps: Integer;
strTmp, sPropName : string;
{$IFDEF NEXTGEN}
BinarySize: Integer;
InputString: string;
StringAsBytes_Caption: array of Byte;
StringAsBytes_Text: array of Byte;
{$ENDIF NEXTGEN}
Begin
New(PListe);
NbProps := GetPropList(PTypeInfo(AComp.ClassInfo), tkProperties, PListe); //tkAny //tkProperties
{$IFDEF NEXTGEN}
InputString := 'Caption';
BinarySize := (Length(InputString) + 1) * SizeOf(Char);
SetLength(StringAsBytes_Caption, BinarySize);
Move(InputString[1], StringAsBytes_Caption[0], BinarySize);
InputString := 'Text';
BinarySize := (Length(InputString) + 1) * SizeOf(Char);
SetLength(StringAsBytes_Text, BinarySize);
Move(InputString[1], StringAsBytes_Text[0], BinarySize);
{$ENDIF NEXTGEN}
for IdxProp := 0 to NbProps - 1 do
begin
{$IFDEF NEXTGEN}
//todo: we need to compare if (PListe^[IdxProp]^.Name) is 'caption' or 'text'
// but not working
if (PListe^[IdxProp]^.Name = StringAsBytes_Caption[0]) or (PListe^[IdxProp]^.Name = StringAsBytes_Text[0]) then
{$ELSE NEXTGEN}
if (PListe^[IdxProp]^.Name = 'Caption') or (PListe^[IdxProp]^.Name = 'Text') then
{$ENDIF NEXTGEN}
begin
...
end;
Question
How can I compare the (zero-base string) Name define as a Byte by the NEXTGEN define ?
