probable mistake in IDL manual [message #10382] |
Fri, 28 November 1997 00:00  |
szoonem
Messages: 16 Registered: June 1995
|
Junior Member |
|
|
Hi,
I was reading "Building IDL Applications" manual (version 5) and noticed
the procedure on p. 76 which is supposed to count the number of times that
the word "dog" appears in the string "dog cat duck rabbit dog cat dog";
------
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,
- Saeid
------------------------------------------------------------ -----
| Saeid Zoonematkermani | E-Mail: szoonem@astro.sunysb.edu |
| Dept. of Physics & Astronomy | Voice: (+1) (516) 632-8237 |
| State University of New York | Fax: (+1) (516) 632-8742 |
| Stony Brook, NY 11794-3800 | |
------------------------------------------------------------ -----
| Home Page --> http://ozone.ess.sunysb.edu/ |
------------------------------------------------------------ -----
|
|
|