Call 68 – find the length of a string, Call 68 – find the length of a string -10, Purpose – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 252: Syntax, Example

Advertising
background image

Publication 1746-RM001A-US-P

15-10 String Functions

CALL 68 – Find the
Length of a String

Purpose

Use CALL 68 to determine the length of a string. One input argument is expected.
This is the string number on which the routine acts. One output argument is
required. It is the actual number of non-carriage return (CR) characters in this
string. This is similar to the BASIC command LEN(str$) (example:

L=LEN($l)

).

The length of the string can be properly determined only if the string is terminated
with a CR character. If a string is filled using the ASC instruction, a CR must be
added as the last character to terminate the string.

Syntax

PUSH [string number]
CALL 68
POP [number of characters]

Example

>1

REM EXAMPLE PROGRAM

>10 REM SAMPLE OF STRING LENGTH

>20 STRING 1 0,10

>30 $(1) = “1234567”

>40 PUSH 1 : REM BASE STRING

>50 CALL 68 : REM INVOKE STRING LENGTH ROUTINE

>60 POP L : REM GET LENGTH OF BASE STRING

>70 PRINT “THE LENGTH OF ”,$(1),“ IS”,L

>80 END

READY

>RUN

THE LENGTH OF 1234567 IS 7

READY

>

Advertising