Re: find or equal test problem
- Posted by sixs <sixs at ida.net> May 26, 2005
- 400 views
Thanks for the advice from all. I am trying to find words in a listing or letter document . I can see how to find a comma in a line, but I was trying to find a word like "pickle" in a line of information. I have created HTML code, found a single character ">" and then compared what was in buffer[found location], length of expected value. I thought that I might find a simple way to do it. If you have any advice I would appreciate it! Thanks Jim Derek Parnell wrote: > > >posted by: Derek Parnell <ddparnell at bigpond.com> > >sixs wrote: > > >>Hi, >>I can't figure what the pproblem is in this program. I try to find the >>letter "p" in the sequence pp. I see that the value is 112 for p . >>I have used the find and equal command before but i don't know what i'm >>not doing >> >> >When you write a string in the form "xyz", you are actually coding a sequence >of three integers. "xyz" is exactly the same as {'x', 'y', 'z'}. > >So with > > pp = { "pickle" } > >it is the same as > > pp = { {'p', 'i', 'c', 'k', 'l', 'e'} } > >thus the line > > location = find( "p", pp) > >is the same as > > location = find( {'p'}, { {'p', 'i', 'c', 'k', 'l', 'e'} }) > >and as you can see, the variable pp does not contain an element that looks like >{'p'} as it only contains one element and that is a sequence of six integers >(letters). > >To find a single letter inside a string, use find like this ... > > a = find('x', string) > >Note that the X is in single quotes and not double quotes, as that would mean >you are looking for a string as *one* of the elements of the target. > >Try the amended code below ... > >}}} <eucode> >object line >integer location > >procedure process() > sequence pp > > pp = "pickle" > > location = find('p', pp) > if equal(location, 1) then > line = pp > else > line = " " & pp > end if >end procedure >process() ></eucode> {{{ > >