For-loop using ordinal variables
The control variable may not only be an integer, but may be any ordinal variable (distinguishes between the preceding and the following element only in the sense of "bigger - smaller"), for example a character (char) variable. Try by using the char variable list all the letters of the alphabet. We will use the new Memo component that serves to write text, but no longer as 64 kb. Select the component from the Standard tab and put it in the Form. You will see a square with the Memo 1 inscription into which we will list the entire alphabet by pressing the button.
We will call the control variable AZ (to match the content) and it will be of the char data type. The syntax of the For-loop construction will be similar as with the integer variable, but the final and the initial limit will be the first and the last letters of the alphabet (since it is a character, it must be bounded by apostrophes ALT + 39). We will write the text to Memo1, so we also need to use its name at the command line (Figure 60).
The Memo1 component has the Lines attribute (is an array type) that inputs the text in a component, divided into rows. Although Lines itself is an attribute of a Memo component, it contains additional features, one of which is Add, which adds a new line to the Memo component. We write the text of this line after the word Add into brackets, in our case it is a variable (AZ) with characters (char). After running the program, we will see following (Figure 61):
We see that the first letter is p. To show us all the letters from a, it is necessary to enlarge the Memo1 component and the Form according to our needs.