Code center > Darwinbots Program Source Code
search
Zelos:
If I have splited a sentence into arrays is it possible to search trough the arrays for a specefic word/sentence in the arrays, like I split "hi im a human" into "hi"/"im"/"a"/"human" and search for "human" and it tells me its in array 3?
Botsareus:
myerray = split("hi I am a humen", " ")
myerray(3) <> "human" etc etc etc...
PurpleYouko:
Why split it into arrays first?
It's just as easy to search through a string for a section of it.
All you need to do is use the mid function to compare strings.
Example
--- Code: ---Sentence = "Hi. I am a Human!"
Searchstring= "Human"
SentenceLength = len(Sentence)
SearchLength = len(SearchString)
for t = 1 to SentenceLength - SearchLength
test = mid(Sentence, t, SearchLength)
If test = SearchString then
condition = true
exit for
endif
next t
--- End code ---
This loop or something like it will search any length of string for any substring. You could build this into a function which you can call from any point in your program. Unless you have a good reason to convert your sentence into arrays, don't bother.
Zelos:
I hoped there would be a command for it, if it is to loop I can fix it on my own
PurpleYouko:
Sorry, no shortcuts that I am aware of.
Navigation
[0] Message Index
[#] Next page
Go to full version