These functions will search for the criteria, which were earlier associated with the find data specified by the given ID (see SetBufFind()). Depending on the called function the search will be performed in forward or reverse direction but in both cases starting at the current buffer position. If the criteria is found, then the found position is returned and it will also automatically become the new current buffer position. If the criteria is otherwise not found, then zero (0) is returned and the current buffer position remains unchanged. The returned position remains valid until you write or delete data in the respective buffer. Be also aware of (negative) error returns.
For a sequential search to find all occurrences of the criteria in the buffer, you simply call the same direction search function ever again until you get no more hits. Different from INSTR, you don't need to manually displace the start position by 1 byte for the next call to avoid finding the same occurrence again, as the buffer keeps track of the last found occurrence and will do this automatically as required.
SYNTAX:
found& = FindBufFwd& (buf$(), findID%, method%, treat%) found& = FindBufRev& (buf$(), findID%, method%, treat%)
INPUTS:
buf$() (STRING array)
- This is the array of any existing and initialized buffer, in which you wanna search the specified data.
findID% (INTEGER)
- Any ID number in the range 1 to 100, which identifies the desired find data.
method% (INTEGER)
- This flag determines how to use the specified find data, ie. how the search shall actually be performed. It should be one of the flags defined in the stringbuffer.bi file (see also below).
treat% (INTEGER)
- This flag determines how to treat any lower/upper case differences in the search criteria and the searched buffer data. It should be one of the flags defined in the stringbuffer.bi file (see also below).
RESULT:
found& (LONG)
- Either the found position on success, or zero (0), if no more occurrences of the specified find data were found.
- If the return value is negative, then it is any of the error numbers defined in the stringbuffer.bi file (see also Common-Info).
METHOD FLAGS:
SBF_FullData
- Do a regular search for the specified criteria, hence use the find data in whole (ie. look for the string as given via SetBufFind() in its entire form).
SBF_Delimiter
- Make a delimiter search, hence the specified find data are not directly used as a string, but as a list of delimiter chars to look for. The function returns as soon as any of the listed delimiter chars is found.
SBF_InvDelimiter
- Make a inverse delimiter search. As for the above, the specified find data are used as a list of delimiter chars, but here the function returns as soon as any char is found, which is not listed as delimiter.
TREATMENT FLAGS:
SBF_AsWritten
- Simply treat all find data and buffer data as is, hence "Foo" <> "foo".
SBF_IgnoreCase
- Use this flag to ignore the written case of all data, hence "Foo" = "foo".