Set of Char versus String - Error Illegal qualifier lazarus / 61-Beginners ---------------------------------------------------------------------- rc.1990 · 2016-09-28 17:07 I am using Lazarus 1.6.0 ad FPC 3.0.0. How can I pass the value of a Set of Char to a String? ------------- Compile Project, Target: C:\Users\test\AppData\Local\Temp\project1.exe: Exit code 1, Errors: 2 unit1.pas(39,29) Error: Illegal qualifier unit1.pas(41,44) Error: Illegal qualifier ------------- Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);const  TestArray = ['0'..'9', 'a'..'z', 'A'..'Z']; var  OneCharacter: string;begin  OneCharacter := TestArray[20];  ShowMessage('OneCharacter: ' + OneCharacter);  ShowMessage('OneCharacter: ' + TestArray[25]);end; ---------------------------------------------------------------------- Leledumbo · 2016-09-28 17:22 Set is not an array, it's not indexable. Set is not a string, though it can be stringified to display its current content, it's not type compatible with string. Set is a set, you can include/exclude elements from it, check whether certain element is part of it and operate it with another set, but none of the operation deals with string. So you better explain more in details what you expect from the code you write. ---------------------------------------------------------------------- Xor-el · 2016-09-28 17:25 iterate through the set using a "for in " loop and append each value to a string. ---------------------------------------------------------------------- rc.1990 · 2016-09-28 17:30 Thanks Xor-el and Leledumbo. How can I stringify a set of char to display all its content into a for loop so I can create an array of string containing all digits 0..9, small letters a..z and capital letters A..Z? ---------------------------------------------------------------------- Xor-el · 2016-09-28 18:05 // I modified your code a little to convert the set to string. // posted this from my phone so it might not be well formatted. procedure TForm1 . Button1Click ( Sender: TObject );  const  TestArray = ['0' .. '9' , 'a' .. 'z' , 'A' .. 'Z' ] ;  var  OneCharacter, res: string;   C: char;  begin res := '';  for C in TestArray do begin res := res + C; end; OneCharacter := res[20];  ShowMessage ( 'OneCharacter: ' + OneCharacter);  ShowMessage ( 'OneCharacter: ' + res[25]) ;  end ; ---------------------------------------------------------------------- rc.1990 · 2016-09-28 18:19 Thanks Xor-el. Your solution solved my problem. ---------------------------------------------------------------------- Handoko · 2016-09-28 18:31 Xor-el is brilliant.  What I don't understand why should we want to force set to be compatible with char. As Leledumbo said set is not array, not string and not type compatible with string. Although the name "set of char", but it is not char too. I would consider set is a kind of list of on/off (or bool). One of the benefit of OP's code I can think of is make you type less: Code: [Select]TestArray = ['0'..'9', 'a'..'z', 'A'..'Z']; // vs CharsList = '0123456789'+             'abcdefghijklmnoqrstuvwxyz'+             'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; But if the reason to make you type less, I would suggest my code which is less typing compare to Xor-el's code, more exactly, easier to read and understand: Code: [Select]procedure TForm1.Button1Click(Sender: TObject); const   CharsList = '0123456789'+               'abcdefghijklmnoqrstuvwxyz'+               'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; begin   ShowMessage('Char 25th = ' + CharsList[25]); end; Also, I want to add. The name "TestArray" is not correct. Actually that is a set not an array. ---------------------------------------------------------------------- Handoko · 2016-09-28 18:51 Use the right tool for the job, is what I want to say. I ever saw a youtube video, someone using Iphone to hit a nail. Of course, you can if you want. But it will be much better to use a hammer, right? Thaddy ever said the benefit of using set recently (or some weeks ago). That is for faster processing, because set is optimized for speed and code size. It is explained on the documentation too: http://www.freepascal.org/docs-html/3.0.0/ref/refsu17.html But forcing set to char, you will lose all the benefits.