Dumb problem with STRPOS [message #4738] |
Fri, 14 July 1995 00:00 |
steele
Messages: 5 Registered: March 1994
|
Junior Member |
|
|
Can someone explain the following behaviour to me?
IDL> help,/st,!version ; Here's the situation.
** Structure !VERSION, 3 tags, length=24:
ARCH STRING 'mipseb'
OS STRING 'RISC/os'
RELEASE STRING '3.1.0'
IDL> test='c000.' ; define a string
IDL> help,test ; check it is a string
TEST STRING = 'c000.'
IDL> print,strpos(test,'000') ; search for a substring
1
IDL> print,strpos(test,'000.') ; and a slightly different one
1
IDL> test='c0000.' ; add a '0'
IDL> help,test
TEST STRING = 'c0000.'
IDL> print,strpos(test,'000') ; search again
1
IDL> print,strpos(test,'000.') ; Why isn't this substring found???
-1
I checked the manual for this version and it says nothing that would
explain this. BTW, it's nothing to do with octal constants.
All suggestions gratefully received!
Dave
--
David Steele | Internet : steele@aragorn.phys.ucalgary.ca
Dept. of Physics and Astronomy | SPAN : CANCAL::STEELE
The University of Calgary | Phone : +1 403 220 8651
OPINIONS EXPRESSED WITHIN ARE MY OWN AND NOT THOSE OF THE UNIVERSITY OF CALGARY
|
|
|
Re: Dumb problem with STRPOS [message #4742 is a reply to message #4738] |
Fri, 14 July 1995 00:00  |
steele
Messages: 5 Registered: March 1994
|
Junior Member |
|
|
In article <3u6g67$usi@ds2.acs.ucalgary.ca>, I wrote:
|> Can someone explain the following behaviour to me?
|> [snip]
|> IDL> test='c0000.' ; add a '0'
|> IDL> help,test
|> TEST STRING = 'c0000.'
|> IDL> print,strpos(test,'000') ; search again
|> 1
|> IDL> print,strpos(test,'000.') ; Why isn't this substring found???
|> -1
To add further spice:
IDL> test='c00000.' ; Add a further '0'
IDL> print,strpos(test,'000') ; Search again
1
IDL> print,strpos(test,'000.') ; This time it works!
3
IDL> test='c10000.' ; But if I add a '1' instead,
IDL> print,strpos(test,'000') ; this still works,
2
IDL> print,strpos(test,'000.') ; and this still doesn't!
-1
Does anyone have a glimmer? Anyone at RSI listening?
Dave
--
David Steele | Internet : steele@aragorn.phys.ucalgary.ca
Dept. of Physics and Astronomy | SPAN : CANCAL::STEELE
The University of Calgary | Phone : +1 403 220 8651
OPINIONS EXPRESSED WITHIN ARE MY OWN AND NOT THOSE OF THE UNIVERSITY OF CALGARY
|
|
|