Hi all
Today they asked me not to display the document prefix when printing an implementation document, I solved the problem as follows.

StrReplace(Number, Lev(Number, 3), "" );

When I looked into the syntax assistant I liked it so much that I wanted to write about working with strings in 1C:Enterprise.

A string in 1C refers to a primitive data type.

If you look at the 1C help, we will see the following description of the String type:
Values of this type contain a Unicode string of arbitrary length.
If you use your own words about strings, it will work. A string is a constant consisting of various characters, always surrounded by quotes.

Setting a line
Salutation = "Hello Passenger";

Multiline lines in typical configurations are most often created using the vertical separator “|”:
String = "Multiline
|string
|write
|text";

A quote inside a string is specified double quotes.
String = ""Text in quotes"";

There are many operations on strings (searching inside the string, determining the first ones, etc.), it is better to look at the Syntax Assistant.
Syntax Helper - general description built-in language -> built-in functions -> functions for working with strings.

Functions for working with strings

Here, in short form Here are some functions for working with strings:

VReg(<Строка>) — The function converts all characters in the string to upper case.

SymbolCode(<Строка>, <НомерСимвола>) – The function receives the code of the character located in the passed string at position c specified number.

A lion(<Строка>, <ЧислоСимволов>) – The function selects the first left characters of the string.

Find(<Строка>, <ПодстрокаПоиска>) — The function finds an occurrence of the search string as a substring in the source string.

NReg(<Строка>) — The function converts all characters in the string to lowercase.

Right(<Строка>, <ЧислоСимволов>) This function differs from the Left functions in that it selects the last characters from the right of the string.

Empty line(<Строка>) — The function checks the string for the presence of significant characters.

Symbol(<КодСимвола>) — The function converts the character code into a string containing the character.

AbbrL(<Строка>) — The function cuts off insignificant characters to the left of the first significant character in the string.

AbbrLP(<Строка>) — The function trims non-significant characters to the left of the first significant character in the line, and spaces to the right of the last significant character in the line.

Abbreviation(<Строка>) — The function cuts off insignificant characters to the right of the last significant character in the string.

Wednesday(<Строка>, <НачальныйНомер>, <ЧислоСимволов>) — The function selects a string of characters, starting with the character<НачальныйНомер>, total number<ЧислоСимволов>.

StrLength(<Строка>) — The function gets the number of characters in the line.

StrReplace(<Строка>, <ПодстрокаПоиска>, <ПодстрокаЗамены>) — The function finds all occurrences of the search substring in the source string and replaces it with the replacement substring.

StrGetString(<Строка>, <НомерСтроки>) - The function gets a multiline string by number.

StrNumberOccurrences(<Строка>, <ПодстрокаПоиска>) — The function calculates the number of occurrences of the search substring in the source string.

StrNumberRow(<Строка>) — The function counts the number of lines in a multiline string. In a multiline string, lines are separated by newlines.

TReg(<Строка>) — The function converts the string to title case. This means that the first character of each word is converted to title case, or to upper case if title case is not specified for the character. The remaining characters are converted to lowercase.

Type Conversions
For explicit conversion of data types, there are functions of the same name with the data type to which the conversion is taking place: String(<Значение>)

StringFromNumbers = String(Number);

All these functions are described in detail in the Syntax Assistant; I described how the Syntax Assistant can help a novice programmer in the article.

Examples for working with strings

Converting a number to a string and back.

To obtain a string representation of the year, use the Format function.

Year = Format(CurrentDate(), "DF=yyyy") // Year = "2012"

To convert a number to a string without inserting a group separator character (non-breaking space), you must use the Format function with the NG=0 parameter:

Number = 2012 Line = Format(Number, "NH=0" ); //String = "2012"

String No spaces.

Rows in 1C 8.3 in the built-in language 1C represent values ​​of a primitive type Line. Values ​​of this type contain a Unicode string of arbitrary length. String type variables are a set of characters enclosed in quotes.

Example 1. Let's create a string variable with text.

StringVariable = "Hello world!";

Functions for working with strings in 1s 8.3

IN this section The main functions will be given that allow you to change lines in 1c, or analyze the information contained in them.

StrLength

