Hi David:

In message <[email protected]>,
[email protected] writes:
>On Fri, 20 Nov 2009, John P. Rouillard wrote:
>> In message <[email protected]>,
>> david at lang.hm writes:
>>> I am creating rules that accumulate log lines into a
>>> context for a later report.
>>> 
>>> since these are _long_ log lines, they will wrap in the
>>> e-mail client when I send them. I would like to add an
>>> extra newline when I add text to the context, but I
>>> cannot figure out how to make this work.
>> 
>> Maybe use sub-pattern matches to break the line into
>> multiple pieces and add each piece?
>>
>>  pattern=^(.*some matching thing)(.{60})(.*)
>>  action = add context $1; add context $2; add context $3
>
>this could work, but having to do a second rule and action
>just to add a newline is a very expensive way to do things.

Actually you shouldn't need a second rule. Just set up your
current rule with the appropriate subexpressions and rather
than adding $o add the three sub-patterns. I agree it's kind
of ugly though.


>> Use eval to create a perl function that will format its
>> argument by inserting newlines.  Then in your action
>> calling it on $0 "call %{result} %{eval_fnction_handle}
>> $0; add context %{result}".
>
>I'm not sure how to do this.

See the man page for eval and call. Look for funcptr for an
example. You will need some perl skills though to create the
function. Or you can create a .pm file and include it in the
running sec. See James Brown's sec tutorial for an example
of how to load a pm file.

>in this case it's a simple 'add a blank line between every
>line' reformatting, but I can definantly see future options
>that would be messier.

Yup the the perl subroutine route is probably the best mechanism.

>> If you just need a newline after each line you add,
>> assign a variable to newline and add it:
>>
>>  assign %N \n; add context %N;
>>
>> I am not sure if \n works for setting a newline though.
>
>no, this inserts the characters \n not a newline.

Try:

  eval %N (return (" \n");); add context $0; add context %N

if the " \n" is changed to "\n" then it's as though the add
is ignored. No empty line is inserted. I claim this is a
bug.

Risto care to chime in?

--
                                -- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Simple-evcorr-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to