ESPL: Event Redirection

Q:  How can ESPL be notified when the Ensign program is closing so that information can be saved before the program closes?

A:  Redirect the OnCloseQuery event for the main Ensign form to an ESPL procedure which performs the clean-up tasks such as saving information.  The main Ensign form is referenced with the component named   frmMain.   This example will print a message in the Output window when Ensign closes.

uses
  Forms;
procedure ShutDown;
begin
  writeln('Exiting');
end;
begin
  if ESPL = 3 then
    frmMain.OnCloseQuery := 'ShutDown';
end;
Cick ESPL button 3 to establish the redirection of the OnCloseQuery event.  Then when Ensign exits, the OnCloseQuery event fires and executes the ESPL ShutDown procedure which displays ‘Exiting’ in the Output window.  Ensign continues its exit process and closes down.
 

ESPL: Custom Symbol

Q:  I did this in E10 ESPL.  I have a Quote Page open with IBM, MSFT, and CSCO quotes which show correctly.  But my custom symbol MANO1 shows up blank after I click the Run button.  What is the problem?

procedure Mano11;
var price, MANO1: real;               
begin
{ if (TimeStr >= '07:20') and (TimeStr <= '14:00') then}
begin
  Feed := eSignal;
  price:= Get('IBM') + Get('MSFT') + Get('CSCO');
  Update('MANO1',price,1,2);
 end;
end;

A:  Steps I took: 

  1. Click Setup | Custom Symbols
  2. Enter the code in the editor.   NOTE:  I do not have a Procedure as in your example. The presence of Procedure is the problem.
  3. Click the Save button, then the Compile button which has the gear image.  Then click the Run button.
  4. Open the quote page for eSignal and it shows the custom symbol updating.

ESPL: Custom Quote List

Q:  I’d like to create and edit daily a custom symbol with about 50 or more stocks in the index.  Instead of editing ESPL code, would it be possible to reference an array in the E10 spreadsheet, which can be updated more easily?  What would the basic code look like?

A:  Use the predefined   sList   variable which is a TStringList variable.  TStringList has useful methods for working with a list of strings.   The data source file would be an ASCII file that you edit using Notepad, or it could be a custom quote page file, such as   MyList.dat.    When using a custom quote file the records have a market group character in the 1st character position, followed by the symbol.   This example copies the symbol from the 2nd character position.

ESPL: Emulate Workspace Tabs

Q:  I have used Ensign for years…and I am very happy with it. I look at about 14 markets. I set up each market with 2-3 charts in a workspace. I click onto a workspace and this works well for me.  I was trying to use the Layer function in Ensign 10 for the same effect, but the numbered tabs do not label that particular market, there are only 9 tabs, and my understanding is that it requires more CPU.   Is there any chance of having layout tabs in Ensign 10 that serves the same function as the workspace tabs in Ensign Windows?

A:  There are no plans to add a tab control which shows layout names to replicate the EW feature.  However, the E10 ESPL language is very powerful and could be used to create the tabs feature.  This is the essence of the ESPL implementation of a tab control.

Starting with a New Project, put a tab control on the form, and resized the form and the tab control.  At design time, edited the TABS property to add names for the tabs, such as is shown on the form, using words of ‘First’, ‘Second’, ‘Third’ etc. 

In the Change event for the tab control, write code that opens different layouts using the Layout function. Here is the code example. 

procedure TabControl1Change(Sender: TObject);
begin
  Case tabControl1.tabIndex of
    0: Layout('ALayoutName');
    1: Layout('2ndLayout');
    2: Layout('3rdLayout');
  end;
end;

Edit the example so you have tab names that are meaningful and open the layouts using layout names you use.   Each tab would have a case number entry.

ESPL: Format statement

Q:  I cannot get the format command to work with a variable enclosed in brackets.  This example gives an error.

vTotalVolume:=13894948
strText:=’The Total Volume was ‘ + Format(‘%12.0n’,[vTotalVolume]);

A:  The parameter needs to be of type ‘real’. The example you gave evaluates to type ‘integer’.   This example works where .0 is appended to the value so it is treated as a ‘real’.

vTotalVolume:=13894948.0
strText:=’The Total Volume was ‘ + Format(‘%12.0n’,[vTotalVolume]);

ESPL: Reset Scale Default

Q: Are you planning to add btnReset to ESPL in E10, or is there another way of automatically rescaling all the open charts in E10?

A: You would write a loop to give each open chart focus, and then use these 3 statements to accomplish a scale reset.   Task #198 resets the chart scale to its default.   Since the chart pop-up menus are not registered in ESPL, the trick is to set the tag for the mnuSaveLayout which is exposed in ESPL.   After doing the click event, reset the tag for this menu back to its original 900 value.   See the documentation in the DYO manual for the IF # then Action #2 statement for a full listing of action values that could be performed by this method.

mnuSaveLayout.tag := 198;
mnuSaveLayout.click;
mnuSaveLayout.tag := 900;