The 1C:Enterprise language supports a set of primitive data types. Most primitive data types allow to use literals in the module code, that is, to specify the value of the corresponding type directly in the module.
// Example of a String type literal A = "My string"; // Example of a Boolean type literal B = True; // Example of a Number type literal В = 12345.6789;
Values of this type are used only to specify the missing value in a database operations, for example, when joining tables.
Variables of this type have two values, True and False, given by the corresponding literals. Values of this type are returned as a result of evaluating logical expressions.
The 1C:Enterprise language comparison operations use logical expressions. This means that comparison expression should not necessary has the form:
If MyVariable = True Then EndIf;
The following is enough:
If MyVariable Then EndIf;
Values of this type contain an AD date (starting from January, 1 0001) and a time with 0.1 millisecond accuracy.
A string of numbers enclosed in single quotes of the form ‘YYYYMMDDhhmmss’, where:
- YYYY a 4-digit number of year
- MM a 2-digit number of month
- DD a 2-digit number of day
- hh a number of hour (in 24-hour format)
- mm a 2-digit number of minute
- ss a 2-digit number of second
A literal of the Date type must contain year, month, and day. You can omit seconds or the entire time. If seconds are not specified, they are set to 0. A starting date is '00010101'. All chars other than digits are ignored in the date literal. You can place separators in the date literal to simplify its presentation.
Date('2017\03\23 10~45~25') = 23.03.2017 10:45:25 Date('2017\03\23 10~45~25') = 23.03.2017 10:45:25 Date('2017.03.23 10:45:25') = 23.03.2017 10:45:25 Date('20170323104525') = 23.03.2017 10:45:25
The numeric type can represent any decimal number. The language defines the following basic arithmetic operations on data of numeric type: addition, subtraction, multiplication, and division.
IMPORTANT! The maximum width of the number is 32 characters.
A set of numbers directly in the code of a module of the form:
Point is used as a separator for the integer and fractional parts.
A = 15; B = 968.612;
Values of this type contain a string of arbitrary length in Unicode format. The string is encoded in UTF-16 format. If you need to specify a surrogate pair in the string, you should use two calls of the Char() function specifying the value of each code unit from the surrogate pair in turn.
String literals are a set of characters enclosed in quotes. For the quote character, you need to type two quotes in a row ("").
In addition, you can use "multiline" string constants. In the source code, the multiline constants can be specified in two ways:
- Between fragments representing individual lines of a multiline string, no characters except for spaces, line breaks and comment lines can be inserted.
- Each individual fragment is not closed with quotes, and each next line should start with hyphenation character “|” (vertical bar). In this variant, comments are allowed if the line starts with the comment character “//”.
// String example MyString = "This is a valid string"; // Example 1: Multiline string MyMultilineString = "This is |a valid |multiline |string"; // Example 2: Multiline string MyMultilineString = "This is" // This is a comment "a valid" "multiline" "string"; // Example 3: String containing quotes CompanyName = """Cornflower"" LLC" // Example 4: Surrogate pair TextWithSurrogatePair = "Hieroglyph: " + Char(55401) + Char(56997);
CompanyName from Example 3 is displayed and printed as follows:
The value of this type is used when it is necessary to use an empty value that does not belong to any other type. For example, attributes of a composite type initially have such values. There is one single value of this type, given by literal.
Values of this type are used to identify types of values. This is necessary to define and compare types. This type has no literals and can be returned by the 1C:Enterprise language functions TypeOf and Type (see below).