Section 7. Installation
+ operation is performed. When working with strings, exclusive use of the &
operator ensures that no string value will be converted to an integer.
Table 47.
String Concatenation Examples
Expression
Comments
Result
Str(1) = 5.4 + 3 + " Volts"
Add floats, concatenate strings
"8.4 Volts"
Str(2) = 5.4 & 3 & " Volts"
Concatenate floats and strings
"5.43 Volts"
Lng(1) = "123"
Convert string to long
123
Lng(2) = 1+2+"3"
Add floats to string / convert to long
33
Lng(3) = "1"+2+3
Concatenate string and floats
123
Lng(4) = 1&2&"3"
Concatenate floats and string
123
CRBasic Example 59.
Concatenation of Numbers and Strings
'This program example demonstrates the concatenation of numbers and strings to variables
'declared As Float and As String.
'
'Declare Variables
Public
Num(12)
As Float
Public
Str(2)
As String
Dim
I
BeginProg
Scan
(1,Sec,0,0)
I = 0
'Set I to zero
'Data type of the following destination variables is Float
'because Num() array is declared As Float.
I += 1
'Increment I by 1 to clock through sequential elements of the Num() array
'As shown in the following expression, if all parameter are numbers, the result
'of using '+' is a sum of the numbers:
Num(I) = 2 + 3 + 4
'= 9
'Following are examples of using '+' and '*' when one or more parameters are strings.
'Parameters are processed in the standard order of operations. In the order of
'operation, once a string or an '&' is processed, all following parameters will
'be processed (concatenated) as strings:
I += 1
Num(I) = "1" + 2 + 3 + 4
'= 1234
I += 1
Num(I) = 1 + "2" + 3 + 4
'= 1234
I += 1
Num(I) = 1 + 2 + "3" + 4
'= 334
I += 1
Num(I) = 1 + 2 + 3 + "4"
'= 64
284
Содержание CR1000
Страница 2: ......
Страница 4: ......
Страница 6: ......
Страница 32: ......
Страница 36: ......
Страница 38: ......
Страница 40: ......
Страница 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Страница 96: ......
Страница 98: ...98 ...
Страница 302: ......
Страница 350: ...Section 8 Operation Figure 91 Pulse Sensor Output Signal Types Figure 92 Switch Closure Pulse Sensor 350 ...
Страница 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Страница 454: ...Section 8 Operation 8 8 1 Data Display Figure 116 Displaying Data with the Keyboard Display 454 ...
Страница 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Страница 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Страница 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Страница 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Страница 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Страница 478: ......
Страница 506: ......
Страница 536: ......
Страница 636: ......
Страница 642: ......
Страница 644: ......
Страница 676: ......
Страница 677: ......