sLayout List Variable

The global variable   sLayout  is of type  TListBox; and will reference the contents of the Layout form's list box in Ensign Windows.

TListBox  is a type with the following functions and properties, briefly mentioned here, but more fully documented in the ESPL Help documentation:

    Clear           empties the list
    Items           a type TStrings object holding the contents of the list
    ItemsIndex  select an item in the list, or report which item is selected.
    Sorted         reports if list is sorted, can be set to True to sort the list.
    Click           same as single mouse click on Item at ItemsIndex
    DblClick      same as doulble mouse click on Item at ItemsIndex to execute a layout

Example code to illustrate:

var
  b: TStrings;
  i: integer;
begin
  Output(eClear);
  b:= sLayout.Items;
  for i:=0 to pred(b.count) do writeln(b.strings[i]);

  b.Add('JunkJunk');
  writeln(b.count);

  sLayout.ItemIndex := 2;   {select 3rd item on list}
  sLayout.DblClick;         {execute that layout script}
end;

In the first few lines, I illustrate writing the contents of the Layout list box to the Output window using sLayout.
In the middle couple of lines, I illustrate how you can add a new entry to the list.   If you then click on the Layout button, you will see that JunkJunk has been added to the bottom of the Layout list on the left side of the Layout form.

In the last section, I illustrate how an item in the list can be selected, and its layout executed with Double Click.

One item is confusing, so I am making this effort to document it for you.   sLayout is type TListBox so that it matches the Layout list box we use in Ensign Windows to hold the list in the layout form.   Since TListBox objects have an Items object, we can work with    sLayout.Items.    Items is an object of type TStrings, so we can work with   Items.Strings[]  and  Items.Count. 

Now for the quirk, to reference an item in the list, normally one should be able to use   sLayout.Items.Strings[]    However, this will give an error message because the ESPL compiler cannot compile a double dot reference.   I call it a double dot reference because you had to use two dots or periods to write    sLayout.Items.Strings[]    The work around is to break the full reference into parts, as illustrated in the example script.    sLayout.Items  is of type TStrings, so I declared a variable of type TStrings and assigned it to point to  sLayout.Items.    Then, the compiler can reference the properties of the Items object.

Example:

  b:=sLayout.Items; writeln(b.count); {this will compile}

  writeln(sLayout.Items.count); {equivalent to the above, but it will not compile because of the double dot reference}

I will not expose the ability to create variables of type TListBox, because the functionality hoped for is already present in TStringList type variables