Skip to main content
Version: v6.0.0

Find String

Describe

Find the specified content within the string and output the position of the found character (counting from 1). If not found, output 0.

Design principle

Basic concept: a process can contain multiple components (process block, judgment, sub process, etc.), a process block can contain multiple commands, and a command can contain multiple attribute.

Prototype

The command usually consists of "[process block variable]=[module name] [Command Name] (attribute 1, attribute 2,..) "format. Built in commands can default to the module name. The return value of the command is an optional design.

found_result = InStr(sText, sSubText, iPos, bCompare)

Attribute Description

Output to

For uniform output attribute, process block variables are usually used to receive the results after the command is executed. The output attribute is optional, which can be supported or not supported in command design, and can be received or not received in command use.

  • Found_result

Assign the result of the command execution to this variable.

Required Group

In order to enter attribute, developers usually need to make modifications based on the default filling. When the number of attribute lists does not match, an error will be thrown when the command runs.

  • SText: string, default $PrevResult

    The string to be operated on - the string to be searched for

  • SSubText: string, default $PrevResult

    Find Content - What to Find in a String

  • IPos: number, default 1

    Start searching for location - the starting location for searching, where a position of 1 indicates starting from scratch

  • BCompare: boolean, default False

    Case sensitive - When searching for strings, is case sensitive

Command usage

Visualization view

Double click or drag the current command directly into the command list to switch to the default fill of each attribute visible in the attribute panel.

Source Code View

Switch to the source code editor, and you can see the code results of each attribute that has been filled in by default. After modifying the source code, it can be automatically converted to visual results.

found_result = InStr($PrevResult, "", 1, False)

Note: When a required attribute is entered with an empty string and incomplete path, the developer usually needs to modify it according to the actual situation.

Run instance

/************************查找字符串*****************
命令原型:
iRet=InStr(sText,sSubText,iPos,bCompare)
入参:
sText--进行操作的字符串.
sSubText--需要查找的子串.
iPos--从第几个字开始查找.
bCompare--对比字符串时是否区分大小写.
出参:
iRet--函数调用的输出保存到的变量.
注意事项:

***********************************************************/
iRet=InStr("Laiye RPA","RPA",1,True)
TracePrint(iRet)