title: Pascal - User input name of array
body: <p>I’m writing a Lazarus application that selects and manipulates data contained in a particular two-dimensional array specified by the user, from a number of preset two-dimensional arrays. My problem is that I don’t know how to convert the user input string into an array name.</p>
  
  <p>An example application contains three two-dimensional arrays:
  aaa, bbb and ccc. I want the user to enter, say, bbb and the index (i) in two edit boxes, then be able to read the data contained in bbb[i,2] and bbb[i,3].</p>
  
  <pre><code>...
  type
    table = array [1..10, 1..3] of real;
  
    var
    aaa, bbb, ccc : table;
    Duration : real;
    i : integer;
    Sector : string[3];
  
  ...
  procedure SetUpTables;
    {code that puts data into aaa, bbb, and ccc}
  end;
  ...
  
  {Code that asks user to input aaa, bbb or ccc into Edit1.Text}
  
  ...
  procedure TForm1.Edit1Exit(Sender: Tobject)
    Sector := Edit1.Text;
    Duration := Sector[i,3];
  end;
  ...
  </code></pre>
  
  <p>In the last procedure, I want to use the contents of Sector (aaa, bbb or ccc) to access bbb[i,3]. As you would imagine, I get an “illegal qualifier” error in the line “Duration := Sector[1,3];” at the second index for Sector.</p>
  
  <p>I’m afraid I can’t see how to use the contents of Sector as the array name. I would be grateful for any thoughts on how this can be done.</p>