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
Summary of Contents for CR1000
Page 2: ......
Page 4: ......
Page 6: ......
Page 32: ......
Page 36: ......
Page 38: ......
Page 40: ......
Page 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Page 96: ......
Page 98: ...98 ...
Page 302: ......
Page 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Page 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Page 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Page 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Page 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Page 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Page 478: ......
Page 506: ......
Page 536: ......
Page 636: ......
Page 642: ......
Page 644: ......
Page 676: ......
Page 677: ......