ESPL: Power Programmer, Part II
|
In the first part of this series, I covered some basic concepts about ESPL. This segment will examine ESPL for essential characteristics of a programming language.
Over the past few years, I have looked at, and used a small hand full of programmable charting packages. As a programmer of many years, having worked with over a dozen programming languages, the first thing I look for in these charting packages, are the essentials that are key to any programming language. I am happy to say that ESPL has the largest number of these essentials.
Before other experienced software developers hand me my head, let me point out that there are several different types of programming languages. Two classifications that come to mind, are what I call, "linear programming" and "rules based programming". In linear programming, the program is executed in the order that the code is written, unless modified by flow control instructions. Conventional linear languages are C++ and Java. Rules based languages can execute in what might appear to be random order, based on criteria being met, regarding the data being operated on. Examples of such languages are Amzi Prolog and XSLT. ESPL is a linear programming language.
Like Prego, "It’s in There"
Standard Programming Language Features
The first thing presented in many manuals and books for the typical linear programming language, is a description of the data types and variables the language supports. Most coding in ESPL can be done with the data types: integer, real, and Boolean. In addition, ESPL provides support for arrays of these basic types and character strings. There are also several "special" data types, that are unique to ESPL, such as TDateTime, TListBox, TStringList, TFont, TForm and TScreen. These special data types are used by specific built-in methods. As expected, your code does not access their contents directly, but rather obtains ones of these data types from a built-in method and then passes it back to other built-in methods.
The next thing typically discussed in programming language manuals is operators and expressions. In this area, ESPL has the full complement of numeric, Boolean, and string operators. The numeric operators include binary operators such as shift left (SHL), shift right (SHR), binary OR (OR), binary AND (AND), and exclusive-or (XOR). All of the typical Boolean operators are provided. For strings, the ‘+’ operator provides concatenation.
Flow control statements are next on my hit list. These include the typical goto, if-then-else, while, repeat-until, and for. ESPL has all of these statements. I include in the flow control group, what I call convenience statements. These would be break, continue, and return. Unfortunately ESPL does not have these statements. Flow control also includes the ability to call subroutines and functions. ESPL uses the name procedure for subroutines, and function for functions. A built-in variable called Result must be assigned the return value of a function, and return is made at the end of the function’s code. The lack of a return statement leads to the use of a label, placed at the end of the function, with goto statements in the function’s code. I guess I should have mentioned that ESPL has the label data type. Labels must be explicitly declared. Note that a declared label that is not used, both as being placed in the code (i.e. label: ), and being referenced (in a goto statement) will result in a compilation error.
The mention of procedures and functions requires a brief discussion of parameter passing. Conventionally there are three ways to pass parameters to a method. (The word method is used here as a generic term for procedures and functions.) They are referred to as: pass by value, pass by reference and pass by name. Pass by name is relatively rare, and does not appear in ESPL, so we’ll skip that one. In the case of pass by value the method obtains the value of the parameter, and can not effect any variable in the calling method. With pass by reference, the called method has access to the value of the parameter, and any change made to the parameter will change the associated variable in the calling method. The primary use for pass by reference, is to allow the called method to provide multiple outputs to the caller. This is in contrast to the single output provided by the returned value of a function. Happily, ESPL provides for both pass by value and pass by reference.
A programming language is of no use, without input and output (usually referred to as I/O). Here is where ESPL truly excels. Most of ESPL’s I/O deals with interfacing to Ensign charts, which I will discuss in a moment. In addition, ESPL has a full complement of other I/O methods. These include:
- the reading and writing of files;
- reading keyboard input;
- writing to the text output window of the ESPL editor;
- writing to a text box window (in the main Ensign window);
- writing to the Windows clipboard;
- reading and writing to DDE (Dynamic Data Exchange);
- playing sounds (.wav files);
- invoking Windows/Dos commands;
- reading http sites from the internet;
- reading and writing ftp sites from the internet; and
- sending e-mail.
You must admit, that such a list of built-in I/O capabilities is very impressive for any programming language.
An additional capability, which could loosely be classified as I/O, is the ability for ESPL to invoke any code made available through a DLL (dynamic link library). With this capability, an ESPL script can do just about anything.
The last conventional programming language feature, that I want to mention about ESPL, is the Include statement. This statement allows the programmer to segment the code being written, into logical pieces, each in its own file. Those files can then be "included" into a master file, which is the file opened in the ESPL editor. When the program being written is large, the capability to segment pieces of it, is essential. Though this statement has nothing to do with execution, it is (in my humble opinion) a critical feature in any programming language. I am happy to say, that, with regards to ESPL, it’s in there.
Charting Package Programming Language Features
A general programming language is all well and good, but we are interested in a charting package programming language. Here is where ESPL will blow you away. To state our desire in one sentence: anything I can see on the screen (charts, quote page, etc.) and anything I can do with the mouse and/or keyboard (apply studies, etc.) should be accessible to the ESPL program. I would say that ESPL meets this goal about 90%. Far greater than any other charting package programming language that I have seen thus far.
Starting with a basic chart, ESPL has full access to the values of the price bars. This includes the obvious High, Low, Open, Close, Volume, and Timestamp. ESPL can read and write these values for any bar on the chart. In addition, ESPL can add and delete bars from the chart, thus a program can construct it’s own chart full of bars.
Any study, bar coloring, or draw tool that can be added to a chart, from the menus, can be added and removed, from ESPL. In addition, any value, for any line drawn by the studies, can be read. All properties (with a few minor exceptions) including colors, line style, markers, and marker colors can be read and changed from ESPL.
The contents of quote page cells can be read from ESPL. I have had some problems writing quote page cells, though the documentation says it is possible.
ESPL has built-in methods for activating many of the pull down menu selections. If that isn’t enough, ESPL can "force" keystrokes into the input stream, as if they had been typed at the keyboard. An ESPL script can access the list of open windows, it can open new windows, it can close any window, and obtain information about any window – such as its contents, if it minimized, etc.
I hope you are beginning to see that the power of ESPL is awesome; and the possibilities for what it can do, are endless.
For reasons of both size and subject matter, this is a good place to stop. Next time, we will look at the issue of data storage for your programs, and then several new features that I would like to see in future releases of ESPL.
Read more» Part I Read more» Part III
Article by Paul Levin
Last modified 10/20/08 1:59 PM
|