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

Page 120

Advertising
background image

Operating Functions

Chapter 5

5–83

5.10.3.5
Find a String in a String – CALL 64

This routine finds a string within a string. It locates the first occurrence
(position) of this string. This call expects two input arguments . The first is
the string to be found, the second is the string to be searched for a match.
One return argument is required. If the number is not zero then a match
was located at the position indicated by the value of the return argument.
This routine is similar to the BASIC INSTR$(findstr$,str$). (Example:
L=INSTR$($(1),$(2))

u10 REM SAMPLE FIND STRING IN STRING ROUTINE

u20 STRING 1000,20

u30 $(1)=“456”

u40 $(2)=“12345678”

u50 PUSH 1 :REM STRING NUMBER OF STRING TO BE FOUND

u60 PUSH 2 :REM BASE STRING NUMBER

u70 CALL 64 :REM GET LOCATION OF FIRST CHARACTER

u80 POP L

u90 IF L=0 THEN PRINT “NOT FOUND”

u100 IF Lu0 THEN PRINT “FOUND AT LOCATION ”,L

u110 END
uRUN

FOUND AT LOCATION 4

READY

5.10.3
String Support Calls
(continued)

Advertising