Hitachi

JP1 Version 11 JP1/Script Description and Reference (For Windows Systems)


8.3.1 InStr (find the position of a substring in a string)

Purpose

Searches for a specified substring in a specified string and returns the character position (number of characters from the beginning of the string) of the first occurrence of the substring.

Syntax
InStr (String, SearchStr, [Start] [, Compare])
Arguments
String

Write the string to search as a character string or as a variable that stores this value.

Zero is returned if you specify a zero-length string ("").

SearchStr

Write the search substring as a character string or as a variable that stores this value.

Zero is returned if you specify a zero-length string ("").

Start

Specify the position at which to begin the search as the offset from beginning of the string you set in String, where 1 is the first character.

Zero is returned if the Start value exceeds the number of characters in String.

This value is optional. If you omit this value, 1 is assumed.

Compare

Specify how to perform string comparisons. Use one of the following values:

Value

Meaning

True

Perform case-sensitive comparison.

False

Perform case-insensitive comparison.

Twice

Perform case-insensitive comparison for one-byte characters, and case-sensitive comparison for two-byte characters.

This value is optional. If you omit this value, Twice is assumed.

Description

The InStr command searches for a specified substring in a specified string and returns the character position (number of characters from the beginning) of the first occurrence. One two-byte-character and one one-byte-character are both handled as one character. Zero is returned if no matching string is found.

Example
' This code stores 16 in variable point1.
Dim point1
point1 = InStr ("Search file in ABC order", "abc", 3, False)
JP1/Script version

Supported from JP1/Script 05-00.