beautypg.com

2 string concatenation, 3 string null character, Table 35. measuring voltse() at 200 hz – Campbell Scientific CR800 and CR850 Measurement and Control Systems User Manual

Page 239

background image

Section 7. Installation

239

 

7.8.13.2 String Concatenation

Concatenation is the building of strings from other strings ("abc123"), characters
("a" or chr()), numbers, or variables.

Table 39. 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

 

7.8.13.3 String NULL Character

All strings are automatically NULL terminated. NULL, Chr(0) or "", counts as
one of the characters in the string. Assignment of just one character is that
character followed by a NULL, unless the character is a NULL.

Table 40. String NULL Character Examples

Expression Comments

Result

LongVar(5) = "#"-""

Subtract NULL, ASCII code results

35

LongVar(6) = StrComp("#","")

Also subtracts NULL

35

Example:

Objective:

Insert a NULL character into a string, and then reconstitute the string. 

Given:

StringVar(3) = "123456789"

Execute:

StringVar(3,1,4) = "" "12356789"

Results:

StringVar(4) = StringVar(3) "123"

But,

StringVar(3) still = "12356789",

so,

StringVar(5) = StringVar(3,1,4+1)
'"56789"
StringVar(6) = StringVar(3) + 4 + StringVar(3,1,4+1)
'"123456789"