I didn't expect this lazarus / 61-Beginners ---------------------------------------------------------------------- Ten_Mile_Hike · 2025-04-22 20:00 I was bored today and just started playing in Lazarus trying to write stupid (obfuscated) code for shits and giggles when all of a sudden THIS (indexing a hard coded string) WORKED. Should I have been surprised that I am allowed to index a hard coded string? 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.Button4Click(Sender: TObject);var c:char; x:integer;begin for x:=1 to Length('Mississippi') do   if 'Mississippi'[x]='s' then Button4.caption:=Button4.caption+inttostr(X)+','end; ---------------------------------------------------------------------- ASerge · 2025-04-22 21:15 Quote from: Ten_Mile_Hike on April 22, 2025, 10:00:58 pmShould I have been surprised that I am allowed to index a hard coded string? This is a long-standing opportunity. Such strings are usually defined as constants, which is why you didn't notice earlier. ---------------------------------------------------------------------- 440bx · 2025-04-22 21:25 Quote from: Ten_Mile_Hike on April 22, 2025, 10:00:58 pmShould I have been surprised that I am allowed to index a hard coded string? Hard coded or otherwise, a string is an array of characters, indexing an array is completely normal. It's just not obvious that the string is an array when it is hard coded.  For that reason, it's reasonable to be surprised but, it's completely logical. ---------------------------------------------------------------------- H₂SO₄ · 2025-04-23 05:25 String indexing is a powerful operation  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 program Calculator; begin  WriteLn(Integer('eight plus eight'[0])); // Output: 16end. ---------------------------------------------------------------------- Fibonacci · 2025-04-23 05:49 Quote from: Khrys on April 23, 2025, 07:25:28 amString indexing is a powerful operation  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 program Calculator; begin  WriteLn(Integer('eight plus eight'[0])); // Output: 16end. Wow Get 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 program Calculator;begin  WriteLn(Integer('2+2='[0])); // Output: 4 end. ---------------------------------------------------------------------- Bart · 2025-04-23 10:32 Quote from: Fibonacci on April 23, 2025, 07:49:48 amWow Get 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 program Calculator;begin  WriteLn(Integer('2+2='[0])); // Output: 4 end. Try that one (or the previous) with {$H+}  (Or, to have fun with {$ZeroBasedStrings on}) Bart ---------------------------------------------------------------------- simone · 2025-04-23 11:40 In fact, these fun examples are only valid for short strings, where the first character (position #0) of the underlying array contains the length of the string, as shown in: https://www.freepascal.org/docs- html/current/prog/progsu160.html#x204-2140008.2.7