Internet Windows Android

1s 8 remove spaces from string. Comparing strings to each other

It often happens that when loading and unloading data from 1C 8.2 and 8.3, there are spaces in the numbers that prevent the data from being processed normally. The solution to this problem is very simple.

Consider what types of gaps are.

Spaces can be of two types:

  • non-breaking space;
  • "regular" space.

Removing non-breaking spaces

StringRepresentation = String(Number); // the system will write to the variable "10 000"

Removing such spaces in 1C is very simple through the number format function:

Number = Format(10000, "CH=");

StringRepresentation = String(Number); // the system will write to the variable "10000"

We set the grouping in the format string to an empty value (you can also write "0").

If the data type is already "string", then the following method can be used:

StringRepresentation = StrReplace(String(StringRepresentation), Characters.NPP, ""); // variable StringRepresentation was "10 000", became "10000"

That is, we simply replaced the non-breaking space (Symbols.NPP) in the string with an empty value.

Regular spaces

Removing a regular space in a string is as easy as shelling pears. It is enough to execute the following function:

StringRepresentation = StrReplace(String(StringRepresentation), " ", ""); // "10,000" became "10,000"

The example is similar to the previous method. However, instead of Symbols.npp, we use a single-space string.

If you are starting to learn 1C programming, we recommend our free course (do not forget subscribe to youtube - New videos are released regularly.

FAQ or platform 8 for dummies.

Judging by the forums dedicated to 1C, programmers who first encountered the 1C v 8 platform or transitioning from 7.7 often have the same questions. Here I decided to collect the most common, in my opinion ...

V: How to remove a space in the number 12,600.00?
O: It is important to understand that it is not the space character that is used here, but the so-called “non-breaking space”, therefore, for example, the following construction:

StrReplace(VariableNumber," ","");

will not work. There are two options for solving the problem, either specify Symbols.NPP for replacement instead of a space, or using the Format () function.

StrReplace(VariableNumber, Symbols.NPP,""); // 1st option
Format(VariableNumber,"CH="); // 2nd option

V: How to set a condition in a query in such a way that only documents of a certain type would be included in the resulting selection?
O: This can be done using the query language operator REFERENCE, which allows you to check whether the value of the expression specified to the left of it is a reference to the table specified to the right. Consider an example, select from the accumulation register Realization of Services only those records for which the registrar is the document Realization of Goods and Services:

Request=New Request("
|CHOOSE
| Implementation of Services. Registrar,
| Implementation of Services. Amount
| FROM
| Accumulation Register. Implementation of Services AS Implementation of Services
|WHERE
| Registrar LINK Document. Sales of Goods and Services");

V: How to transfer certain documents/directories between identical configurations?
O: This can be done with the help of the sample processing UploadUploadDataXML.epf supplied on the ITS disks.

V: How to transfer data between different configurations (or from 7.7 to 8)?
O: The best option, in my opinion, is to use the typical "Data Conversion" configuration, which is supplied on ITS disks, there are also several articles describing the use of this configuration.

V: How to add a certain string to a field of non-string type in a query, for example, SELECT Realization of Goods of Services. Amount + "rub."?
O: No way. Type conversion is not possible in a query. The EXPRESS query language construct is misleading to some, but it only casts a value of a composite type to one of the component types of that value and does not in any way convert the type, so it is not applicable in this situation.

V: How to set a condition in a query on a field with the string type of unlimited length, for example, select all documents with a certain comment?
O: To do this, you must limit the length of the field using the EXPRESS query language operator. For instance:

Request=New Request("
|CHOOSE
| Realization of Goods and Services. Link
| FROM
| Document.Sale of Goods/Services HOW Realization of Goods/Services
|WHERE
| EXPRESS(ImplementationProductsServices.Comment AS STRING(100)) = &Comment");

V: Is there an analogue of function 7.7 CatalogIB() in v 8?
O: No, since such a function would not make sense for a client-server mode of operation. However, for the file mode of operation, you can get the infobase directory using the following construction:

DirectoryIB=NSstr(InfobaseConnectionString(),"File");

V: How to disconnect a node from a distributed infobase?
O: With the following construct:

Exchange Plans.SetMainNode(Undefined);

Or run the configurator with the /ResetMasterNode command line parameter (not used for basic versions).

V: How to get the name of the document (analogous to method 7.7 View())?
O: With the help of metadata. For instance:

V: How to select documents of all kinds with one query?
O: Using metadata and the ability to combine queries V:

Request=New Request;
Text="";
For Each Document From Metadata.Documents Loop
Text=Text+"CHOOSE Link FROM Document."+Document.Name+"JOIN";
EndCycle;
Query.Text=Lev(Text, StrLength(Text)-StrLength(" UNITE "));
Selection=Query.Execute().Select();

V: How to interrupt the execution of a report/processing?
O: With the UserInterruptHandle() operator, it is recommended to use it inside loops. When the user presses the Ctrl+Break key combination, the execution is interrupted and a corresponding message is displayed. For instance:

While Selection.Next() Loop
HandlingUserInterrupt();

EndCycle;

V: The form has a TableField with the ValueTree type and the Tree property set. Why is the Value Tree not displayed?
O: It is also necessary to set the DisplayHierarchy property for one of the columns.

V: How to use scheduled tasks in the infobase file mode?
O: Unlike the client-server mode, in file mode, the developer is responsible for the implementation of automatic launch of scheduled tasks. To implement autostart of jobs, you need a Wait Handler that periodically checks for “overdue” jobs and starts them. It is highly recommended to use a separate session for this. Example:

Task Check() procedure
ExecuteProcessingJobs();
EndProcedure
ConnectWaitingHandler("CheckingTasks",3);

V: How to get an array from a delimited string?
O: As an example, I will give my version of a function that works "in both directions", i.e. when passing a delimited string, it forms an array, and when passing an array, it forms a delimited string from it.

Function StringArray(Value Value, Separator)
If TypeValue(Value)=Type("String") Then
MnStr=StrReplace(Value, Separator, Symbols.PS);
Array=New Array;
For n=1 By StrNumber of Rows (MnStr) Cycle
Array.Add(StrGetString(MnStr,n));
EndCycle;
Return Array;
ElseIf TypeValue(Value)=Type("Array") Then
String="";
For Each Element From Value Loop
String=String+?(String"",Separator,"")+Element;
EndCycle;
Return String;
Otherwise
Return Undefined;
EndIf;
EndFunctions

V: How to enable the ability to make changes in the configurator in a typical configuration?
O: Since typical configurations are supported (which allows automatic updates), by default, the ability to make changes to the configuration is disabled. To enable this feature, select the menu item "Configuration > Support > Support settings" in the configurator and click the "Enable the ability to change" button in the window that opens.

V: How to set a password for processing/configuration?
O: In 1C v 8, passwords can only be set on object modules. To set a password, you need to open the object module and select the menu item "Text > Set password". It is also possible to deliver the configuration without the source code of the object modules (configure "Configuration > Configuration delivery > Delivery settings"). I would like to note that at the moment, none of these methods is a reliable protection against viewing the source code of the module.

V: Why does the search for a document not work using the FindByNumber(<Номер документа>)?
O: It must be remembered that if periodic numbering is set for this type of documents in the configurator, in addition to the document number, it is necessary to indicate the date of the interval as the second parameter. Otherwise, a document with an empty date will be searched, which obviously will not lead to the desired result.

V: In 1C 8.1, if you need to connect to an already running application for debugging (Configurator > Debugging > Connection), the available debugging items are empty. What is the reason?
O: The fact is that for the application that we are going to debug, you need to explicitly enable debugging. Tools menu > Options > System tab > Debugging enabled flag.

V: How to sort through the rows of a dynamic list (for example, DirectoryList or DocumentList)?
O: This can be done using Report Builder, for example:

Builder=New Report Builder;
Builder.DataSource=NewDataSourceDescription(DocumentList);
Selection=Builder.Result.Select();
While Selection.Next() Loop
Report(Selection. Link);
EndCycle;

Note: the selection will include rows in accordance with the selection currently set.

V: How to check property values ​​of metadata objects? For example, the type of directory hierarchy or the register entry mode, or the frequency of the document number?
O: All of these properties are enumerated properties of metadata objects. You can also get values ​​of this type through metadata. Examples:

// Example 1. Lookup Hierarchy View
If Metadata.Catalogs[CatalogName].HierarchyView = Metadata.ObjectProperties.HierarchyView.HierarchyGroupsAndItems Then...
// Example 2. RegisterWriteMode
If Metadata.InformationRegisters[RegisterName].RegisterWriteMode = Metadata.ObjectProperties.RegisterWriteMode.RegisterSubordinate Then...
// Example 3. Periodic document number
If Metadata.Documents[DocumentName].Number Periodicity = Metadata.ObjectProperties.DocumentNumber Periodicity.Non-Periodic Then...

V: How to implement a checkbox with three states in the value tree?
O: Let us consider the problem statement in more detail. The form has a table field whose data source is a value tree. One of the columns contains a checkbox control. It is necessary that it could take three states "On", "Off" and "Undefined". In this case, the state is "Undefined" or the so-called "gray flag", i.e. partially selected, set if not all subordinate rows have the same flag state. Also, if a row has subordinate rows, then when its flag is changed, the flags of all subordinate rows should be changed accordingly.
First, let's add our checkbox column to the value tree:

Tree.Columns.Add("Mark",NewTypeDescription("Number"));
FormElements.Tree.CreateColumns();
TreeColumns=FormElements.Tree.Columns;
TreeColumns.Mark.FlagData="Mark";
TreeColumns.Mark.SetControlItem(Type("Checkbox"));
TreeColumns.Mark.EditMode=EditModeColumns.Immediate
enno;
TreeColumns.Tag.ThreeFlagStates=True;

Secondly, when changing the flag, you need to set the appropriate values ​​in the subordinate rows and control the value of the flag in the “parent row”:

Procedure TreeOnChanging a Flag(Element, Column)
CurrentRow=Element.CurrentRow;
If CurrentLine.Mark=2 Then
CurrentLine.Mark=0;
EndIf;
SettingFlags(CurrentRow,CurrentRow.Mark);
While CurrentRow.ParentUndefined Loop
CurrentRow.Parent.Label=?(SetForAll(CurrentRow),CurrentRow.Label,2);
CurrentRow=CurrentRow.Parent;
EndCycle;
EndProcedure

Here, the procedure SetFlags() recursively sets the flags in the sub-rows:

Procedure SetFlags(CurrentRow,Value)
For Each Page Of CurrentRow.Rows Loop
PageMark=Value;
SetFlags(Pg,Pg.Mark);
EndCycle;
EndProcedure

And the function SetForAll() checks if the same value is set for all rows at the current level:

Function SetForAll(String)
For Each Page Of Row.Parent.Row Loop
If Page.MarkString.Mark Then
return false;
EndIf;
EndCycle;
return true;
EndFunctions

V: How to implement sorting by attribute in list form?
O: If the attribute is of a primitive type, then it is enough to set the property of the attribute "Index" to "Index" or "Index with additional ordering” (not available for attributes of the ValueStorage type). If the attribute is of a reference type, then it is necessary to explicitly enable sorting for it. For instance:

ElementUE=Form Elements.DirectoryList.Order Settings.Find("Attribute1");
If ElementUE is Undefined Then
ItemUE.Availability=true;
EndIf;

Strings in 1C 8.3 in the built-in language 1c are 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 quotation marks.

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

StringVariable = "Hello world!";

Functions for working with strings in 1s 8.3

This section will provide the main functions that allow you to change lines in 1s, or analyze the information contained in them.

StrLength

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

Example 2. Let's count the number of characters in the string "Hello world!".

String = "Hello world!"; Number of Characters = StrLength(String); Report(Number of Characters);

The result of executing this code will be displaying the number of characters in the string: 11.

Abbreviated

Abbr(<Строка>) . Trims non-significant characters to the left of the first significant character in a string.
Insignificant 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 string "peace!" and append the string "Hello" to it.

String = abbr("world!"); String = "Hi"+String; Notify(String);

The result of the execution of this code will be the display of the string "Hello world!".

Abbreviation

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

Example 4. Form from the strings "Hello" and "world!" phrase "Hello world!"

String = abbr("Hi")+" "+abbr("world!"); Notify(String);

Abbreviated LP

Abbrl(<Строка>) . Trims non-significant characters to the right of the first significant character in the string, 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 versatile.

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

Contractor = Directories.Contractors.FindBy Details("TIN", "0777121211"); ContractorObject = Contractor.GetObject(); ContractorObject.Description = Abbreviated LP(ContractorObject.Description); ContractorObject.Write();

a lion

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

Example 6. Let the structure Employee contain the name, surname and patronymic of the employee. Get string with last name and initials.

InitialName = Lion(Employee.Name, 1); Patronymic Initial = Leo(Employee.Patronymic, 1); FullName = Employee.LastName + " " + FirstName Initial + "." + Patronymic Initial + ".";

Rights

Right(<Строка>, <ЧислоСимволов>) . Gets the last characters of a string, the number of characters is 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 be written at the end of a string variable in the format “yyyymmdd”, get a string with a date and convert it to type date.

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

Wednesday

Wednesday(<Строка>, <НачальныйНомер>, <ЧислоСимволов>) . Gets a substring from the string passed in the parameter Line, starting from the character whose number is specified in the parameter InitialNumber and the length passed to the parameter Number of Characters. The numbering of characters in a string starts from 1. If 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, characters up to the end of the string are selected.

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

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

PageFind

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

  • Line. Source string;
  • SubstringSearch. The desired substring;
  • DirectionSearch. Specifies the direction to search for a substring in a string. Can take values:
    • Search Direction.From the Beginning;
    • Search Direction.From the End;
  • StartPosition. Specifies the position in the string at which to start the search;
  • Entry Number. Specifies the number of occurrences 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.From End); Notify(PositionNumber);

The result of the execution of this code will be the display of the number of the last occurrence of the symbol "and" on the screen: 9.

VReg

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

Example 10. Convert the string "hello world!" to uppercase.

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

The result of the execution of this code will be the display of the string "HELLO WORLD!"

HReg

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

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

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

The result of the execution of this code will be the display of the string "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. Capitalize the first letters of the words in the string "hello world!".

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

The result of the execution of this code will be the display of the string "Hello World!"

Symbol

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

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

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

The result of the execution of this code will be the display of the string "★Hello World!★"

SymbolCode

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 string "Hello World!".

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

The result of the execution of this code will be the display of the code of the symbol "!" — 33.

Empty line

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

Example 15. Check if the string is empty and consists of three spaces.

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

The result of the execution of this code will be the display of the word "Yes" (string expression of a boolean value True).

StrReplace

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 "World" with the word "Friends".

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

The result of the execution of this code will be the display of the string "Hello Friends!"

StrNumberRows

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

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

Number = StrNumber of Lines("First line"+Symbols.PS +"Second line"+Symbols.PS +"Third line"); Report(Number);

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

StrGetString

StrGetString(<Строка>, <НомерСтроки>) . Gets a string 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"+Characters.PS +"Second Line"+Characters.PS +"Third Line"; LastLine = StrGetLine(Text, StrNumber of Lines(Text)); Notify(Last Line);

The result of the execution of this code will be the display of the line "Third line".

StrNumberOccurrences

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” enters the line “Lines in 1s 8.3 and 8.2”, regardless of its case.

String = "Lines in 1s 8.3 and 8.2"; Number of Occurrences = StrNumber of Occurrences(Vreg(String), "C"); report(number of occurrences);

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

PageBeginsFrom

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

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

TIN = Contractor.TIN; StartsCUnits = StrStartsC(TIN, "1"); If StartsFROM1 Then //Your code EndIf;

Page Ends On

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

Example 21. Determine if the TIN of the selected counterparty ends with the number 2. Let the variable counterparty the link to the directory element is stored Counterparties.

TIN = Contractor.TIN; Ends With Two = Str Ends With (TIN, "2"); If Ends With Two Then //Your Code EndIf;

PageSplit

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

Example 22. Suppose we have a string containing numbers separated by the symbol ";", get an array of numbers from the string.

String = "1; 2; 3"; Array = StrSplit(String, ";"); For Count = 0 By Array.Quantity() - 1 Loop Attempt Array[Count] = Number(Ablp(Array[Count])); Exception Array[W] = 0; EndTry EndCycle;

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

StrConnect

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

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

For Count = 0 By Array.Quantity() - 1 Loop Array[Count] = String(Array[Count]); EndCycle; String = StrConnect(Array, "; ");

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 consider in detail the various ways to work with string types in 1C 8.3 and 8.2 using examples.

Line

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

String(False) // returns "No"
String(12345) // returns "12 345"
String(CurrentDate()) //"21.07.2017 11:55:36"

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

Abbreviated LP, Abbreviated L, Abbreviated P

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

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

Leo, Right, Middle

These functions allow you to cut off part of a string. The Lion() function will return the part of the string on its left side of the specified length. The "Right()" function is similar, but cropping is done on the right. The "Wed()" function allows you to specify the character number from which the string will be selected and its length.

Lion("String variable", 4) // returns "Stro"
Right("String variable", 7) // returns "variable"
avg("String variable", 2, 5)// returns "troco"

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 a part of a string in a string variable. The return value will be a number that indicates the position of the beginning of the found string. If no matches are found, zero is returned.

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") // the function will return the number 6

Empty line

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

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

VReg, NReg, TReg

These functions are very useful when comparing and converting string variables. "Vreg()" will return the original string in uppercase, "HReg()" in lowercase, and "TReg()" will format it so that the first character of each individual word is capitalized, and all subsequent characters are lowercase.

VReg("GENERAL DIRECTOR") // return value - "GENERAL DIRECTOR"
HReg("GENERAL DIRECTOR") // return value - "CEO"
TReg("GENERAL DIRECTOR") // return value - "General Director"

StrReplace

This function is similar to replacement in text editors. It allows you to substitute one character or set of characters for another in string variables.

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

StrNumberRows

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

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

For ind \u003d 1 by StrNumber of Lines ("Line1" + Symbols.PS + "String2" + Symbols.PS + "Line3") Loop
<тело цикла>
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" + Symbols.PS + "String2" + Symbols.PS + "String3", 2) // returns "Line2"

StrNumberOccurrences

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

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

Symbol and SymbolCode

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

SymbolCode("A") // the function will return the number 1 040
SymbolCode(1040) // the function will return "A"

Frequent tasks when working with strings

String Concatenation

To concatenate multiple strings (concatenate) just 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 to a string, for example, a reference to a dictionary element, a number, and so on, it is enough to use the "String ()" function. Functions like "ShortLP()" will also convert variables to a string, but immediately with cutting off insignificant characters.

String(1000) // will return "1000"

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 structures:

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

String(Format(1000,"CH=")) // will return "1000"

Quotes in a string

Quite often you will have to deal with the need to put quotes in a string variable. It can be either a request text written in the configurator, or just a variable. To solve this problem, you just need to set two quote characters.

Header = String("Horns and Hooves LLC is us!") // returns "Roga and Hooves LLC is us!"

Multiline, line break

In order to create a multiline text, it is enough to add line break characters (Symbols.PS) to it.

MultilineText = "First Line" + Characters.PS + "Second Line"

How to remove spaces

In order to remove spaces on the right or left, you can use the function "Stretch()" (as well as "Scrpt()" and "ScreenP()"):

StringWithoutSpaces = ShortLP(" 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:

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

Also, programmers often use the following construction, which allows you to remove or replace all spaces of a text variable with another character:

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

Comparing strings to each other

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

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