Hello.
Suppose you're collecting data in an array called buffer and it contains "mississippi".
To find at which positions within the array there is an "i" you can use another array, e.g. search_result, and store those positions in it.
Something like this:
Code:search_item="i" cnt=0 for n=0 to 10 if buffer[n]=search_item then search_result[cnt]=n cnt=cnt+1 next n
If you'd look, say, for an "s" then you could replace
search_item="i"
with
search_item="s"
You are making an assumption that the list of constants is known.
I only used the example of "mississippi" as I was unable (by definition) to give the contents of an unknown $tring as an example. It seems that LOOKDOWN, although useful for conversion to decimal, is unsuitable for scanning a string (list) of uncertain contents, where duplication may occur - as would happen with field separators. (Thanks, Bruce).
I don't see any futility.
Why do you say "Too bad" ?
Last edited by electrosys; - 10th January 2011 at 14:17.
Sorry electrosys, I said "too bad" because withyou seem pretty reluctant to use anything other than lookdown. I assume you are looking up constants .... well, because that is what lookdown does. From the manual "LOOKDOWN Search,[Constant{, Constant...}],VarOther methods of searching a string are likewise not being sought.
The reason you were asked where this list comes from, was to see what you were using it for, to see if you really wanted to use Lookdown, or if there were other alternatives that might work better for you.
If you have PBP ver 2.60 arrayread is very nice. Here are a couple examples of how it can be used to parse strings.
http://www.picbasic.co.uk/forum/show...5028#post85028
http://www.picbasic.co.uk/forum/show...8422#post88422
http://www.scalerobotics.com
Bookmarks