Hi, I am trying to use a function to read/parse through a logfile outputted from a SRI Gas chromatograph to get an array of strings and am having a little trouble with the function aspect of it. My code as a sequence works perfectly, but when I try use a function with the filename as the argument I get an error.
for example this:
//function readLog(FILENAME)
private string FILENAME = "C:/Peak489Win10/CH1.LOG"
private string logArray
private handle = File.Open(FILENAME,1,0,0,1)
logArray = File.ReadDelim(handle,-1, chr(9), chr(10),0,1)
File.Close(handle)
private string thisRow
private SolArray
private BenArray
private TolArray
private ChlArray
private EthArray
private mpDArray
private oDiArray
private string NameArray
private string DateArray
private string TimeArray
private timeDoubleArray
private nRows = numRows(logArray)
private string output
private rowCounter = 0
while(rowCounter < nRows)
private SolventArea = 0
private BenzeneArea = 0
private TolueneArea = 0
private ChlorobenzeneArea= 0
private EthylbenzeneArea = 0
private m_pDichloroArea = 0
private oDichloroArea = 0
private handle2
handle2 = File.Open(FILENAME, 1,0,0,1)
for(private.i = 0, i<rowCounter, i++)
file.Read(handle2)
endfor
thisRow = File.ReadDelim(handle2, -1,chr(9),chr(10),1,1)
file.Close(handle2)
private string Name0 = thisRow[0][0]
private string Date0 = thisRow[0][1]
private string Time0 = thisRow[0][2]
private timeDouble = StrToTime((Date0 + " " + Time0),'mdyhms')
private nCols = NumCols(thisRow)
private colCounter = 3 //start at row 3 because the first 3 are used up already
while(colCounter < nCols)
switch
case (thisRow[0][colCounter]=="SOLVENT")
SolventArea = SolventArea + strToDouble(thisRow[0][colCounter+2]) //colCounter+1 is occupied by RT
case (thisRow[0][colCounter]=="Benzene")
BenzeneArea = BenzeneArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="Toluene")
TolueneArea = TolueneArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="Chlorobenzene")
ChlorobenzeneArea = ChlorobenzeneArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="Ethylbenzene")
EthylbenzeneArea = EthylbenzeneArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="m_p-Dichloroben")
m_pDichloroArea= m_pDichloroArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="o-Dichlorobenz")
oDichloroArea= oDichloroArea + strToDouble(thisRow[0][colCounter+2])
endcase
colCounter = colCounter+1
endwhile
SolArray[rowCounter] = SolventArea
BenArray[rowCounter] = BenzeneArea
TolArray[rowCounter] = TolueneArea
EthArray[rowCounter] = EthylbenzeneArea
ChlArray[rowCounter] = ChlorobenzeneArea
mpDArray[rowCounter] = m_pDichloroArea
oDiArray[rowCounter] = oDichloroArea
NameArray[rowCounter] = Name0
timeDoubleArray[rowCounter] = timeDouble
TimeArray[rowCounter] = Time0
DateArray[rowCounter] = Date0
output[0][rowCounter] = Name0
output[1][rowCounter] = Date0
output[2][rowCounter] = Time0
output[3][rowCounter] = SolventArea
output[4][rowCounter] = BenzeneArea
output[5][rowCounter] = TolueneArea
output[6][rowCounter] = ChlorobenzeneArea
output[7][rowCounter] = EthylbenzeneArea
output[8][rowCounter] = m_pDichloroArea
output[9][rowCounter] = oDichloroArea
output[10][rowCounter] = timeDouble
rowCounter = rowCounter+1
endwhile
?output
//return output
gives me my desired output, whereas this:
function readLog(FILENAME)
//private string FILENAME = "C:/Peak489Win10/CH1.LOG"
private string logArray
private handle = File.Open(FILENAME,1,0,0,1)
logArray = File.ReadDelim(handle,-1, chr(9), chr(10),0,1)
File.Close(handle)
private string thisRow
private SolArray
private BenArray
private TolArray
private ChlArray
private EthArray
private mpDArray
private oDiArray
private string NameArray
private string DateArray
private string TimeArray
private timeDoubleArray
private nRows = numRows(logArray)
private string output
private rowCounter = 0
while(rowCounter < nRows)
private SolventArea = 0
private BenzeneArea = 0
private TolueneArea = 0
private ChlorobenzeneArea= 0
private EthylbenzeneArea = 0
private m_pDichloroArea = 0
private oDichloroArea = 0
private handle2
handle2 = File.Open(FILENAME, 1,0,0,1)
for(private.i = 0, i<rowCounter, i++)
file.Read(handle2)
endfor
thisRow = File.ReadDelim(handle2, -1,chr(9),chr(10),1,1)
file.Close(handle2)
private string Name0 = thisRow[0][0]
private string Date0 = thisRow[0][1]
private string Time0 = thisRow[0][2]
private timeDouble = StrToTime((Date0 + " " + Time0),'mdyhms')
private nCols = NumCols(thisRow)
private colCounter = 3 //start at row 3 because the first 3 are used up already
while(colCounter < nCols)
switch
case (thisRow[0][colCounter]=="SOLVENT")
SolventArea = SolventArea + strToDouble(thisRow[0][colCounter+2]) //colCounter+1 is occupied by RT
case (thisRow[0][colCounter]=="Benzene")
BenzeneArea = BenzeneArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="Toluene")
TolueneArea = TolueneArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="Chlorobenzene")
ChlorobenzeneArea = ChlorobenzeneArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="Ethylbenzene")
EthylbenzeneArea = EthylbenzeneArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="m_p-Dichloroben")
m_pDichloroArea= m_pDichloroArea + strToDouble(thisRow[0][colCounter+2])
case (thisRow[0][colCounter]=="o-Dichlorobenz")
oDichloroArea= oDichloroArea + strToDouble(thisRow[0][colCounter+2])
endcase
colCounter = colCounter+1
endwhile
SolArray[rowCounter] = SolventArea
BenArray[rowCounter] = BenzeneArea
TolArray[rowCounter] = TolueneArea
EthArray[rowCounter] = EthylbenzeneArea
ChlArray[rowCounter] = ChlorobenzeneArea
mpDArray[rowCounter] = m_pDichloroArea
oDiArray[rowCounter] = oDichloroArea
NameArray[rowCounter] = Name0
timeDoubleArray[rowCounter] = timeDouble
TimeArray[rowCounter] = Time0
DateArray[rowCounter] = Date0
output[0][rowCounter] = Name0
output[1][rowCounter] = Date0
output[2][rowCounter] = Time0
output[3][rowCounter] = SolventArea
output[4][rowCounter] = BenzeneArea
output[5][rowCounter] = TolueneArea
output[6][rowCounter] = ChlorobenzeneArea
output[7][rowCounter] = EthylbenzeneArea
output[8][rowCounter] = m_pDichloroArea
output[9][rowCounter] = oDichloroArea
output[10][rowCounter] = timeDouble
rowCounter = rowCounter+1
endwhile
?output
return output
Does not when I call readLog("C:/Peak489Win10/CH1.LOG"), I get this error message
global x = readLog("C:/Peak489Win10/CH1.LOG")
F0002 The file could not be located.: readLog Line 4: Line 1
when I try to call it in the command line. Am I doing something wrong here?
I attached the log file I am trying to read if that helps at all. Any help would be greatly appreciated. Thanks!
CH1.LOG