StrLength(<Строка>) . Returns the number of characters contained in the string passed as a parameter.

Example 2. Let's count the number of characters in the line “Hello world!”

String = "Hello world!"; NumberofCharacters = StrLength(String); Report(NumberCharacters);

The result of executing this code will be the display of the number of characters in the line: 11.

AbbrL

AbbrL(<Строка>) . Trims non-significant characters to the left of the first significant character in the string.
Minor characters:

  • space;
  • non-breaking space;
  • tabulation;
  • carriage return;
  • line translation;
  • translation of the form (page).

Example 3. Remove all spaces from the left side of the line "world!" and add the line “Hello” to it.

String = Abbreviation("world!"); String = "Hello"+String; Report(String);

The result of executing this code will be the display of the line “Hello world!” on the screen.

Abbreviated

Abbreviation(<Строка>) . Trims non-significant characters to the right of the first significant character in the string.

Example 4. Form from the lines “Hello” and “peace!” the phrase “Hello world!”

Line = Abbreviation("Hello ")+" "+ Abbreviation(" world!"); Report(String);

AbbrLP

AbbrLP(<Строка>) . Trims non-significant characters to the right of the first significant character in the string, and also trims non-significant characters to the left of the first significant character in the string. This function is used more often than the previous two, as it is more universal.

Example 5. Remove insignificant characters on the left and right in the name of the counterparty.

Counterparty = Directories. Counterparties.Find By Details("TIN", "0777121211"); AccountObject = Account.GetObject(); CounterpartyObject.Name = AbbrLP(CounterpartyObject.Name); AccountObject.Write();

a lion

A lion(<Строка>, <ЧислоСимволов>) . Gets the first characters of the string, the number of characters is specified in the parameter Number of Characters.

Example 6. Let in the structure Employee contain the first, last and patronymic names of the employee. Get a string with last name and initials.

NameInitial = Lev(Employee.Name, 1); Patronymic Initial = Leo(Employee. Patronymic, 1); FullName = Employee.LastName + " " + FirstName Initial + "." + Middle Initial + ".";

Right

Right(<Строка>, <ЧислоСимволов>) . Gets the last characters of a string, the number of characters specified in the parameter Number of Characters. If the specified number of characters exceeds the length of the string, then the entire string is returned.

Example 7. Let a date in the format “yyyymmdd” be written at the end of a string variable, get a string with the date and convert it to type date.

String = "Current date: 20170910"; StringDate = Rights(String, 8); Date = Date(StringDate);

Wednesday

Wednesday(<Строка>, <НачальныйНомер>, <ЧислоСимволов>) . Gets a substring from the string passed as a parameter Line, starting from the character whose number is specified in the parameter InitialNumber and the length passed into the parameter Number of Characters. The numbering of characters in a line starts from 1. If in the parameter InitialNumber a value less than or equal to zero is specified, then the parameter takes the value 1. If the parameter Number of Characters is not specified, then characters up to the end of the line are selected.

Example 8. Let the string variable starting from the ninth position contain the region code, you should get it and write it in a separate line.

String = "Region: 99 Moscow"; Region = Avg(String, 9, 2);

PageFind

StrFind(<Строка>, <ПодстрокаПоиска>, <НаправлениеПоиска>, <НачальнаяПозиция>, <НомерВхождения>) . Searches for a specified substring in a string, returning the position number of the first character of the found substring. Let's look at the parameters of this function:

  • Line. Source string;
  • Search Substring. Search substring;
  • Search Direction. Specifies the direction to search for a substring in a string. Can take values:
    • Search Direction.From Start;
    • Search.End Direction;
  • InitialPosition. Specifies the position in the string at which the search begins;
  • NumberOccurrences. Specifies the occurrence number of the searched substring in the source string.

Example 9. In the line “Hello world!” Determine the position of the last occurrence of the "and" character.

PositionNumber = StrFind("Hello world!", "and", SearchDirection.End); Report(PositionNumber);

The result of executing this code will be to display the number of the last occurrence of the “and” symbol: 9.

VReg

VReg(<Строка>) . Converts all characters in the specified string in 1s8 to uppercase.

Example 10: Convert the string "hello world!" to upper case.

StringVreg = VReg("hello world!"); Report(StringVreg);

