Verify date in text file
Good day
I hope there is somebody that can help please ?
I have the following code that finds a text file exported by the tested application and reads a certain part of the file. This part is a date in yymmdd format in the text file exported from the tested application. There are no slashes or anything separating the date. It looks like this 150506
This date in the file should always be two days from today. So if the export is done today eg. 2015-05-06 , the date in the file should be 150508. The date in the file is located in line 3 column 59 to 64.
Could someone please help me to verify this date in the file ?
Herewith the script. This is script that I got from a previous post. I would like to add the verify part to this script. I would also like to get some sort of confirmation that the date is indeed two days from today and if not I would like to get confirmation of that as well please.
Thank you in advance
Wynand
function main(){
readfile("C:\\FolderName\\", "Name_Of_File_*_*");
}
function readfile(directory,filename){
var foundFiles = aqFileSystem.FindFiles(directory, filename);
if (foundFiles != null) {
if (foundFiles.Count == 1) {
var sPath = foundFiles.Next().Path;
ReadDateFromFile(sPath);
}
else {
Log.Error("More than 1 file found.");
}
}
else {
Log.Error("File not found.");
}
}
function ReadDateFromFile(sPath){
var sPath = sPath;
// Opens the specified file for reading
var myFile = aqFile.OpenTextFile(sPath, aqFile.faRead, aqFile.ctANSI);
// Skips to the specifed position and reads the specified amount of symbols
myFile.SkipLine(2);
myFile.Skip(58);
var sDate = myFile.ReadString(6);
// Closes the file
myFile.Close();
}
Awesome!!
Can't thank you enough!!
Thanks a lot for the help!!