Basic programming guide – Remote Processing BASIC for the CX-10 Modbus User Manual

Page 71

Advertising
background image

BASIC PROGRAMMING GUIDE

2-62

Syntax:

A = STR(3,$(n))

Description:

Returns numbers in a string as a real number. Similar to VAL in other Basics. Leading spaces are ignored.
First non-number terminates conversion at last valid number. No valid numbers return 0. Number length is
limited to the first 12 valid numbers and decimal in a string. This means a number no greater than
9999999999999 is converted to a number.

Example:

10

STRING 100,20

20 $(2) = "-23.452volts"
30 A= STR(3,$(2))
40

PRINT A

run
-23.452

Syntax:

A = STR(4,$(n))

Description:

Trims spaces to left of first non-space character. Variable A returns length of trimmed string.

Example:

10

STRING 100,20

20 $(0) = "

1234"

30 A = STR(4,$(0))
40

PRINT $(0)

50

PRINT A

run
1234
4

Syntax:

A = STR(5,$(n))

Description:

Trims spaces from right side of string. Variable A returns length of trimmed string.

Example:

10

STRING 100,20

20 $(0) = "ABCDE

"

30 A = STR(5,$(0))
40

PRINT $(0)

50

PRINT A

run
ABCDE

5

Syntax:

A = STR(6,$(x),$(y))
A = STR(6,$(x),"string")

Description:

Appends one string into another. This function concatenates two strings in the form of $(x) = $(x) + $(y).
Length of new string is returned in variable A. The variable $(y) could be a quoted string.

Example:

10

STRING 120,40

20 $(0)="First part"
30 $(1)=" Second part"
40 A = STR(6,$(0),$(1))
50

PRINT $(0)

60

PRINT "Length:",A

70 A = STR(6,$(0)," last part")
80

PRINT $(0)

90

PRINT "Length:",A

run
First part Second part
Length: 22
First part Second part last part
Length: 32

Lines 50 and 80 print the concatenated string $(0).

Advertising