frills processing and XyPerl

Greetings fellow XyUsers,

I am having a bit of trouble with frills processing and wondered if anyone might spot what the problem might be…
I’m using XPP 9.1.1.0  and XyPerl to do the frills processing.

I have chopped my XyPerl down so that I am
-    opening the main stream (successfully)
-    opening the first block (successfully)
-    then start to loop through the lines in that first main block

From some messages that I am able to output to STDERR I can see that well before reaching the last line in the block I am getting a return from the line open that is showing !opened as being in error.
At first this was at about the 10th line down the page.
After adding a little bit more text to my STDERR messages I am now encountering the problem before the 10th line - so suspect that somehow I hitting a limit.

In the XyMacros book, at page 4-61, I read this information:

Use caution when writing a frills processing loop that’s checking
each main text line to see if you want to do something on it.
Composition is just going to process all of this on a single line until
something in the macros causes a new line to occur. If nothing
causes a new line to occur in a reasonableamount of processing,
then the line is going to fill up with over 65535 bytes and cause the
fatal error Macro definitions are probably too long and/or
recursive.

However, I’m struggling a bit to understand what it means - and what I might need to do to avoid hitting such a limit.


I have experimented with my XyPerl program and am hitting what seems to be the same sort of limitation when processing the “foot” stream.


Does anyone have an idea what might be happening?


thanks,
Paul


  • Hi Paul. First off I wouldn't output to STDERR, just print to the xyview directly i.e. print "opened line<qa>";

    This will allow you to see how many opened lines you actually got to before the error occurred. I believe there is some buffering going on so as long as you're not core-dumping or infinite-looping (obviously you're not as you can see the compo log), then you'll see some output that should make sense.

    You can include a counter pretty easily and count the lines as they're opened/output.

    If you want to get to the last line in the block just use open_db("last", "main", "line")
  • Thanks Mark.
    That was very helpful - I can now loop successfully through all main and foot blocks and also now have the desired outcome onto the page!

    Do you think that my use of STDERR started off some buffering which later reached a limit and caused my frills loop to have problems?

    cheers,
    Paul
  • Paul,

    Very strange...I never had hit any limit while doing frills processing.
    But I never use STDERR to send anything back.
    I am like Mark, for debugging I send things straight back to the division.

    So it looks like STDERR might be the one to blame for your problems.
    If I were you I would still open a ticket on this as I can not see why STDERR would have a limit different from STDOUT.
    So maybe you are on to something here.
    Plus the response you get back from engineering might be very instructive
    They usually are and usually they are really helpful in getting a better understanding on what really goes on deep down there inside the XPP engine.
  • Thanks Bart.

    I think that  I was initially not finding what I was expecting when I set up my frills loops and so printed a few things to STDERR to try and figure out what was going on.

    That decision to use STDERR seems to have been the cause of the problems that I was seeing - so, like you and Mark, I'll be sending debug info to the division in future!

     

    I see in the XyMacros manual it has this in the Error Handling section on page 6-26:

    Note: If you write to STDERR from your Perl program, XPP does not
    compose any generated text, but writes the error information to job.log.

    I don't think that really covers the behaviour that I was seeing though ... I'll open a ticket to enquire further.

     

    cheers,

    Paul

     

     

     

     

     

     

     

  • Hi Paul (and Mark and Bart),

    I think the "answer" that's indicated by what you quoted from the manual is that if a XyPerl script writes anything to STDERR then that is treated as a composition "error" and anything that the same XyPerl script has written to STDOUT (meant to go back as input to composition) will get ignored ("XPP does not compose any generated text").

    In other words, if a XyPerl script at any point during a call writes anything to STDERR then anything that the same call wrote to STDOUT is ignored - even if things were written to STDOUT before the script wrote to STDERR.

    The writing to STDERR by a XyPerl script was intended to be used for "abort" types of situations, and not really meant to be a means of "communication".

    However, there are some other options that can be used for "debugging" than having to write your messages to STDOUT and have those messages become part of the composed text (thereby interfering with the desired composition results).

    1. You can have your XyPerl script write "debugging" messages to a separate file of your choice that you can view later (i.e. do not write these messages to STDOUT or STDERR).

    2. You can use the logging macro <lg> (added in XPP 8.4 release) to write a message to the composition log (and dialog window in the XyView). See the documentation on it, but with XyPerl you would craft an <lg;...> macro and then write it to STDOUT. When that is later composed (along with everything else written to STDOUT and as long as nothing is written to STDERR and no error occurs), then composition will write the <lg> message to the composition log and to the message dialog.

    Hope that helps.

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • Ah the logging macro...completely forgot that it was there.
    Thank you Jonathan for reminding me of that little gem...it might come in useful some day...
  • Hi Jonathan,

    Perfect! - Thanks very much for your explanation and guidance - that's very helpful.

    I've just tried the $X->lg("message") route in my XyPerl program and that has worked a treat.

     

    cheers,

    Paul