I am having a problem wit this data
here is the code to add the times up and print in the output window, but it is not working all help is appreciated
Code: Select all
kjg oejhgreg
eig
qegj rpqej gpq
egj 'pierp'
erg
r
gu eg
u g
p u g
p u g
p u g
p ue gp
eg pue gpue qg
Elapsed: 01:10:00.66
'lgk sdl;jgad;ojg ad
gag
fagk
fa
gka
gk
Elapsed: 00:33:44.00
agad
gfa
g
ga
g
ag
ag
g
Elapsed: 00:00:55.23
ag
ag
adgf
ag
ad
gfa
dh
dhs
fhf
jhdsjy
dgj
gj
Elapsed: 00:08:32.77
h
fgd
gfswd
hgwr
hwr
ht
wrh
wrh
wrh
w
Elapsed: 00:50:00.12
ashaswhtwsrhwrthrwhwrthwrthwrth
sfdth
wrh
wr
hw45
h45w
h
w456h
2456h
52w6
h526
h562
h5
h5
64h5
h5
h56
h
Elapsed: 00:16:00.01
wiy rtpio3qytgpiu31qy gtipuq3yh tg3
Elapsed: 00:19:00.40
e
rtweb5
tw
5tbqw43
b6tq3
6q6
q6
23
324
6
Elapsed: 00:31:00.56
qt
34b63
6
6
q26
w234
562
4652
4b6
2
Elapsed: 03:00:00.12
rtqw
4etyb23q4
6234
62q43
62q34
562q
462q43
62q
66
Elapsed: 00:00:44.11
twe
y245b
67y24
7y642w
y7w4
y75n w4
57y6nw 4
5b
56 46
7w7
45
7nw475
Elapsed: 00:00:22.99
h
e5thn
5 h
2 54y6
2y
45 y
y4
y
4y5
y45
45y
y4
2y
654y
Elapsed: 00:00:10.03
ka
;lkgv
kbf
fbgk
qewbg
wqre
bgt
qwertbgk
q4rekgt
q4tkg
4q1gk
4qpg
1435jgt
1j435gh
Elapsed: 00:00:04.00
iah epfghqepuoir gpueiqgypuiqeygipuqeyguiqg:
Elapsed: 00:00:00.00
Code: Select all
// Define working environment for this file.
UltraEdit.perlReOn();
UltraEdit.insertMode();
if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
var t1,t2,t3,ttime
// Helper function as UE does not recognize start and ending slashes in regexp
RegExp.prototype.toUEregexp = function() { return this.toString().replace(/^\/|\/$/g, ""); }; /* remove starting and ending slashes */
// Where to find the parmfile:
var parmfile = "c:\\temp\\sample_timing.txt";
// Now go get parm file and parse it into an array of parameters
var parms = getParms(parmfile);
UltraEdit.outputWindow.write( parms.length );
if(parms.length != 0) {
for(var i=0;i<parms.length;i++) {
ttime= ttime + parms[i];
}
}
t1 = parseInt( ttime/3600 );
/* Parse parameter document to get parameters */
function getParms(parmfilePath) {
var parsedParms = new Array();
// Open parm file if not open already
var parmdocIx = getDocumentIndex(parmfilePath);
var parmdocOpen = true;
if(parmdocIx==-1) { /* not open */
UltraEdit.open(parmfilePath);
parmdocIx = getDocumentIndex(parmfilePath);
parmdocOpen = false;
}
if(parmdocIx==-1) { /* just in case, no parm file found */
return parsedParms;
}
// Define all the replace options to correct execute the follwing 2 replace all commands.
UltraEdit.document[parmdocIx].findReplace.mode=0;
UltraEdit.document[parmdocIx].findReplace.searchDown=true;
UltraEdit.document[parmdocIx].findReplace.searchInColumn=false;
UltraEdit.document[parmdocIx].findReplace.matchCase=false;
UltraEdit.document[parmdocIx].findReplace.matchWord=false;
UltraEdit.document[parmdocIx].findReplace.preserveCase=false;
UltraEdit.document[parmdocIx].findReplace.regExp=true;
var reParms = /Elapsed: ([\d]{2}:){2}[\d]{2}\.[\d]{2}/; /* perl regular expression */
UltraEdit.document[parmdocIx].top();
// Loop and find all parameters
while (UltraEdit.document[parmdocIx].findReplace.find(reParms.toUEregexp())) {
// retrieve found parameter definition
var foundParmDefs = UltraEdit.document[parmdocIx].selection;
// UltraEdit.outputWindow.write( foundParmDefs )
t1 = foundParmDefs.substr(9,2);
t2 = t1 * 3600;
t1 = foundParmDefs.substr(12,2);
t2 = t2 + ( t1 * 60 );
t1 = foundParmDefs.substr(15,5);
t2 = t2 + t1;
// add up total in seconds format is sssssss.hh
// after adding I only care about sssssss
// t3 = t3 + t2;
// collect pairs of parameter definitions into array:
parsedParms.push( [parseInt(t2)] );
}
if(parmdocOpen==false) { /* not open, then close again on exit */
UltraEdit.closeFile(UltraEdit.document[parmdocIx].path,2);
}
return parsedParms;
}
/* getDocumentIndex(filepath) */
/* If called without parameter = Find the tab index of the active document */
/* If called with parameter "filepath" = Find the tab index of that document. -1 = document not found */
function getDocumentIndex(filepath) {
var tabindex = -1; /* start value */
for (i = 0; i < UltraEdit.document.length; i++)
{
if(filepath) {
if (UltraEdit.document[i].path.toLowerCase().indexOf(filepath.toLowerCase())!=-1) {
tabindex = i;
break;
}
}
else {
if (UltraEdit.activeDocument.path==UltraEdit.document[i].path) {
tabindex = i;
break;
}
}
}
return tabindex;
}