Hi chihuahualand,
chihuahualand wrote:This is a clean (and recent) WINXP MCE SP3 install. I am running MS v7.4.009. The MS is fairly dated, but, it does everything I need it to do.
It seems to be directly related to stepping through the program (F8), so it's easily managed.
It must be something with that old 7.4.009 version because it works fine for me in 11.1.04 even when single stepping in the debugger.
I went back and played with your original code as posted and generated the same error:
error wrote:Microsoft VBScript compilation error :1033
Unterminated string constant
Line 4, Column 3
That happened at the point where it tried to pass a null character to your VBscript function... evidently VBscript does not like that. I am not sure it if is possible to "escape" the null character and pass it anyway, probably not... but if anyone knows how, please fill us in.
chihuahualand wrote:I'm reading the Volume Info on a DVD.
%info_2% returns with the information, but, all attempts to trim this variable (from length 255) have failed.
Various VBEvals, LET's, StringReplace, IF's have failed.
I assume the string is null terminated, but, I can't replace the null character.
I tried this too and all I can say is...
I feel your pain. I did manage to get it down from 255 chars to 245 chars by removing spaces... but the null characters (there are 124 of them in that variable) could not be removed or replaced by any method I tried.
The following section from this post:
removing trailing ascii(0) made me think it was possible...
mtettmar wrote:0 is a null char. It normally marks the end of a string.
But, you could try:
VBSTART
VBEND
VBEval>CHR(0),NullChar
StringReplace>text,NullChar,,text
...but the Length> command showed the variable length as 255 both before and after doing the above so there was no effect.
Sidenote: Marcus... is the StringReplace> command "supposed" to be able to replace null characters within a variable? If so it doesn't but perhaps its just not possible.
Try the code below... preferably single stepping through it in the debugger. It shows an interesting limitation of the MDL> command when displaying variables containing the null character CHR(0).
Note: My DVD drive was at F:\
Before running this, change F:\ in the LinFunc> line below to whatever drive letter you are interested in.
Code: Select all
VBSTART
VBEND
VBEval>CHR(0),NullChar
// GetVolumeInformation Function: http://msdn.microsoft.com/en-us/library/aa364993(VS.85).aspx
LibFunc>kernel32,GetVolumeInformationA,info,F:\,str REF:0,200,REF:0,REF:0,REF:0,str REF:0,255
// At this point, the following variables have been created:
// INFO_1 contains RootPathName
// INFO_2 contains VolumeNameBuffer
// INFO_3 contains VolumeNameSize
// INFO_4 contains VolumeSerialNumber
// INFO_5 contains MaximumComponentLength
// INFO_6 contains FileSystemFlags
// INFO_7 contains FileSystemNameBuffer
// INFO_8 contains FileSystemNameSize
// I wanted to display them all but this does not work, only the 1st is shown
MDL>%INFO_1% %INFO_2% %INFO_3% %INFO_4% %INFO_5% %INFO_6% %INFO_7% %INFO_8%
// I believe this is because the MDL> command quits after it runs into a null character.
// Many of the above variables actually contain multiple null characters.
// Any attempts to remove or replace the null characters in the above variables failed...
// but if someone else can manage it... I'd love to see it.
// The Separate> command however can separate out all the data between the null characters
// (leaving the null characters behind) and we can then display the values all at once.
Separate>%info_1%,%NullChar%,var1
Separate>%info_2%,%NullChar%,var2
Separate>%info_3%,%NullChar%,var3
Separate>%info_4%,%NullChar%,var4
Separate>%info_5%,%NullChar%,var5
Separate>%info_6%,%NullChar%,var6
Separate>%info_7%,%NullChar%,var7
Separate>%info_8%,%NullChar%,var8
// This works
MDL>%var1_1% %var2_1% %var3_1% %var4_1% %var5_1% %var6_1% %var7_1% %var8_1%
Let>MSG_HEIGHT=230
// With parameter names
MDL>RootPathName: %var1_1%%CRLF%VolumeNameBuffer: %var2_1%%CRLF%VolumeNameSize: %var3_1%%CRLF%VolumeSerialNumber: %var4_1%%CRLF%MaximumComponentLength: %var5_1%%CRLF%FileSystemFlags: %var6_1%%CRLF%FileSystemNameBuffer: %var7_1%%CRLF%FileSystemNameSize: %var8_1%
And here's another way to do it... without using the Separate> command:
Code: Select all
VBSTART
VBEND
VBEval>CHR(0),NullChar
// GetVolumeInformation Function: http://msdn.microsoft.com/en-us/library/aa364993(VS.85).aspx
LibFunc>kernel32,GetVolumeInformationA,info,C:\,str REF:0,200,REF:0,REF:0,REF:0,str REF:0,255
// At this point, the following variables have been created:
// INFO_1 contains RootPathName
// INFO_2 contains VolumeNameBuffer
// INFO_3 contains VolumeNameSize
// INFO_4 contains VolumeSerialNumber
// INFO_5 contains MaximumComponentLength
// INFO_6 contains FileSystemFlags
// INFO_7 contains FileSystemNameBuffer
// INFO_8 contains FileSystemNameSize
//there's no null characters in info_4
Let>VolumeSerialNumber=info_4
//extract the data from info_2 leaving the null characters behind
Let>VolumeName=
Let>char_position=0
Label>Loop
Let>char_position=char_position+1
MidStr>info_2,char_position,1,one_char
If>one_char=NullChar,display_values
ConCat>VolumeName,one_char
Goto>Loop
Label>display_values
// display VolumeName and VolumeSerialNumber in one MDL>
MDL>VolumeName: %VolumeName%%CRLF%VolumeSerialNumber: %VolumeSerialNumber%
Finally, a challenge for the gurus out there - a bounty on null character string cleansing.
2 points goes to the first person who can take the script below and add code to strip out the null characters and any other characters not part of the actual VolumeName data in the info_2 variable... i.e. if the first MDL> shows
VolumeName: My_Disk then the info_2 variable should actually be 7 chars long and the second MDL> should show
VolumeName Length: 7
- without using the Separate> command
- without resorting to using a command like MidStr> to extract a single character substring and comparing it to a NullChar variable... over and over throughout the string like in the example above
- anything else is allowed, RegEx, StringReplace>, VBscript, etc.
- Marcus, if you have a solution, please wait until the others have had a chance
Code: Select all
LibFunc>kernel32,GetVolumeInformationA,info,C:\,str REF:0,200,REF:0,REF:0,REF:0,str REF:0,255
MDL>VolumeName: %info_2%
Length>info_2,Length_info_2
MDL>VolumeName Length: %Length_info_2%