- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I search for a nonprintable control character? Index does not seem to work with CR or LF characters! See code ex: cr = "
"
crlf = " "
bline = TRIM(bline) // crlf(1:2)
iloc = index(bline, cr)
iloc aways returns zero. Whats the trick here? Thanks Bruce
crlf = " "
bline = TRIM(bline) // crlf(1:2)
iloc = index(bline, cr)
iloc aways returns zero. Whats the trick here? Thanks Bruce
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried your statements and on my system it worked correct.
Is bline long enough to hold the extra 2 characters.
bline must contain in your example at least two spaces at the end to work correct. If so, does bline contain a non-printable character at the end, for example a zero value?
This can be checked in the watch window in debug mode by entering bline,x to see the hexadecimal presentation of bline.
Guus
Is bline long enough to hold the extra 2 characters.
bline must contain in your example at least two spaces at the end to work correct. If so, does bline contain a non-printable character at the end, for example a zero value?
This can be checked in the watch window in debug mode by entering bline,x to see the hexadecimal presentation of bline.
Guus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
and
are escape sequences in null-terminated C strings, not Fortran control characters, which are CR = CHAR(13) & LF = CHAR(10).
Having said that, there is nothing wrong with your scrap of code, which works for me, and would when modifed also work for finding CHAR(10) & CHAR(13).
HTH
Alan
Having said that, there is nothing wrong with your scrap of code, which works for me, and would when modifed also work for finding CHAR(10) & CHAR(13).
HTH
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems that you added too much C spice ;-):
Is it better now?
Jugoslav
cr = char(13) crlf = char(13)//char(10) bline = TRIM(bline) // crlf(1:2) iloc = index(bline, cr)
Is it better now?
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another point that occurs to me is that if bline is a null-terminated C-string, one can have all sorts of characters beyond the null that will not be removed by TRIM, hence your crlf(1:2) may not find room to be included in bline.
It's simpler in Fortran.
Alan
It's simpler in Fortran.
Alan
![](/skins/images/2E08A100FB92911314A240D1EAFB2828/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page