Call 64 – find a string in a string, Call 64 – find a string in a string -6, Purpose – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 248: Syntax, Example

Advertising
background image

Publication 1746-RM001A-US-P

15-6 String Functions

CALL 64 – Find a String
in a String

Purpose

Use CALL 64 to find a string within a string. It locates the first occurrence
(position) of this string. This CALL has two input arguments. The first is the string
to be found, the second is the string searched for a match. One output argument is
required. If the number is not zero then a match was located at the position
indicated by the value of the output argument. This routine is similar to the BASIC
INSTR$(findstr$,str$) (example:

L=INSTR$($(1),$(2)

).

Syntax

PUSH [string number to be found]
PUSH [base string number]
CALL 64
POP [match position]

Example

>1

REM EXAMPLE PROGRAM

>10

REM SAMPLE FIND STRING IN STRING ROUTINE

>20

STRING 100,20

>30

$(1) = “456”

>40

$(2) = “12345678”

>50

PUSH 1 : REM STRING NUMBER OF STRING TO BE FOUND

>60

PUSH 2 : REM BASE STRING NUMBER

>70

CALL 64 : REM GET THE LOCATION OF FIRST CHARACTER

>80

POP L

>90

IF (L=0) THEN PRINT “NOT FOUND”

>100 IF(L>0) THEN PRINT “FOUND AT LOCATION”,L

>110 END

READY

>RUN

FOUND AT LOCATION 4

READY

>

Advertising