This can be accomplished using the function StrSearchDelimited . For a general overview of this function please refer to the Silk Performer Help. To parse a string in a reverse direction with StrSearchDelimited, you must replace the left and right delimiter occurrence values with negative values. Using negative values tells the StrSearchDelimited function to begin searching the string from the end, and work towards the beginning in a reverse direction. For example, lets say we have a string defined as follows: sJustTesting := "|12|34|56|78|90|"; If we wanted to return the number 12 from the string, then we would use StrSearchDelimited as normal, like this: StrSearchDelimited(sNormalSearch, sizeof(sJustTesting), sJustTesting, "|", 1, "|", 1, STR_SEARCH_FIRST); This will fill the string sNormalSearch with the value 12, as the function is searching in a forwards direction, capturing the data between the two "|" characters, as seen below: | 12 | 34|56|78|90| To perform the reverse search, you have to use negative values for the left and right delimiters. This is the same as a normal search, except the search is moving backwards. Lets say we want to return the number 90 from the string, examining this in the StrSearchDelimited function below: StrSearchDelimited(sReverseSearch, sizeof(sJustTesting), sJustTesting, "|", -1, "|", -1, STR_SEARCH_FIRST); Having the left delimiter as -1 tells the function to search from the end of the string until the first time the character "|" occurs. The left delimiter -1, tells the function to find the next "|" character from the position defined by the right delimiter. This will fill the string sNormalSearch with the value 90, as the function is searching in a reverse direction. The left and right delimiters pinpointed by this reverse search are shown below: |12|34|56|78 | 90 | Old KB# 18247
↧