Author Topic: search  (Read 4034 times)

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
search
« on: November 02, 2005, 10:09:33 AM »
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?
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
search
« Reply #1 on: November 02, 2005, 10:48:49 AM »
myerray = split("hi I am a humen", " ")

myerray(3) <> "human" etc etc etc...

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
search
« Reply #2 on: November 02, 2005, 11:38:07 AM »
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: [Select]
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
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.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
search
« Reply #3 on: November 02, 2005, 01:35:38 PM »
I hoped there would be a command for it, if it is to loop I can fix it on my own
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
search
« Reply #4 on: November 02, 2005, 01:59:35 PM »
Sorry, no shortcuts that I am aware of.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
search
« Reply #5 on: November 02, 2005, 02:11:50 PM »
its ok, ive already solved it, thx anyway
why I want to split it is cause im gonna use it in cell, the dna tells how the cell looks and I want to be able to show it before it and then I need to isolate the gene that contain birth appherens
« Last Edit: November 02, 2005, 02:12:48 PM by Zelos »
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA