Call 65: replace a string in a string – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 254

Advertising
background image

Chapter
Call Routines 0–68

12

12 -64

Use this routine to replace a string within a string.

Input and Output Arguments

This routine has three input arguments and no output arguments. The first
input argument is the string number of the new string to replace the old
string. The second input argument is the string number of the old string to
be replaced by the new string. The third input argument is the base string’s
string number.

Syntax

PUSH

string number of the replacement string

PUSH

string number of the string to be replaced

PUSH

base string number

CALL 65

Example

>10 REM SAMPLE OF REPLACE STRING IN STRING

>20 STRING 1000,20

>30 $(0)=“RED-LINES”

>40 $(1)=“RED

>50 $(2)=“BLUE”

>60 PRINT “BEFORE: $0=”,$(0)

>70 PUSH 2 :REM STRING NUMBER OF STRING TO REPLACE WITH

>80 PUSH 1 :REM STRING NUMBER OF STRING TO BE REPLACED

>90 PUSH 0 :REM BASE STRING NUMBER

>100 CALL 65 :REM REPLACE STRING IN STRING ROUTINE

>110 PRINT “AFTER: $0=”,$(0)

>120 END

>RUN

BEFORE: $0=RED-LINES

AFTER: $0=BLUE-LINES

CALL 65: Replace a String
in a String

Advertising