Currently in a legacy code I have a set which I want to convert to array of string so i can pass this as a parameter for existing method.
//Existing code to be used and converted
const
North = 'F';
Pay = 'P';
Lynk = 'L';
TCharSet = set of AnsiChar;
MySet: TCharSet = [North, Pay, Lynk];
So my question is how do i convert above set to a array of character? Is this doable?
After doing some research found below code and that seems to have enum used to create a set and using TypeInfo to convert the enum to string.
//**Working code**
TMyEnum = (meFirst, meSecond, meThird);
TMySet = set of TMyEnum;
function MySetToString(MySet: TMySet): string;
var
i: TMyEnum;
begin
Result := '';
// one way to iterate
for i := Low(i) to High(i) do
if i in MySet then
Result := Result + GetEnumName(TypeInfo(TMyEnum), Ord(i)) + ' ';
end;
// call to above method
set1 := [meFirst, meSecond, meThird];
ShowMessage(MySetToString(set1));
Any help really appreciated.