/ / Delphi pos - lines in Pascal

Delphi pos - lines in Pascal

In Delphi, as in any other programming language, you can work with strings. There are many functions for working with them. In this article, we'll look at the most popular string functions in Delphi.

Finding a character in a string

In Delphi, pos is used to find the positioncharacter or group of characters in a string. This function is used as follows: pos (the string we are looking for, the string we are looking for). For example, in the word "machine" we need to find the letter "O". Write pos ('o', 'Automatic'). During the execution of the program, the number 4 appears in place of this function. Since the letter O in the word "automatic machine" is on the 4th place. Or we want to find a whole line of symbols. In the word "Refrigerator" find a "dile". Pos ('dil', 'refrigerator'). It will return to us 5, since the passage of the dile begins with a 5 character. If there is no character or a line of characters in the source line at all, then the function returns 0. It is also important to remember that the letters a and A are different, so if you need to find all the letters a in the word, then look for both a and A.

delphi pos

Other functions in Delphi

In addition to the pos function, Delphi includesa lot of functions for working with strings. For example, the function copy. It is used to copy a single section from one line to another. Also, the concat function serves as a two-line concatenator. As in mathematics two numbers are added, lines are also joined together.

String procedures in Delphi

delphi string functions

Functions always return something, but the procedures- no. Examples of string procedures are the insertion and deletion procedures. The Delete procedure can remove fragments from a string. And Insert - to insert. Skillfully combining these procedures, and also using functions, you can achieve great results, for example, all error correctors that emphasize incorrectly written words, and also correct them, translators, dictionaries and so on, work. They all use string functions, but probably not in Pascal. Knowing string functions and procedures, you can, for example, write the program shown in the figure above.