4 Replies Latest reply: Dec 9, 2015 11:13 AM by Kevin Bertsch RSS

    Peek or previous?

    Kevin Bertsch

      I am trying to process a log file from nPrinting in my script. I want (eventually) to have a summary report of any errors, and the current schedule and task when the error occurred. nPrint log files look like this:

      LOG.jpg

      When it reads the second line, I want to set a field "CurrentSchedule" to "Outbound Touch Report". using

      right(Message,len(Message)-index(Message,';',2)-8)

       

      I want "Outbound Touch Report" to be set as CurrentSchedule until the NEXT line with "Run Schedule" appears, at which

      point it will be replaced by the new value of CurrentSchedule, and so on.

       

      I tried, among other things,

      //If(RowNo() = 0,
      //if(SchedLine = 0, 'dummy',right(Message,Len(Message)-Index(Message,':',2)-8)), // if rowno = 0, set to dummy unless CS line
      //if(SchedLine = 1, right(Message,Len(Message)-Index(Message,':',2)-8), Previous(CurrentSchedule))) AS CurrentSchedule,

       

      but that gives me an error "field CurrentSchedule not found". (SchedLine is a flag set in my Select statement)

       

      The only other thing I can think of is to write a procedure to this, but I'm sure it can be done in the script; I'm just not sure of the syntax. Can anyone help? thanks, Kevin

        • Re: Peek or previous?
          Mark Little

          Hi

           

          What error are you getting or what is the problem?

          I would normally started my Statement like

          IF ROWNO() =1,

           

          But doesn't seem to be the problem. Does the field CurrentSchedule exist in the data?

           

          Previous() works on load.

          Peek() works after, so can reference a field you are creating.

           

          So try the peek.

           

          Mark

            • Re: Peek or previous?
              Kevin Bertsch

              No, "Current Schedule" does not exist in the data. As I noted, the error message I get is "field CurrentSchedule not found". I am trying to create this field. The problem is getting an initial value! i.e. in RowNo()=0 - that's the first row read in, which MIGHT (or might not) contain the "Run Schedule" trigger, there's no value for CurrentSchedule. I tried to set it in my first IF (If RowNo()=0, if(SchedLIne = 0, 'dummy', ...) so that there would be a value for Previous(CurrentSchedule) when it read RowNo()=1, but that doesn't seem to work.