This function will take two strings and search the first string for the second one. It returns a 1 if the string is found, and a 0 if it is not. The third variable is the Case Flag, when set to 0 the function is not case sensitive, any other value will make it Case Sensitive. Please note that this function was made for text adventures, so essentially it searches a sentence for a word and it will not find the search string if it doesn't have spaces around it. Example: Searching "I like cheese" for "like" will return a 1, while searching "Ilikecheese" for "like" will return 0. This is useful if, for example, you don't want the user to input "Feast" and have the character go "East" instead. Various kinds of punctuation are counted as spaces.
SYNTAX: Return Integer=Search(Search this string,Search for this string,Case Flag)
function Search(Input$,Search$,CaseFlag) Input$=Input$+" " If CaseFlag=0 Input$=lower$(Input$) Search$=lower$(Search$) endif For a=1 to Len(Input$) currentchar$=mid$(Input$,a) if currentchar$=" " or currentchar$="," or currentchar$="." or currentchar$="/" or currentchar$="-" or currentchar$="_" or currentchar$="?" or currentchar$="!" if currentword$=Search$ exitfunction 1 else currentword$="" endif else currentword$=currentword$+currentchar$ endif Next a endfunction 0