Entering data into an application
An application must also receive data from the user; the simplest tool is the Edit (Standard tab). It has no Caption: the typed text is held in the Text property, so it is usually used together with a Label. If ReadOnly = True the user cannot change the text but the application can write to Text: because an Edit has a frame it shows a result neatly. MaxLength limits the number of characters that can be typed (4 for a year), and PasswordChar shows a character instead of the letters (PasswordChar := '*'). When texts are compared, capital and small letters differ: 'abc' = 'ABC' is false. Writing a password inside the program code is not safe: anyone who sees the code learns it; do not type your own real password into learning applications.
| Property | Meaning |
|---|---|
| Text | the typed text |
| ReadOnly | True – the user cannot change it |
| MaxLength | limit of characters |
| PasswordChar | shows a sign instead of the letters |
When a pupil types an invented secret word for a game into an input field, the letters appear as stars, so a classmate behind cannot read it. The program itself still knows the typed text. This is how a private word is hidden from onlookers.
Web and app developers, designers of banking apps and information security specialists protect input fields.
Draw an input box on paper and show how the letters of an invented word turn into stars; never write a real password of yours.
1procedure TForm1.Button1Click(Sender: TObject); 2begin 3 if Edit2.Text = Edit1.Text then 4 Edit3.Text := 'Topdingiz!' 5 else 6 Edit3.Text := 'Yana bir urinish'; 7end;
“Secret word”: a pair builds the game application; another pair tests it with correct, wrong and capital-letter guesses and writes a table of results.