Uniface occurence printing

Author: roger.wallin@abilita.fi (rogerw)

Hi, I have never been a Uniface print-expert so this question could be strange/easy..... Having the below code in OGF-trigger. The code prints  some occurrences and sends some as e-mail. Is there a way to avoid printing a blank paper if there are just occurrences retrieved that will be send as Epost. The print is initiated in print-trigger and you don't know beforehand that there are no occurrences that should be printed (or at least I wouldn't like to loop and check them in the print-trigger). if($printing=0) done if(wayToSend="Paper") ;Print   pbnret.break_1=nret   pbdatat.break_1=datat   printbreak "break_1" elseif(wayToSend="Email") ;Dont print but send as Email   ;pbnret.break_1=nret   ;pbdatat.break_1=datat   call SendAsEpost() endif clear/e "break_1" return(-1) Regards RogerW.

10 Comments

  1. Hi Roger, The return(-1) in the OGF should accotding to the documentation, suppress the printing of the occurence. But uniface will print ALL whats on the form: if there is a blank line, it is enough to force an "empty" page print. So check that all entity- and breakframes are back-to-back. Greetings from Frankfurt/Germany, Uli


    Author: ulrich-merkel (ulrichmerkel@web.de)
  2. Hi Uli, I still have problems with this. But as I would like to find those situations where there is only one occurence and it's not going to the printer, I think I'll have to loop the occurences in the print-trigger and then start a Uniface print to Notepad (or preview) instead of Printer to avoid the paper being printed. It's quite an old and complicated ;-) program and I wouldn't like to do any big changes. The program is changed to send messages as email or sms for some customers instead of paper, due to their setting in the customer-register. Regards RogerW.


    Author: rogerw (roger.wallin@abilita.fi)
  3. What about just using a special PRATT with an empty QUEUE and good old P_DEFAULT. Will give you back the formname.P0? files.


    Author: ulrich-merkel (ulrichmerkel@web.de)
  4. Hi, actually that's what I have. As there are no occurrences to print (just those being sent as email or sms) there is a "formname.P0?" that has the size of 0 KB that is being printed as an empty paper. There seem to be no place in code where I could eg. remove this file before it's being printed. I think there is something strange here. Uli tell me more, what do you mean! Regards RogerW.


    Author: rogerw (roger.wallin@abilita.fi)
  5. Hi Roger, even a file with 0KB may have some characters. So open it in an editor where you can see the non-printable characters. Sometimes you may find a single space or a newline etc. which does not show up in a printout, but causes generation of output file.


    Author: ulrich-merkel (ulrichmerkel@web.de)
  6. Reading this thread I get a feeling that either:

    • The 'else' part of the code just doesn't belong in an OGF trigger. The choice for either print or email should be made 'higher up', i.e. in the print trigger itself. or
    • The return(-1) in the OGF is not picked up in the higher level trigger, i.e. also leaving the 'higher up' trigger with $status=-1 and thus prevent the actual printing.

    If you would only be looking for a way to get rid of the print output files in your working directory, a redirection line iyour ASN would be an option, like this (relative path to prt subdirectory under working directory): [FILES] *.P* .\prt\*.P* Regards, Arjen


    Author: Arjen van Vliet (arjen.van.vliet@uniface.com)
  7. Hi, I would probably program it differently today, ie. a hidden form (service?) to manage the printing and operations (as today) to send email or sms. But now I'll check before printing if there are no occurrence to print and then just print with preview and in that case just  show the log. A file redirection mustn't be done if there are occurrences that really should be printed. Regards RogerW.


    Author: rogerw (roger.wallin@abilita.fi)
  8. Another option which does not mess up your current cood too much:: Previous to the print, just loop through your occurences: If it has to be emailed, just start the email and discard the occurence. If there are any occurences left after the loop, start the print for the occurences which have to go to paper. Be aware that because of the discard, you must NOT use the FORentity: I usually use an index from $totocc step -1 down to 1 with a setocc, so discard will not cause trouble. Greetings from a sunny Frankfurt/Germany, Uli


    Author: ulrich-merkel (ulrichmerkel@web.de)
  9. Thanks Uli, Unfortunately there is a counter involved, which is updated by the user after a successful printing. They are used being able to reprint if there are problems during the print and today the logic and their working process is based on that a reprinting is easily done as the counter is not yet updated. So it should be possible to update the counter of the occurrences after the print process, ie. not that good if the occurrences are discarded. One could probably solve this easily but it's a bit complicated to make changes to the form... Regards RogerW.


    Author: rogerw (roger.wallin@abilita.fi)
  10. OK, just a hint: run at first a loop and count the occurences which have to be printed. If there are some, just use the normal print to run the mixed mode. If not, use a normal loop to call SendAsEpost because all occurences are Epost ones.   Or, if sequence doesn't matter: sort occurences by wayToSend descending and check the value of the first occurence for "Paper"


    Author: ulrich-merkel (ulrichmerkel@web.de)