The result of executing this code will be the display of the line “HELLO WORLD!”

NReg

NReg(<Строка>) . Converts all characters of the specified string in 1s 8 to lower case.

Example 11: Convert the string "HELLO WORLD!" to lower case.

StringNreg = NReg("HELLO WORLD!"); Report(StringVreg);

The result of executing this code will be the display of the line “hello world!”

Treg

TReg(<Строка>) . Converts a string as follows: the first character of each word is converted to uppercase, the remaining characters of the word are converted to lowercase.

Example 12. Do capitalized first letters of words in the line “hello world!”

StringTreg = TReg("hello world!"); Report(StringTreg);

The result of executing this code will be the display of the line “Hello World!”

Symbol

Symbol(<КодСимвола>) . Gets a character by its Unicod code.

Example 13. Add left and right to the line “Hello World!” symbol ★

StringWithStars = Symbol("9733")+"Hello World!"+Symbol("9733"); Report(StringWithStars);

The result of executing this code will be the display of the line “★Hello World!★”

Symbol Code

SymbolCode(<Строка>, <НомерСимвола>) . Gets the Unicode character code from the string specified in the first parameter, located at the position specified in the second parameter.

Example 14. Find out the code of the last character in the line “Hello World!”

String = "Hello World!"; CharacterCode = CharacterCode(String, StrLength(String)); Notify(CharacterCode);

The result of executing this code will be the display of the symbol code “!” - 33.

Empty line

Empty line(<Строка>) . Checks whether the string consists of only insignificant characters, that is, whether it is empty.

Example 15. Check whether a string consisting of three spaces is empty.

Empty = EmptyString(" "); Report(Empty);

The result of executing this code will be the display of the word “Yes” (string expression boolean value True).

PageReplace

StrReplace(<Строка>, <ПодстрокаПоиска>, <ПодстрокаЗамены>) . Finds all occurrences of the search substring in the source string and replaces it with the replacement substring.

Example 16. In the line “Hello World!” replace the word “Peace” with the word “Friends”.

String = StrReplace("Hello World!", "World", "Friends"); Report(String);

The result of executing this code will be the display of the line “Hello Friends!”

StrNumberLines

StrNumberRow(<Строка>) . Allows you to count the number of lines in a multiline string. To go to new line in 1s 8 the symbol is used PS(newline character).

Example 17. Determine the number of lines in the text:
"First line
Second line
Third line"

Number = StrNumberString("First line"+Characters.PS +"Second line"+Symbols.PS +"Third line"); Report(Number);

The result of executing this code will be the display of the number of lines in the text: 3

StrGetString

StrGetString(<Строка>, <НомерСтроки>) . Gets a line in a multiline string by its number. Line numbering starts from 1.

Example 18. Get the last line in the text:
"First line
Second line
Third line"

Text = "First line" + Symbols. PS + "Second line" + Symbols. PS + "Third line"; LastRow = StrGetRow(Text, StrNumberLines(Text)); Report(LastLine);

The result of executing this code will be the display of the line “Third Line”.

PageNumberOccurrences

StrNumberOccurrences(<Строка>, <ПодстрокаПоиска>) . Returns the number of occurrences of the specified substring in a string. The function is case sensitive.

Example 19. Determine how many times the letter “c” appears in the line “Lines in 1s 8.3 and 8.2”, regardless of its case.

Line = "Lines in 1s 8.3 and 8.2"; NumberOccurrences = StrNumberOccurrences(Vreg(String), "C"); Report(NumberOccurrences);

The result of executing this code will be the display of the number of occurrences: 2.

PageStartsWith

StrStartsWith(<Строка>, <СтрокаПоиска>) . Checks whether the string passed in the first parameter begins with the string in the second parameter.

Example 20. Determine whether the TIN of the selected counterparty begins with the number 1. Let in the variable Counterparty Counterparties.

TIN = Counterparty.TIN; StartsUNits = StrStartsWith(TIN, "1"); If Starts with units Then //Your code EndIf;

PageEndsOn

StrEndsWith(<Строка>, <СтрокаПоиска>) . Checks whether the string passed in the first parameter ends with the string in the second parameter.

