InstrRev

String management function.

The InstrRev function returns the position of a substring within the specified string, searching backward through the string.

Usage

Mainly used to extract a substring from one string. For example, InstrRev function can be used to extract the path from a long filename. See the example below.

Syntax

pos=InstrRev(<target_string>,<search_string>)

Parameters

<target_string>, string to be searched

<search_string>, string to search for, searching backward

Return value

Pos returns the position where the search string was found, starting from the beginning, with a backward search through the string. If the search string is not found in the target string, 0 is returned; if <target_string> or <search_string> are empty, 0 is also returned.

See also

Instr

Examples

 

a$="Hello WinTask, Hellobis"

pos=InstrRev(a$,"Hello")

msgbox(pos) ' returns 16

'Path extraction of a long filename including its path

pos=InstrRev("c:\program files\wintask\scripts\my_script.rob","\")

msgbox(pos)

path$=left$("c:\program files\wintask\scripts\my_script.rob",pos)

msgbox(path$)