Constants

Read(1112) Label: constant,

In esProc computing, constants are frequently needed, and sometimes data is directly stored in the cellset. Here let’s learn how to use the constants in esProc.

Using constants in expressions

You can use constants in the esProc expressions:

 

A

1

=64*32

2

=round(1.45*5.5)

3

=isupper("Tom Sawyer")

When using constants in the expressions, use the integers and the floating-point numbers directly, but put the strings in quotes. You can also use the boolean constants true and false directly though there are few cases of using them. The results in A1, A2 and A3 are as follows:

   

In particular, the capitalized L can be appended to an integer to indicate a long integer. The long integers have a wider range of value; the hexadecimal long integers can be represented with strings whose first two characters are 0x:

 

A

1

=123456789L*100

2

=123456789*100

3

=0x00FF

Because the value range of normal integers is -231~231-1, that is, -2147483648~2147483647, the result in A2 exceeds that value range. In A1, a long integer is used, and the value range is increased to -263~263-1. By this way, the correct result can be obtained. The results in A1, A2 and A3 are as follows:

   

As you can notice, if a certain step of integer calculation in which one of the operands is a long integer, the result is the long integer.

In a string used in an expression, if there are special characters like " and \, use an escape character \ before each special character:

 

A

1

="C:\\Program Files\\"+"Java"

2

="\"I can come today,\" she said, \"but not tomorrow.\""

After execution, the resulting strings in A1 and A2 are as follows:

 

 The time and date constants are not allowed in the expressions. The strings or long integers should be converted through the type conversion functions, such as date(), time(), and datetime():

 

A

1

=interval@y(date("1944-6-6"),now())

The result of A1 is as follows:

Constant cells

If a cell can interpret a data string typed in it as a constant, then this cell can be regarded as a constant cell. Its value is the constant.

The text in a constant cell is by default diplayed in pink. Based on the format, the text string will be parsed into a value of corresponding data type, such as integer type, floating-point number type and datetime type. If the format is unidentifiable, it will be interpreted as the string type data.

The double quotation marks are not necessary when a string is defined in the constant cell.

In addition, in the constant cell, data can be represented as a percentage, like 5%:

 

A

1

5%

2

=A1*1000

After computation, the cell values of A1 and A2 are as follows:

 

In the constant cell A1, 5% will be converted to the corresponding float value 0.05. Note: The format like 5% is forbidden in the expressions, but only allowed in the constant cells.

The value in the constant cell can also be true, false or null:

 

A

1

true

2

false

3

null

These are reserved words that are case-sensitive. As can be seen from above, the constant cell value is a boolean value or a null value:

    

You can use the string constant cell to specify the value of a cell as a string. The string in a string constant cell starts with the single quotation mark ' of English font. The string constant cell is used to define the strings containing special characters or those composed of numbers:

 

A

1

'abc\d

2

'1234.5

3

1234.5

In the above cellset, the value of the constant cell A1 is the string abc\d; the value of cell A2 is the string 1234.5; and the value of cell A3 is the number 1234.5:

   

In the constant string cells, the escape character \ is not necessary if any special character exists in the string:

 

A

1

'C:\Program Files\Java

2

'"I can come today," she said, "but not tomorrow."

The string values in A1and A2 are as follows:

 

In a constant cell, you can also define the sequence constant with the brackets [],with members of the sequence separated by the comma. For example:

 

A

1

[2,3,5,7,11]

2

[Gold,Silver,Bronze]

The sequence constants in A1 and A2 are as follows:

 

In defining a sequence constant, it is also unnecessary to put each of the string members of the sequence in a pair of double quotation marks.

In an expression, you can reference the constant cell with its name:

 

A

1

1944-6-6

2

=interval@y(A1,now())

The result of A2 is as follows:

Constant cells sequence

In esProc, you can represent a sequence of constants using cells that hold constants and use the constant cells sequence in an expression. For example:

 

A

B

C

D

E

F

1

1

2

4

8

16

32

2

=[A1:F1]

 

 

 

 

 

In A2, the expression [A1:F1] indicates a sequence composed of the values of all cells in the area from A1to F1. The sequence is as follows:

The cells in the sequence can be in a continuous strech of area:

 

A

B

C

1

1

2

4

2

8

16

32

3

=[A1:C2]

 

 

In A3, expression [A1:C2] indicates a sequence composed of values of cells in an area from A1 to C2, whose members follow the order of first-row-then-column. The result of A3 is as follows:

esProc supports filling values of a continuous stretch of constant cells in a table sequence (Tseq):

 

A

B

C

D

E

1

German

2

1

0

7

2

American

1

1

1

4

3

Portugal

1

1

1

4

4

GHana

0

1

2

1

5

=create(Team,W,D,L,Points)

 

 

 

 

6

>A5.record([A1:E4])

 

 

 

 

In A5, a new TSeq is created. In A6, the record function fills the TSeq with the values of the constant cells in the area from A1 to E4. The result of A5 is as follows:

With such a method, the dfx file can be used to store the tabular data.