Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 118

Advertising
background image

Operating Functions

Chapter 5

5–81

5.10.3.2
String Append (Concatenation) – CALL 61

This routine allows you to append one string to the end of another string.
The CALL expects two string arguments. The first is the string number of
the string to be appended and the second is the string number of the base
string. If the resulting string is longer than the maximum string length, the
append characters are lost. There are no output arguments. This is a string
concatenation assignment. (Example: $(1)=$(1)+$(2)).

u10 STRING 200,20

u20 $(1)=“How are”

u30 $(2)=“you?”

u40 PRINT “BEFORE:”,

u50 PRINT “$1=”,$(1),“ $2=”,$(2)

u60 PUSH 2 :REM STRING NUMBER OF STRING TO BE APPENDED

u70 PUSH 1 :REM BASE STRING NUMBER

u80 CALL 61 :REM INVOKE STRING CONCATENATION ROUTINE

u90 PRINT “AFTER:”,

u100 PRINT “$1=”,$(1),“ $2=”,$(2)

u110 END
uRUN

BEFORE:

$1=How are

$2=you?

AFTER:

$1=How are you?

$2=you?

READY

5.10.3.3
Number to String Conversion – CALL 62

This routine converts a number or numeric variable into a string. You must
allocate a minimum of 14 characters for the string. If the exponent of the
value to be converted is anticipated to be 100 or greater, you must allocate
15 characters. Error checking traps string allocation of less than 14
characters only.

PUSH the value to be converted

PUSH the number of the string to receive the value.

Example:

u10 STRING 100,14

u20 INPUT “ENTER A NUMBER TO CONVERT TO A STRING ”,N u30 PUSH N

u40 PUSH 1: REM CONVERT NUMBER TO STRING 1

u50 CALL 62: REM DO THE CONVERSION

u60 PRINT $(1)

u70 END

5.10.3
String Support Calls
(continued)

Advertising