Hitachi

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


8.3.2 InArray (find the position of a string in an array variable)

Purpose

Searches for a specified string among the elements in a specified array variable, and returns the index number of the first occurrence.

Syntax
InArray (ArrayName, SearchStr, [Start] [, Compare])
Arguments
ArrayName

Specify the array variable to search as a variable name.

Zero is returned if the specified array variable has no elements.

SearchStr

Write the search string 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 in the specified array variable at which to begin the search. Specify the start position as an index number or as a variable that stores this value.

Zero is returned if the start position exceeds the number of elements in the array variable set in ArrayName.

This value is optional. If you omit this value, the first element 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 InArray command searches for a specified string among the elements of a specified string and returns the index number (number from 1) of the first occurrence. Zero is returned if no matching string is found.

Example 1

Search for specified data from the array variable closeDay, which contains the following values:

[Figure]

Dim closeDay(3,12)
    ...
' (Store the values in array variable closeDay.)
    ...
monthName = "March"
buff = InArray (closeDay(1), monthName, 1, False)
If buff > 0 Then
  firstDay = closeDay(2,buff)
  MessageBox ("First non-working day of" +monthName+ _
              "is" +firstDay+".")
End If
Example 2
' Search for specified data among all the elements of a
' two-dimensional array variable.
Dim array1(,)
    ...
' (Store the values in array variable array1.)
    ...
allCnt = GetArrayCount (array1)
For line = 1 To allCnt
  buff = InArray (array1(line), "1999", 1, False)
  If 0 < buff Then
    Exit For
  End If
Next
JP1/Script version

Supported from JP1/Script 06-00.