ajsenko

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by ajsenko

  1. Figured it out, the command to launch a batch file with shellExecute is 

    system.ShellExecute("cmd.exe", "open", "/C C:\data\myBatchFile.bat") 

    At least thats the way I got it to work, hope this helps if anyone is looking for how to do that. 

  2. On 5/8/2020 at 4:04 PM, AzeoTech said:

    Not built in.  I would probably use a trick, probably with a batch file.  The batch file would just have something like:

    echo %userprofile%/desktop > c:\data\desktopPath.txt

    You'd run it from DAQFactory using shellExecute():

    system.shellExecute("cmd.exe","c:\data\myBatchFile.bat")

    Then you can simply use the file. functions to read the desktopPath.txt file and get the results.

    This is off the cuff, but should work, possibly with minor tweaks.  Test each part.

    Hi, I'm also trying to run a batch file, and "system.shellExecute("cmd.exe","c:\data\myBatchFile.bat")" doesn't do anything. 

    function LoadAutosamplerFile(string que_file)
       //try
          private string script_dir = "C:\Peak489Win10\LoadCtrlFile.bat"
          private handle = file.Open(script_dir, 0, 1, 0, 1)
          File.Write(handle, "cd C:\Peak489Win10")
          File.Write(handle, "Peak489Win10 -a" + que_file)
          File.Close(handle)
          system.ShellExecute("cmd.exe","C:\Peak489Win10\LoadCtrlFile.bat")
          ?"Batch file (allegedly) executed"
          return 1

  3. 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

  4. I'm working with a SRI GC and peaksimple and I want to be able to read the data from the .log file outputted by the GC software (peaksimple) into daq factory

    the basic format of the log file is that each experiment gets one line in the file, and it has some info about the experiment (date/time/name of run) that I want, and then the chemical name followed by the residence time (RT) and peak area for each chemical. Each element is separated by a tab (I attached the logfile so you can see it easier).

    I would like to use ReadDelim to separate it out so I have an array that is formatted as such:

    logArray  = {{'Run 1 name', 'Run 1 date', 'run 1 time', 'run1chemical1', 'run1RT1', 'run1Area1', 'run1chemical2', 'run1RT2', 'run1area2'...},{'Run 2 name' ...}, {'Run 3 name' ...} ...}

     

    I've tried using this code: 

    global string logArray
    private handle = File.Open("c:\Peak489Win10\CH1.log",1,0,0,1)
    logArray = File.ReadDelim(handle,0, chr(9), chr(10),0,1)

    And I get an array that is {NaN, NaN, 330}. Is it possible to use file.readDelim to get an array of strings out? Do I have any alternatives? thanks

     

    CH1.LOG

  5. I have a set of global variables called "ProcedureDummy0" , "ProcedureDummy1" ... that I set ={0,0,0,0,0,0,0,0} at startup. I will change the value of these variables in a table (I have figured out a semi-janky way to do that with input boxes and a table), but I also want to be able to display the values in a table. Not including headers, I want the cell in the "m"th row and the "n"th column to be "ProcedureDummyn[m]" I set the expression for the column to {ProcedureDummy[1],ProcedureDummy1[1],ProcedureDummy2[1],ProcedureDummy3[1],ProcedureDummy4[1],ProcedureDummy5[1]} (each of those are still 0 from my startup sequence, and each of those will display as 0.000 with the variable value element). But the table displays 1.00 for each cell in the table. It does the same with 2.00 and the 2nd element, and so on. Why? Can I fix this?