Forum Discussion
Hi...thanks to everyone for their help. It was suggested that I include what I'm trying to achieve...
I'm writing the contents of a grid to a text file (notepad) which will be used as a baseline during a file compare. The problem is the file includes a datetime stamp which will cause the file comparison to always fail.
The notepad file looks like this: "SYSDBA","05/17/2017 1:09:40 PM","Update","","BRANCH","1","0"
My goal is to end up with a file looking like one of the following:
"Update","","BRANCH","1","0"
"SYSDBA","Update","","BRANCH","1","0"
This is a copy of the code I'm using:
procedure Test;
var
tempFileName4, FileName4, str : OleVariant;
begin
tempFileName4 := Project.Path + '4199_4_temp.txt';
//Save 2nd row in listview to file
listview := TBO.HistoryForm.CDSListView1;
ListViewItemToCSVFile4(listview, tempFileName4, 1);
//Verify 2nd item displays: BRANCH (field), 1 (Old Value), 0 (New Value)
if Files.Compare(FileName4, tempFileName4) then
log.Checkpoint(tempFileName4+' matches baseline.');
end;
Thanks in advanced,
Kim
Hi,
ListViewItemtoCSVFile4 is writing output value to a tempFilename4
Then you are comparing tempFileName4 with FileName4.
If my understanding is correct,
FileName4 will have the contents with Timestamp and tempFileName4 will not have the timestamp
So, Checkpoint going fail in this scenario.
Correct me if my understanding is wrong
- tristaanogre7 years agoEsteemed Contributor
If ListViewItem4 is under your control, your answer is there. When you're reading the listView and writing it to the file, detect when a field contains a date (use aqString.StrMatches and use a regular expression). If the field contains a date, write out a blank, otherwise, write out the actual value.
- kimmatsumoto7 years agoContributor
Yes, ListViewItemToCSVFile4 is writing output (in text format) to the file tempFileName4 which gets compared to the baseline file (FileName4).
The file tempFileName4 will have the timestamp which I want to remove and save and then compare it against FileName4 (baseline) which will not have a timestamp.
FYI...to get the baseline file I copied tempFileName4 and renamed to FileName4 and then manually deleted the timestamp.- tristaanogre7 years agoEsteemed Contributor
kimmatsumoto wrote:
Yes, ListViewItemToCSVFile4 is writing output (in text format) to the file tempFileName4 which gets compared to the baseline file (FileName4).
The file tempFileName4 will have the timestamp which I want to remove and save and then compare it against FileName4 (baseline) which will not have a timestamp.
FYI...to get the baseline file I copied tempFileName4 and renamed to FileName4 and then manually deleted the timestamp.Exactly... so... edit ListViewItemToCSVFile4 to filter out the datetime stamp in it's writing to your temp filename. Again, detection can be used with aqString.StrMatches and then just write out the line to your file without the date time stamp.
- joseph_michaud7 years agoModerator
If you know that the timestamp is always the second element in the comma separated string, you can use JScript/JavaScript code directly. The following example creates a new array with second element removed.
function tryme() { var str = "aaa,bbb,ccc,ddd"; var arr = str.split(","); Log.Message(arr); var arr2 = Array().concat(arr.slice(0, 1), arr.slice(2, arr.length)); Log.Message(arr2); }
Related Content
Recent Discussions
- 4 hours agoSubhraDas
- 22 hours agotramuntana