07-24-2023, 06:47 AM
I'm trying to convert an array value that contains a path to a string. I want to do this because I want to use the regex `.replace` method to get rid of the large part of the path and leave just the file and its containing folder. I thought the path in the array was a string but `.replace` won't work on it, though it works fine converting `555` to `666`.
The program prints out arrayValue fine but when I put the `.toString()` on it it throws an error (which I can't read because the console immediately closes and I don't know how to make it pause for an exception).
for (i=0; i < dirArrays.length; i++) {
fileIsThere = false;
for (k=0; k < dirArrays[i].length; k++) {
arrayValue = dirArrays[i][k];
x = 555
WScript.Echo('dirArrays[' + i + '][' + k + '] = ' + x.toString() + ' ' + x.toString().replace(/5/g, '6') + ' ' + arrayValue.toString() )
if ( /replacedData.txt$/.test(dirArrays[i][k]) ) {
fileIsThere = true;
break;
}
}
if (!fileIsThere) {
throw 'replacedData.txt missing from \mls_num_' + i
}
}
The program prints out arrayValue fine but when I put the `.toString()` on it it throws an error (which I can't read because the console immediately closes and I don't know how to make it pause for an exception).
for (i=0; i < dirArrays.length; i++) {
fileIsThere = false;
for (k=0; k < dirArrays[i].length; k++) {
arrayValue = dirArrays[i][k];
x = 555
WScript.Echo('dirArrays[' + i + '][' + k + '] = ' + x.toString() + ' ' + x.toString().replace(/5/g, '6') + ' ' + arrayValue.toString() )
if ( /replacedData.txt$/.test(dirArrays[i][k]) ) {
fileIsThere = true;
break;
}
}
if (!fileIsThere) {
throw 'replacedData.txt missing from \mls_num_' + i
}
}