07-24-2023, 06:35 AM
I've been coding in the WSH for a couple days now and just recently the `WScript.Echo()` method started to only print parts of the string or it would put the end of the string at the beginning so that it's jumbled. I'm using Win7 pro x64. This is the function that contains the broken `Echo()` method:
function age() {
if ( !/\d*/.test(specimen[AGE]) || !/\d*/.test(comp[AGE]) ) {
WScript.Echo('ERROR: age value for specimen or comp not valid')
WScript.Sleep(10000);
WScript.Quit();
}
WScript.Echo("specimen[AGE] = ", specimen[AGE], " and comp[AGE] = ", comp[AGE])
ageAdjValue = ( parseInt(specimen[AGE]) * 250) - ( parseInt(comp[AGE]) * 250)
adjArray[AGE] = ageAdjValue;
//log adjArray
for (i=0; i < adjArray.length; i++) {
WScript.Echo(adjArray[i])
}
}
This is the output:
and comp[AGE] = 12
SKIP
SKIP
SKIP
SKIP
SKIP
0
0
?
0
0
0
2500
0
0
The message at the top doesn't include the specimen[AGE] part, instead it has blank space.
Now to see if it was because of what was contained in the specimen[AGE] element, I changed it to specimen[ADDRESS] like this:
WScript.Echo("specimen[AGE] = ", specimen[ADDRESS], " and comp[AGE] = ", comp[AGE])
This was the new output:
and comp[AGE] = 12ings Ct.
SKIP
SKIP
SKIP
SKIP
SKIP
0
0
?
0
0
0
2500
0
0
It put the address at the end instead of the beginning and only printed part of the address...
I then noticed that in the string preceding `specimen[ADDRESS]`, the string didn't match up with the variable... and for the hell of it I changed it to "specimen[ADDRESS]" to match, like this:
WScript.Echo("specimen[ADDRESS] = ", specimen[ADDRESS], " and comp[AGE] = ", comp[AGE])
Now I am completely clueless why... but the output changed to include 2 extra characters of the full address at the end...
and comp[AGE] = 1263 Kings Ct.
SKIP
SKIP
SKIP
SKIP
SKIP
0
0
?
0
0
0
2500
0
0
The same thing happens when I use the `+` operator to concatenate the strings instead of commas. What could be causing this?
function age() {
if ( !/\d*/.test(specimen[AGE]) || !/\d*/.test(comp[AGE]) ) {
WScript.Echo('ERROR: age value for specimen or comp not valid')
WScript.Sleep(10000);
WScript.Quit();
}
WScript.Echo("specimen[AGE] = ", specimen[AGE], " and comp[AGE] = ", comp[AGE])
ageAdjValue = ( parseInt(specimen[AGE]) * 250) - ( parseInt(comp[AGE]) * 250)
adjArray[AGE] = ageAdjValue;
//log adjArray
for (i=0; i < adjArray.length; i++) {
WScript.Echo(adjArray[i])
}
}
This is the output:
and comp[AGE] = 12
SKIP
SKIP
SKIP
SKIP
SKIP
0
0
?
0
0
0
2500
0
0
The message at the top doesn't include the specimen[AGE] part, instead it has blank space.
Now to see if it was because of what was contained in the specimen[AGE] element, I changed it to specimen[ADDRESS] like this:
WScript.Echo("specimen[AGE] = ", specimen[ADDRESS], " and comp[AGE] = ", comp[AGE])
This was the new output:
and comp[AGE] = 12ings Ct.
SKIP
SKIP
SKIP
SKIP
SKIP
0
0
?
0
0
0
2500
0
0
It put the address at the end instead of the beginning and only printed part of the address...
I then noticed that in the string preceding `specimen[ADDRESS]`, the string didn't match up with the variable... and for the hell of it I changed it to "specimen[ADDRESS]" to match, like this:
WScript.Echo("specimen[ADDRESS] = ", specimen[ADDRESS], " and comp[AGE] = ", comp[AGE])
Now I am completely clueless why... but the output changed to include 2 extra characters of the full address at the end...
and comp[AGE] = 1263 Kings Ct.
SKIP
SKIP
SKIP
SKIP
SKIP
0
0
?
0
0
0
2500
0
0
The same thing happens when I use the `+` operator to concatenate the strings instead of commas. What could be causing this?