PDA

View Full Version : searching for a word :)



Lionheart008
11-05-2009, 23:45
good evening, have tried and built this little script and if you like it to search for a word, you can use it... theme: stringmanipulation, my 5 cent for today... ;)


'-- lionhearts testscript for searching a word, part one, 11.april.2009

uses "console", "UI"

dim scoreahit as integer
dim searchposition as integer
dim textinfo as string
dim searchword as string

console_writeline ("-- to score a hit example, simple version --")
printl

textinfo = "superman batman hulk, spiderman superman batgirl, x-men superman robin, wolverine asterix obelix, superman incredible hulk mywoman"
searchword = "superman"

printl
printl ("textpool is: " + textinfo)
printl
printl ("we are looking for: " + searchword)
printl

do
scoreahit = instr(searchposition+1,textinfo,searchword)
if scoreahit > 0 then
printl "Position of searching word is: " & scoreahit
end if
searchposition = scoreahit + len(searchword) -1
loop until scoreahit=0
sleep 200

console_writeline
console_writeline ("ok, push a key to end this fantastic script")

waitkey

:D

ciao, Lionheart

kryton9
12-05-2009, 02:22
Nice example Lionheart. Few lines of code and it does quite a bit, the power of thinBasic!