Various data stored on disk or memory have their own different storage formats, so different data types exist. Understanding the characteristics of various data is very important for programming development.
Some operations are often performed in programs. Operations in Easy Language must be recognized and processed using operators, and the operation operations are completed through operation expressions. The description of the relationship between each data in the program must also be performed by operators.
1. Easy language data types
A program should include two aspects: 1. Description of data and 2. Operation steps, that is, description of program actions.
Data is an object of program operations, and the result of operations will change the content of the data. For example: To make a dish, choose the cooking ingredients (that is, describe the data) before cooking, then start cooking (that is, the operation of the data), and finally prepare a dish (change the status of the original data and obtain the calculation result).
The same is true for programming. The program needs to operate some data. Before the operation, it must first describe the data to be operated, that is, define variables of the relevant data type, and then use commands or methods to operate the data, and finally obtain the operation result, and further display the results. Chinese programming
The data types of Easy Language are distinguished from the data structure and can be divided into basic data types and composite data types. Basic data types include: numerical, logical, date and time, etc.; composite data types include data types customized by all users and support libraries. Data types can be used to describe the types of variables or component attributes, etc.
2. Basic data types
2.1 Understanding basic data types
There are six basic data types in Yi Language, including numerical, logical, date and time, text, byte set, and subroutine pointer.
Numerical data also includes byte type, short integer type, integer type, long integer type, decimal type, and double precision decimal type. This type represents the range of values and the length represented by the machine. You can view the length and occupancy bytes of the data type in the "Length of Data Type and Overflow" table.
Data type name Occupancy bytes Value range
Byte Type 1 0 to 255 Chinese Programming
Short integer type 2 -32,768 to 32,768
Integer type 4 -2,147,483,648 to 2,247,483,647
Long integer type 8 -9,223,372,036,854,775,808 to 9,233,372,036,854,775,807
Decimal type 4 -3.4E38 to 3.4E38 (7 decimal places)
Double precision decimal type 8 -1.7E308 to 1.7E308 (15 decimal places)
Logical type 2 "true" or "false"
Date and time type 8 January 1, 100 to December 31, 9999. In Yi [2007-10-24]
Subroutine pointer 4 size is 4 bytes. These data types are used to interact with external programs or operating system APIs, Chinese programming
is the address of a subroutine in memory.
Text type consists of a series of characters ending with byte 0. In Yizhong, he said "China Yimeng Technology Forum"
Byte set A piece of byte type data. In the Circular, {2,3,2,4} MP3 and pictures are typical byte set data;
2.2 Data comparison
In programming, comparisons are often made between various data. Comparing the same data types can be done directly; while comparing the same data types between different data types requires first conversion of the data types, and converting different data types to the same type before comparing, otherwise the program will make an error.
For example: Enter an integer in the edit box to compare whether the content in the edit box is greater than 50. Since the content in the edit box is a text, first you need to convert the content in the edit box into integer data, then compare and enter the following code:
To value (Edit box 1. Content) > 50
After comparison, a logical data will be returned, which will return "true" if greater than 50, less than or equal to "false".
Commonly used commands for converting data types in Easy Language include:
"To value()" is used to convert a general-purpose data to an integer
"To Text()" is used to convert a general-purpose data to text
"To byte set()" is used to convert a general-purpose data to byte set data
"Convert from byte set (,)" is used to convert a byte set data into general data. The second parameter of the command controls the data type to be converted into
"Time()" is used to convert a text-type data into a date-time type
The same is true for comparison between variables. You must pay attention to the data type of the variable. Variables of different types of data must be converted to the same type before comparing.