Example 21. Determine whether the TIN of the selected counterparty ends with the number 2. Let in the variable Counterparty a reference to a directory element is stored Counterparties.

TIN = Counterparty.TIN; EndsWithTwo = StrEndsWith(TIN, "2"); If EndsInTwo Then //Your code EndIf;

PageSplit

StrDivide(<Строка>, <Разделитель>, <ВключатьПустые>) . Splits a string into parts using the specified delimiter characters and writes the resulting strings to an array. The first parameter stores the source string, the second contains the string containing the delimiter, and the third indicates whether empty strings should be written to the array (by default True).

Example 22. Let us have a string containing numbers separated by the symbol “;”, get an array of numbers from the string.

String = "1; 2; 3"; Array = StrDivide(String, ";"); For Count = 0 By Array.Quantity() - 1 Cycle Attempt Array[Count] = Number(AbbrLP(Array[Count])); Exception Array[Sch] = 0; EndAttemptsEndCycle;

As a result of execution, an array with numbers from 1 to 3 will be obtained.

PageConnect

StrConnect(<Строки>, <Разделитель>) . Converts the array of strings from the first parameter to a string containing all the elements of the array separated by the delimiter specified in the second parameter.

Example 23. Using the array of numbers from the previous example, get the original string.

For Account = 0 By Array.Quantity() - 1 Cycle Array[Act] = String(Array[Act]); EndCycle; Row = StrConnect(Array, "; ");

The basic capabilities of a programming language usually include working with numbers and strings. Usually these features are hard-coded into the compiler code (or the “base” classes of the programming language are implemented).

In 1C, the ability to work with strings is programmed in the platform itself. Today we will look at the features of working with 1C strings in programs in the built-in 1C language.

Line value 1C

1. Let's start with the simplest. Creating a variable and assigning a constant string value to it looks like this in 1C:

Variable = "Hello, world!";

If you need to specify a quote character in a constant 1C string value, then you need to double it “”

Variable = "Hello, world"!;

2. Line break 1C can be specified in two ways at once. The first is using the symbol |

Variable = "Hello,
| world! ";

The second is using the Symbols system enumeration. It allows you to add both 1C line breaks and other non-printing characters, such as TAB.

Variable = "Hello" + Symbols.PS + "peace!";

3. Configurations in 1C can be developed not only for one language (Russian, English or another) - but simultaneously for several languages. In this case, the currently used language is selected at the bottom of the 1C window.

The list of languages ​​is located in the configuration window in the General/Languages ​​branch. Each language has a short identifier such as ru or eng.

It is clear that when programming such a configuration, 1C lines can also be multilingual. To do this, it is possible to create such a 1C line by specifying through; options by language identifier:

Variable = "ru=""Hello, world! ""; en=""Hello, world! """;

If you use the 1C line formed this way as usual, then it will be what is written in it. In order for the system to split it into two options and use the desired one, you need to use the НStr() function:

//correct for bilingual configurations
Report(NStr(Variable));

Props with line type 1C

The attribute is a field in the 1C directory/document. It differs from a variable in a program in the 1C language in that for the attribute its type is precisely indicated (number, 1C string, etc.). If you need to refresh your memory of what a prop is, watch the lesson on.

If you specify the type of attribute - line 1C, then you must additionally specify the parameters.

1C lines come in unlimited length (indicated as length = 0) and limited length, indicating the exact number of characters. 1C lines of unlimited length are stored in a separate SQL table, so their use is less productive than limited.

That is why the use of 1C strings of unlimited length has its limitations - it is not possible to use them everywhere. For example, it is not allowed as a document number, reference code, or measurement.

Working with 1C strings

There are several built-in functions of the 1C platform for working with strings.

  • AbbrLP (“Incredible, but true!”)
    Removes extra spaces from the 1C line. Can also be used to convert any types to a 1C string (for example, numbers).
  • Variable = "Vasya" + AbbrLP(" plus") + "Olya"; //there will be "Vasya plus Olya"
    An example of summing several 1C string values. The result will be one line 1C.
  • Variable = Lev("Music", 2); //will be "Mu"
    Variable = Medium("Music", 2, 2); //there will be "threat"
    Variable = Rights("Music", 2); //there will be "ka"
    Various options for obtaining a substring from a 1C string.
  • Variable = Find("Music", "zy"); //there will be 3
    Search for a substring in string 1C, starting from character 1.
  • Variable = StrLength("Music"); //there will be 6
    Returns the number of characters in the 1C line.
  • Report("Hello") //in the message window at the bottom of the 1C window
    Alert("Hello") //popup dialog
    Status("Hello") //in the status display line at the bottom left
    .

