Call 65 – replace a string in a string, Call 65 – replace a string in a string -7, Purpose – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 249: Syntax, Example

Advertising
background image

Publication 1746-RM001A-US-P

String Functions 15-7

CALL 65 – Replace a
String in a String

Purpose

Use CALL 65 to replace a string within a string. Three arguments are expected.
The first argument is the number of the string that replaces the string identified by
the second argument string number. The third argument is the base string number.
There are no output arguments.

Syntax

PUSH [new string number]
PUSH [old string number to be replaced]
PUSH [base string number]
CALL 65

Example

>1

REM EXAMPLE PROGRAM

>10

REM SAMPLE OF REPLACE STRING IN STRING

>20

STRING 100,20

>30

$(0) = “RED-LINES”

>40

$(1) = “RED”

>50

$(2) = “BLUE”

>60

PRINT “BEFORE:”

>70

PRINT “$(0) = ”,$(0)

>80

PUSH 2 : REM STRING NUMBER OF THE STRING

TO BE REPLACED WITH

>90

PUSH 1 : REM STRING NUMBER OF THE STRING TO BE REPLACED

>100 PUSH 0 : REM BASE STRING NUMBER

>110 CALL 65 : REM INVOKE REPLACE STRING IN STRING

>120 PRINT “AFTER:”

>130 PRINT “$(0) = ”,$(0)

>140 END

READY

>RUN

BEFORE:

$(0) = RED-LINES

AFTER:

$(0) = BLUE-LINES

READY

>

IMPORTANT

If the new string length exceeds the length allocated by the string
command, an error message is printed on the console device and
the module enters Command mode.

Advertising