[SOLVED] How to best enable users to define their preferred delimiter? lazarus / 21-General ---------------------------------------------------------------------- Gizmo · 2021-05-03 12:42 I know theres lots of posts about delimitedtext, but I'm trying to work out the best way to allow my users to specify their preferred character via the interface, and I am not using a StringList, as referenced here (https://www.freepascal.org/docs- html/rtl/classes/tstrings.delimitedtext.html). So for example, currently, I use 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 'my string' + ',' + 'more of my string'; to place delimiters. So I have set a labelled edit field in the GUI now. If the user wants to use ',' or ':' or any other printable character, I can use leDelimiterField.Text instead of ','. 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 'my string' + leDelimiterField.Text + 'more of my string'; I also notice it has .Text.IsDelimiter() but I am not quite sure how to use that in this context. I notice there is also TStringHelper.Split (https://www.freepascal.org/docs- html/rtl/sysutils/tstringhelper.split.html) but again, I think it needs to be told what the delimiter character is, and I want my users to be able to choose that themselves. Lets say the user wants to use tab (#9). So they enter the tab value of '#9' in the label edit field. If I use the text property still as above, then '#9' understandably gets inserted into the output string. And I'd prefer not to run a conversion routine for what might be millions of lines on that GUI element every time. I want to rapidly "set" the chosen delimiter when the user clicks a button (and I have that set to a comma currently but the user could choose ':' or tab) such that for every line thereafter that character is chosen, regardless of whether it is an ASCII selected value, or a non printable one like tab. In other words, what I need to do is 1) User chooses a character, such as ':' or tab (#9) in the edit field 2) When user clicks button, program "gets" the chosen delimiter and sets it as ChosenDelimiter 3) For every string thereafter requring delimiter,  ChosenDelimiter is used, whether it be printable ASCII, or not (i.e. tab) How best might folks approach this? Is there a more suitable method than what I am doing here? ---------------------------------------------------------------------- Zvoni · 2021-05-03 13:19 How about offering the User a ComboBox in ListStyle with the "usual" delimiters (incl. non printable)? That way you could catch the chosen delimiter and process it (if it's a non-printable like TAB) You could still offer an additional field "custom delimiter". In that case all gloves would be off, and the user is completely responsible for the results Of course you would have to sanity check the ComboBox against the Custom Delimiter (e.g. If something is entered in Custom Del ignore ComboBox and vice versa) ---------------------------------------------------------------------- Gizmo · 2021-05-03 13:52 Yes, good shout! That is much better. So I have solved this using a combo box, with ',', ':' and 'Tab' as 3 options. Then I use it like this : 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 ChosenDelimiter := C2FDelimiterComboBox.Text;  // if its anything except Tab, just use it  if ChosenDelimiter = 'Tab' then                        // Or if it is tab, use #9  begin    ChosenDelimiter := #9;  end;             And I've set ChosenDelimter as a public var for the form. Thanks man, and anyone else who reads.