String Function ReverseFind() not working as intended


Recommended Posts


I have been trying to use the string function "ReverseFind()" to find the location of a specific character from the right hand side of a string.

In the Help section of DaqFactory I got the following example:


1. The Help states that the above function will return 2. This is not true because of the argument ",0" added to the function. The function as stated in the example does not actually execute because the function should take only two arguments ReverseFind(String,Char to find).

2. When the ",0" is removed and the sequence ReverseFind("abcdef","cd") is executed it returns 2. At the first look, this might seem to be correct but it is not.

3.When I added extra characters before the "c" in the string and executed the sequence

ReverseFind("abrqcdef","cd"), it returns 4 instead of 2 as expected. This result is similar to running the sequence Find("abrqcdef","cd",0).

Am I doing something wrong here or it's actually the function that malfunctioning?

Link to comment
Share on other sites

1) The help has a typo here, probably because the sample was copied from the normal find() function. As you saw, with the extra 0 it doesn't return anything.

2) 2 is the correct result. "c" starts at character 2. Remember, everything is numbered from 0 in computers.

3) again, 4 is correct

Just to be clear, reversefind() searches from the right, but it still returns the character # counting from 0 from the LEFT, not the right. So:


returns 5, the character number for the second e.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.