ProceduresCalling Procedures and FunctionsProcedures and functions are modular pieces of code that perform some specific task. They are known as subroutines in other languages. The ESPL library contains more than 300 powerful procedures and functions that serve as building blocks for use in your scripts. While you don't need to understand the logic of the code within the ESPL procedures and functions, you need to understand what they do. When procedures and functions are declared within objects like a TStringList, they are called methods. Of course, you can create your own procedures and functions in your script. Use them to divide the logic of your application into manageable chunks. If a block of code has more than 25 lines, it is a candidate for being divided into more manageable chunks. To Use an Existing Procedure For example, the TStringList object has a Sort method. Because this functionality is built into the object, you need to know only what the method does and how to use it. This is how you call the Sort method of a TStringList object named sList: sList.Sort; Note that the name of the object, sList, is part of the method call. By including the name of the object, you are specifying which string list you want to sort. Separate the name of the object from the method call with a period. If you omit the name of the control, component, or object in a method call, ESPL usually displays this syntax error: Unknown Identifier Passing Parameters procedure LoadFromFile(sFileName: string); sFileName, the sole parameter of the method, is of type String. When you call the LoadFromFile method, you specify which file you want loaded by specifying a string as the sFileName parameter. This code would read the MYFILE.TXT file into a string list named sList: sList.LoadFromFile( 'MyFile.txt' ); |