Previous line - what should be returned

(imported topic written by SystemAdmin)

I had posed a question to one of the very helpful support staff at Bigfix, but thought it might be worth sharing here.

I was refactoring a rather large relevance and had thought I’d come up with a much more elegant solution, however, some odd behaviour was stopping me. I’ll use a simple example to give you an idea of what’s happening. Essentially, I don’t think the behaviour of ‘Previous line’ or ‘Next line’ is correct (or at least doesn’t fit my idea of what should be returned). I was trying to read lines from a file and do some processing on them. But I will simplify what I was doing by using the alphabet as my source. So if I say tell me what the output from the following would be (pseudo relevance language), what would you say?

(Previous Letter of Letter, Letter) of (List of Letters of the Alphabet whose (Letters are vowels))

What would the answer be ( the ones including nothing would probably not be shown, but are there conceptually )? I think we’re getting the output as Example 1, but I was expecting (hoping for) Example 2.

Example 1:

,a

d,e

h,i

n,o

t,u

-OR-

Example 2:

,a

a,e

e,i

i,o

o,u

(and sometimes you get x,y and u,y)

If the output of Example 1 is correct behaviour (cough), then how could you constrain your results to only include the vowels and get the vowel prior to each vowel, as ()'s don’t seem to do the trick.

Comments?

(imported comment written by sthull)

Hi jwilkinson,

Example 1 is the correct behavior because the previous line and next line inspectors look at things from the file level. So even though you have filtered down the list of returned lines to a subset of the file, it goes back to the file to see the previous and next lines of that subset.

I think the best bet to accomplish what you want is to output your filtered lines to an appendfile or temp file, and then use previous/next lines on that temp file. You will need to error check for the first line because that will cause the overall expression to fail, as opposed to just not showing the first result.

Regards,

Steve