Bringing objects to line 1C

As you know, the most popular format for exchanging structured information at present is XML. Even latest version MS Office Word and Excel save files in this format (docx and xlsx, respectively, change the extension to zip, open in an archiver).

The 1C platform for data exchange provides several options, the main one of which is also XML.

1. The simplest method is to use the Abbreviation() or String() function. You can use the REPRESENTATION() function in the request body. The result of their action is the same - they generate a string representation of any 1C object for the user.

For a directory by default, this will be its name. For a document – ​​document name, number and date.

2. Any 1C object (with restrictions) can be converted to XML and vice versa. The conversion process is called serialization.

StringViewXml = XMLString(Value); //get XML from 1C value
Value1C = XMLValue(Type("DirectoryLink.Nomenclature"),TypeStringXml); //get the 1C value from the XML string, you must specify the 1C type that should be received

3. There is the 1C platform’s own way to convert any 1C object into a string. It migrated from version 1C 7.7. This format is not understood by other programs, but other 1C understands it, which makes it easy to use it for exchange between 1C databases.

Row = ValueInRowInt(Value1C); //get string 1C from value 1C
ValueVFile("C:\MyFile.txt", Value1C); //another option, we get a file with a saved string from the 1C value
Value1C = ValueFromStringInt(String); //back from line 1C
Value1C = ValueFile("C:\MyFile.txt"); //back from file

Editing 1C lines on the form

In addition to working with 1C strings in a program in the 1C language, of course I would like the user to be able to edit them. There are several possibilities for this:

1. The easiest way is to request the entry of a 1C line on demand. This method is used when teaching 1C programming; in life it is used much less often (but it is used!).

Variable = "";
Row = EnterValue(Variable, "Enter Full Name");

2. To display the details of a 1C object (directory/document) or form details (see), an input field is most often used. This is the most common tool in 1C for the user to work with editing fields.

3. The capabilities of the input field can be expanded (see properties of the input field, right click on it, more details):

  • Checkbox Multiline editing mode
  • Advanced editing checkbox (available if the previous checkbox is checked)
  • Checkbox Password mode (see).

4. If all the capabilities of the input field are not enough for you, there is a built-in editor. To add it to the form, you need to add Field to the Form/Insert control menu text document. In its properties you can specify its operating mode – the Extension property.

A text document field cannot be associated directly with data. It is necessary to write a function in the OnOpen() event handler of the form (see):

Form Elements.ElementNameTextDocumentField.SetText(StringValue); //here ValueString is the text received, for example, from the attribute

And in the save handler - for example, in the Save button - add a save:

ValueString = FormElements.ElementNameTextDocumentField.GetText(); //ValueThe line here is the attribute where we save the value

5. In 1C version 8.2.11, in controlled forms, appeared new opportunity 1C line representation – Formatted document field.


Similar to the field of a text document, you must set it when opening it and write it down when saving it yourself using the program.

  • In the 1C object whose form we are creating (directory, document, processing, etc.) - add an attribute with the Value Storage type
  • In the OnReadOnServer() function we set the text from the attribute

    //here the Attribute is the added attribute of the 1C object
    //here FormattedDocument is the name of the field on the form for editing
    &On server

    FormattedDocument = CurrentObject.Attributes.Get();
    End of Procedure

  • In the BeforeWritingOnServer() function or using the button, we will write the text from the field

    &On server
    Procedure When ReadingOnServer(CurrentObject)
    CurrentObject.Props = NewValueStorage(FormattedDocument);
    End of Procedure

Notes from Through the Looking Glass

08/18/2014 New functions for working with strings

Implemented in version 8.3.6.1977.

