Domestic SPL database like learning Excel, zero-based entry (2)

1. Introduction

In this article, we are going to learn about data types. Any data has its own type. For example, a number 5 is an integer. A number with a decimal point is called a floating point type. A string of characters is a teacher string type. Boolean is an event. Right and wrong, you can see the date at a glance, not to mention the date.

2. Basic data types

2.1 Shaping

Here we only learn int shaping. Although there is also long shaping, this is not commonly used, so I will not learn it. I have already said about understanding in the introduction, that is, numbers without decimal points.

The basic form is as follows:
insert image description here

2.2 Floating point

A floating-point type is a number with a decimal point. Some simple cases are as follows:
insert image description here
Supplementary knowledge points: no matter what language you learn, database, or integer divided by integer, its type will become a floating-point type.

2.3 Boolean Type

Boolean type: True or false of an event

For example, the following simple cases:
insert image description here
their corresponding results are:

  • Line A6: true, indicating that 5 is greater than 2 is correct
  • Line A7: false, indicating that 5 is greater than 6 is wrong
  • Line A8: false, indicating that 5 is equal to 6, which is wrong. Supplement: Use double equals to judge whether two values ​​are equal.
  • Line A9: true, indicating that the remainder of 7 divided by 3 is 1 is correct.

2.4 String type

For strings, we need to use double quotation marks to enclose them. The splicing of strings has some extensions from the language we usually learn:

  1. Everyone should know that using the plus sign splicing, it is still a string type after splicing
  2. When we learn other languages, we know that numbers and strings cannot be directly concatenated. In SPL, we can use backslashes/concatenation, and the result is a string.
  3. String concatenation can also be done by adding spaces in the middle, and the result is a string type
  4. You can fill in a string directly in SPL, in this case you do not need to add equal to

For example some examples below:
insert image description here

  1. Line B5: directly assign the value "Chuanchuan" to the cell. This is generally not recommended.
  2. Line B6: Use quotes to assign values ​​to cells
  3. Line B7: Concatenate two strings with spaces
  4. Line B8: Add a newline to the string
  5. Line B9: Concatenate the string in line B6 with the number 4

Supplementary note: We used a newline in line B8, and the result you see in the interface is as follows:
insert image description here

Don't be misled by this, in fact this is a newline, you can click: Copy data to view the complete display result
insert image description here
Copy it out, and then paste it into any text box, you can see it as:

川川
学长

3. Date type

We generally write in the form of month and day, and we want to separate them with a small one. We can directly write it in the form of a line, but it is recommended to use the date function to convert it into a date form. The following effects are the same:

2022-4-18
=date("2022" "-4" "-18")
=date(2022,4,18)

Demo:
insert image description here

Fourth, the data type judgment

To determine the data type, there are the following functions:

  1. ifnumber(x) determines whether x is a real number
  2. ifstring(x) determines whether x is a string
  3. ifdate(x) determines whether x is a date type or a datetime type
  4. iftime(x) judges whether x is a time type
    and their return results are all boolean types. If it is the corresponding type, it returns true, if not, it returns flase.

For example: determine whether A5 is a real number

=ifnumber(A1)

Demo:

insert image description here

For example: check if B8 is a string type

=ifstring(B8)

Demo:
insert image description here

For example: check if A14 is a date type

=ifdate(A14)

Demo:
insert image description here
We can use the now() function to get the current event, but it is a string type, for example:
insert image description here
the output result is:
insert image description here
For example: Check if A17 is a time type?

=iftime(A17)

Demo:
insert image description here
returns false because it is of type string.

Five, data type conversion

It is to convert one type to another data type, and you can directly apply int, float and other functions outside.

Example: Convert 3.14 in cell B1 to an integer

=int(B1)

Demo:
insert image description here
3.14 is converted to shaping, the result is 3,

6. Cell sequence

This is a common sense interspersed in the data type. It is actually very similar to the list. The form of the slice is separated by an English colon. For example, the
insert image description here
output result is:
insert image description here

7. Summary

In this article, we learned some forms of data types, and how to judge whether this data type is the type we want, it is still very simple.

Refer to the official documentation:

http://d.raqsoft.com.cn:6999/esproc/tutorial/jbsjlx.html

All the code files written in this article are stupy2.splx file download:

链接:https://pan.baidu.com/s/1B9zheqMoN18-y2GhZOgcOA?pwd=gzyk 
提取码:gzyk 
--来自百度网盘超级会员V3的分享

Next articleWe learn…

Guess you like

Origin blog.csdn.net/weixin_46211269/article/details/124263304