comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » probable mistake in IDL manual
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: probable mistake in IDL manual [message #10456 is a reply to message #10382] Tue, 02 December 1997 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Saeid Zoonematkermani wrote:
>
> ------
> pro Animals
> animals = 'dog cat duck rabbit dog cat dog'
> i = 0
> cnt = 0
> while (i ne -1) do begin
> i = strpos(animals,'dog', i)
> if (i ne -1) then cnt = cnt + 1
> endwhile
> print, 'Found ',cnt, "occurances of 'dog'"
> end
> ------
>
> When I read it, it struck me as being wrong. I tested it later and it
> seems to have gone into an infinite loop (as I suspected it would). Is it
> some thing VERY obvious that I am missing or is it simply wrong?
>
> I am rather confused about this simple procedure. Any comments would be
> appreciated,

Yep, looks like an infinite loop to me. Needs the following line at
the end of the while loop:

i = i + strlen('dog') ; maybe i = i + 3 is faster ;-)

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Read Message
Previous Topic: pv-wave 5.00,scaling
Next Topic: Pixel Information

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:44:21 PDT 2025

Total time taken to generate the page: 0.55590 seconds