AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Contents · Computing

The Edit object

Lessons 47–48 · 2 lessons · N. I. Taylaqov (general editor), A. B. Akhmedov, M. D. Pardayeva, A. A. Abdug‘aniyev, U. M. Mirsanov. Informatics and Information Technologies, Grade 10, 1st edition. “Extremum-Press”, Tashkent, 2017
48

Practical lesson

Textbook: pp. 105–106
GoalUses Edit and Label together to build small applications that check and process text; uses the Length and UpperCase functions.
New words
Length: a function that returns the number of characters in a string · LengthUpperCase: a function that converts a string to capital letters · UpperCaseOnChange: the event of the text in an Edit changing · OnChangeempty string: a string with no characters, written as '' · bo‘sh satr
Explanation

In the practical lesson three applications for working with Edit are created. The first is the “Character counter”: a word is typed in Edit1 and when the button is pressed Label1.Caption := 'Belgilar: ' + IntToStr(Length(Edit1.Text)); appears. Length also counts spaces and punctuation. The second is “Capital letters”: Edit2.Text := UpperCase(Edit1.Text); converts the text to capitals (UpperCase comes from the SysUtils unit, which is normally connected already in a new application). The third is clearing: in the OnChange event of Edit1 (double-click in the Object Inspector on the Events tab) write Label1.Caption := ''; so that the out-of-date character count disappears as soon as the text changes. In each application write the expected results in your notebook before testing.

💡 Where will I use this?
In real life

In an entry box a code might be typed as “ab12” or as “AB12”. The program automatically changes the text to capital letters and treats both as the same. The user is not turned away because of a tiny difference.

Who uses it

Programmers, data-entry staff and developers of search systems bring text to one form before comparing it.

Try it today

Think up a slogan for a school poster that is no longer than 30 characters and count its characters, spaces included.

Worked examples
Length('informatika') = 11 and Length('Ali Vali') = 8 (the space is counted too). If Edit1 holds kompyuter, the Label shows Belgilar: 9. The result of UpperCase('salom 5a') is SALOM 5A.
Pascal
1procedure TForm1.Edit1Change(Sender: TObject);
2begin
3  Label1.Caption := '';
4end;
Clearing Label1 in OnChange – code above. After “Belgilar: 9” is shown, if the user adds one letter to the word in Edit1 the old number disappears, because it would now be wrong. Pressing the button again shows the new number.
Class activity

“The character counter”: each student writes 5 words in a notebook and calculates Length in advance; checks with the pair’s application and writes the reason for any difference.

Practice
1
What is Length('maktab')?
2
What is Length('10 A sinf') (spaces are counted)?
3
What is the result of UpperCase('ali')?
4
Why is clearing the old result in OnChange convenient for the user?
Story of the Week · The Khwarizmi WayPay that doubles every dayClose the week: all of this week’s subjects in one storyRead →