Searches for an occurrence of a string in a buffer and saves a portion of the buffer after that string to a parameter.
int lr_save_searched_string( const char *buffer, long buf_size, unsigned int occurrence, const char *search_string, int offset, unsigned int string_len, const char *parm_name );
|Example: lr_save_searched_string||String and Parameter Functions|
|buffer||The STRING or CARRAY buffer, part of whose contents you want to save.|
|buf_size||The buffer size.|
|occurrence||The occurrence number of the search_string (0-based count). For example, if the search_string occurs three times, and you want the second occurrence, set occurrence to 1.|
|search_string||The string to search for in the buffer.|
|offset||The number of characters to skip after the end of the search string occurrence.|
|string_len||The number of characters to save.|
|parm_name||Parameter name to be used in subsequent lr statements to refer to the saved information. Name is enclosed in double-quotes.|
The lr_save_searched_string function searches for string search_string inside string or character array buffer, and finds the nth occurrence of search_string, where n is occurrence plus 1. The sub-string to be saved starts at offset after the end of the nth occurrence of search_string, and has length string_len.
char cBuff = "abc Emma Woodhouse abc Elizabeth Bennet abc William Price"; lr_save_searched_string(cBuff, strlen(cBuff), 2, "abc",// Search for third occurrence of "abc" 1, // Skip the space after "abc" 4, // Put the next four characters... "Fannys_brother"); // ... in parameter Fannys_brother.
After the call, the content of parameter Fannys_brother is “Will”.
The search_string cannot contain null characters, but the buffer can contain null characters.
Use the lr_save_string function to save strings from character arrays. Use lr_save_searched_string only when you need to save a portion of a character array relative to a string occurrence.
This function returns LR_PASS on success, and a negative value on failure.
You cannot use standard parameterization for any arguments in this function.