We have expanded the set of functions designed to work with strings. We did this in order to give you more advanced tools for parsing string data. The new functions will be convenient and useful in technological tasks of text analysis. In tasks related to parsing text that contains data in formatted form. This could be an analysis of some files received from the equipment, or, for example, an analysis of a technological log.

You could perform all the actions that perform new functions before. Using more or less complex algorithms written in a built-in language. Therefore, new functions do not give you any fundamentally new capabilities. However, they allow you to reduce the amount of code and make the code simpler and more understandable. In addition, they allow you to speed up the execution of actions. Because the functions implemented in the platform work, of course, faster than a similar algorithm written in a built-in language.

Formatting function StrTemplate()

This function substitutes parameters into a string. The need for such a conversion often arises, for example, when displaying warning messages. The syntax for this function is as follows:

StrTemplate(<Шаблон>, <Значение1-Значение10>)

<Шаблон>- this is the string into which you need to substitute the parameter representations.

<Значение1> , ... <Значение10>- these are parameters (maximum ten), the representations of which must be substituted into the string.

To indicate a specific place in the template where you want to perform the substitution, you need to use markers like %1, ... %10. The number of markers involved in the template and the number of parameters containing values ​​must match.

For example, the result of executing such an operator:

there will be a line:

Data error on line 2 (Date type required)

Function for working with strings StrCompare()

This function compares two strings in a case-insensitive manner. For example, like this:

You could perform the same action earlier using the object Comparison of Values:

However, using the new feature looks easier. And besides this, a function, as opposed to an object Comparison of Values, works in both the thin client and the web client.

Functions for working with strings StrStartsWith(), StrEndsAt()

These functions determine whether a string begins with a specified substring or whether a string ends with a specified substring. The algorithm for these functions is not difficult to implement in an embedded language, but their presence allows you to write cleaner and more understandable code. And they work faster.

For example, it is convenient to use them in the operator If:

Functions for working with strings StrDivide(), StrConnect()

These functions split a string into parts using a specified delimiter. Or vice versa, they combine several lines into one, inserting the selected separator between them. They are convenient for creating or analyzing logs and technological journals. For example, you can easily parse a technological log entry into parts suitable for further analysis:

Function for working with strings StrFind()

Instead of the old function Find() we implemented new feature, which has additional features:

  • Search in different directions(from the beginning, from the end);
  • Search from a specified position;
  • Search for an occurrence with a specified number (second, third, etc.).

In fact, it duplicates the capabilities of the old function. This is done in order to maintain compatibility with modules compiled in older versions. Old function Find() It is recommended not to use again.

Below is an example using the new search capabilities. Reverse search is useful when you need the last part of a formalized string, such as the full file name in a URL. And searching from a specified position helps in cases where you need to search in a known fragment, and not in the entire line.

The String type is found in all programming languages. It is primitive, and in 1C there are many functions for working with it. In this article we will take a closer look various ways working with string types in 1C 8.3 and 8.2 using examples.

Line

In order to convert a variable of any type into a string, there is a function of the same name “String()”. The input parameter will be the variable itself, the string representation of which must be obtained.

String(False) // returns "No"
String(12345) // returns "12,345"
String(CurrentDate()) //"07/21/2017 11:55:36″

It is possible to convert not only primitive types to a string, but also others, for example, elements of directories and documents.

SokrLP, SokrL, SokrP

The input parameters of these functions are a variable of string type. Functions remove insignificant characters (spaces, carriage returns, etc.): from the left and right side, only on the left side, and only on the right, respectively.

Abbreviation(" Spaces will be removed on both sides ") // "Spaces will be removed on both sides"
Abbreviation(" Spaces on both sides will be removed ") // " Spaces on the left will be removed "
Abbreviation(" Spaces on both sides will be removed ") // " Spaces on the right will be removed"

Leo, Right, Medium

These functions allow you to trim part of a string. The "Left()" function will return the portion of a string from its left side of the specified length. The "Right()" function is similar, but crops from the right. The “Avg()” function allows you to specify the number of the character from which the line will be selected and its length.

Lev("String variable", 4) // returns "Str"
Right("String variable", 7) // returns "variable"
Medium("String variable", 2, 5) // returns "troko"

StrLength

The function determines the number of characters that are contained in a string variable.

StrLength("Word") // the result of execution will be the number 5

