- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using the INDEX function to test whether a file name includes particular file extensions, e.g. '.exe' of '.lst'
I have discovered that the file extension '.hds' does not appear to be recognised.
i.e. when filein = 'name.hds'
the statement
ipos = index(filein,'hds')
returns a value of 0.
For the case when filein = 'name.exe' or 'name.lst' the function correctly returns a value of 9. When filein = 'name.xxx' a value of 0 is returned.
Do the substrings 'hds' and 'xxx' have some particular status? How can this apparent anomaly be corrected?
character string
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not aware of any special status for these strings. Could you post a complete example demonstrating this? As I have never seen anything like that, I suspect there is something else going on. A small program to reproduce the issue will help to unravel the mystery.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Commonly, in such cases the culprit is a non-printable character embedded in the string. For example, if there is such a character between '.h' and 'ds', the actual string is not the same as the printed version or as seen in a screen editor. Therefore, when you post your example code, be sure to provided the actual file as an attachment instead of pasting the code or text in the post itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The apparent problem turned out to be the result of a programming error on my part which was revealed in the process of creating a small demonstration program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is not at all uncommon ;). It happens to everyone.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page