- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have run into what seems to be an anomaly in the way that the Visual Studio debugger reports the values of strings that contain nulls. They appear in the debugger as strings of blanks. The following test program runs as expected, but if you set breakpoints and enquire about the value of the string, the final case does not yield the report I would have expected.
Perhaps someone will point out that my debug settings are incorrect and guide me to a solution, or perhaps it will just save someone else the confusion it caused me. (I was confused because, althoughmy code handled blank strings correctly, it didn't handle what "looked like" a blank string correctly.)
program Test_Len_Trim
implicit none
Integer intLength
Character*8 strTest
strTest = ' a b ' ! Appears in debugger as ' a b '.
intLength = Len_Trim(strTest)
Write(6,*) Len(strTest), intLength
strTest = '' ! Appears in debugger as ' ',
intLength = Len_Trim(strTest) ! as expected.
Write(6,*) Len(strTest), intLength
strTest = Repeat(Char(11),16) ! Appears in debugger as ' ',
intLength = Len_Trim(strTest) ! as seems reasonable.
Write(6,*) Len(strTest), intLength
strTest = Repeat(Char(0),16) ! Appears in debugger as ' ',
intLength = Len_Trim(strTest) ! not as expected.
Write(6,*) Len(strTest), intLength
Pause
end program Test_Len_Tri
m
Cheers,
Randy
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Clarification:
In the third case, the debugger shows a string of Char(11) characters as a series of square boxes, as seems customary for control characters. (It seems that the web site doesn't like to show these characters, so the comment in my copy and paste doesn't reflect the comment that is actually in the code.
Cheers,
Randy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah, the debugger thinks of strings as C strings and stops at a NUL. I'm not sure if this is something we can change. You can examine the variable in the Memory window and see all the bytes.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page