Find

The function makes it possible to search for part of a string in a string variable. The return value will be a number that shows the position of the beginning of the found string. If no match is found, zero is returned.

Please note that the search is case sensitive. If there is more than one occurrence of the search substring in the original string, the function will return the beginning of the first occurrence.

Find("one, two, one, two, three", "two") // function will return the number 6

Empty line

Using this function allows you to determine whether a string is empty. Minor characters such as space, carriage return, and others are not taken into account.

EmptyString("Pupkin Vasily Ivanovich") // function will return the value False
EmptyString(" ") // function will return the value True

VReg, NReg, TReg

These functions are very useful when comparing and converting string variables. "Vreg()" will return the original string in uppercase, “НReg()” is at the bottom, and “TReg()” will format it so that the first character of each individual word will be capitalized, and all subsequent ones will be capitalized.

VReg("GENERAL DIRECTOR") // return value - "GENERAL DIRECTOR"
NReg(“CEO DIRECTOR”) // return value – “CEO”
TREG(“CEO DIRECTOR”) // return value – “General Director”

PageReplace

This function is analogous to replacement in text editors. It allows you to replace one character or set of characters with another in string variables.

StrReplace("red, white, yellow", ","", ";") // returns "red; white; yellow"

StrNumberLines

The function allows you to determine the number of lines separated by carriage returns in a text variable.

The loop in the example below will go through three rounds because the LineNumberRow function will return the value 3:

For ind = 1 by StrNumber of Strings ("Line1" + Symbols.PS + "Line2" + Symbols.PS + "Line3") Cycle
<тело цикла>
EndCycle;

StrGetString

This function works with multiline text in the same way as the previous one. It allows you to get a specific string from a text variable.

StrGetString("String1" + Characters.PS + "String2" + Characters.PS + "String3", 2) // return "String2"

PageNumberOccurrences

The function counts the number of occurrences of a character or substring in the search string.

StrNumberAttachments("a;b;c;d; ", ";") // function will return the number 4

Symbol and Symbol Code

These functions allow you to obtain a character by its code in the Unicode encoding, as well as determine this code by the character itself.

SymbolCode("A") // function will return the number 1,040
CharacterCode(1040) // function will return “A”

Common tasks when working with strings

Concatenating Strings

To combine several strings (to perform concatenation), it is enough to use the addition operator.

“Line 1″ + “Line 2″ //the result of adding two lines will be “Line 1 Line 2”

Type Conversion

In order to convert a type into a string, for example, a link to a directory element, a number, etc., it is enough to use the “String()” function. Functions like “ScrLP()” will also convert variables into a string, but immediately with cutting off insignificant characters.

String(1000) // returns "1,000"

Please note that when converting a number to a string, the program automatically added a space separating the thousand. In order to avoid this, you can use the following constructions:

StrReplace(String(1000),Characters.NPP,"") // returns "1000"

String(Format(1000,"HG=")) // returns "1000"

Quotes in a string

Quite often you will have to deal with the need to specify quotation marks in a string variable. This can be either the request text written in the configurator, or just a variable. To solve this problem, you just need to set two quotation marks.

Header = String("Horns and Hooves LLC - that's us!") // will return "Horns and Hooves LLC - that's us!"

Multi-line, line break

In order to create multiline text It is enough to add line breaks to it (Symbols.PS).

MultilineText = “First Line” + Symbols.PS + “Second Line”

How to remove spaces

In order to remove spaces on the right or left, you can use the “ScrAP()” function (as well as “ScrL()” and “ScrP()”):

StringNoSpaces = Abbreviation(" Many letters ") // the function will return the value "Many letters"

If, after converting a number to a string, you need to remove non-breaking spaces, use the following construction:

StringNoSpaces = StrReplace(String(99999),Characters.NPP,"") // returns "99999"

Programmers also often use the following construction, which allows you to remove or replace with another character all spaces in a text variable:

StringNoSpaces = StrReplace("hello","") // returns "hello"

Comparing strings with each other

You can compare terms with the usual equal sign. The comparison is case sensitive.

"Hello" = "hello" // returns False
"Hello" = "Hello" // returns True
"Hello" = "Goodbye" // will return False