Page 1 of 1
Preview-How to pass a parameter
Posted: Tue Nov 13, 2007 8:57 am
by Otto
Preview
Could someone suggest an easy way to pass a parameter to preview?
In certain cases I need more buttons than the standard preview menu has.
How could I pass a parameter for example cCalledFrom to rpreview to know which function called the preview to adapt the menu.
If cCalledFrom = “Billing”
DEFINE BUTTON RESOURCE "Printer" OF oBar GROUP ;
MESSAGE TXT_PRINT_CURRENT_PAGE ;
ACTION f_name() ;
prompt "T e s t" TOOLTIP Strtran(TXT_PRINT,"&","")
endif
Thanks in advance
Otto
Re: Preview-How to pass a parameter
Posted: Tue Nov 13, 2007 9:35 am
by Richard Chidiak
Otto
I write to a txt file username.txt and the preview checks to see if the file is there, it erases it at the end
Hth
Richard
Posted: Tue Nov 13, 2007 10:08 am
by Otto
Richard, thank you for your tip.
How do you care if the txt is deleted after printing. What if the system crashes.
Regards,
Otto
Posted: Tue Nov 13, 2007 10:17 am
by Richard Chidiak
Otto
if i understood correctly your question, the data is needed to be used by the preview, so it has to be deleted after printing in order to load some other data if needed next time.
The file i use is unique per user, so the information is there. The name of the file is retreived from netname() + '.txt' . i use it to pass to the preview the customer's email from the customer file and then the preview email's at the correct address.
Another solution would be to chane the preview and add data to the classs , cargo or anything else.
This depends what you want to do at preview
Hth
Richard
Posted: Tue Nov 13, 2007 10:47 am
by Enrico Maria Giordano
Richard Chidiak wrote:Another solution would be to chane the preview and add data to the classs , cargo or anything else.
Or, better, inherit from TPreview and add to the inherited class what you need to.
EMG
Posted: Tue Nov 13, 2007 10:56 am
by Otto
Thank you for your answers.
Enrico, do you have some code how this could be done.
Do I have to start in printer.prg which calls rpreview?
Do you think this could work?
add xPreview to printer.prg
METHOD xPreview() INLINE If( ::lMeta .and. Len( ::aMeta ) > 0 .and. ::hDC != 0,;
xRPreview( Self ), ::End() )
and add xRPreview.prg with the changes.
Posted: Tue Nov 13, 2007 10:59 am
by Enrico Maria Giordano
Otto wrote:Enrico, do you have some code how this could be done.
No, sorry.
Otto wrote:Do I have to start in printer.prg which calls rpreview?
Yes, TPreview is used by TPrinter so you have to inherit a class from TPrinter also, I'm afraid.
EMG
Posted: Tue Nov 13, 2007 11:01 am
by Otto
Sorry Enrico, I edited my post. Could you please read the post again?
Posted: Tue Nov 13, 2007 11:05 am
by Enrico Maria Giordano
Otto wrote:Do you think this could work?
add xPreview to printer.prg
METHOD xPreview() INLINE If( ::lMeta .and. Len( ::aMeta ) > 0 .and. ::hDC != 0,;
xRPreview( Self ), ::End() )
and add xRPreview.prg with the changes.
Yes, but the problem in creating a modified copy of rpreview.prg is that you have to apply to it any changes/fixes made later to the original file. I recommend inheritance instead.
EMG
Posted: Tue Nov 13, 2007 11:10 am
by Otto
Enrico, if you inherit a class could you also overwrite the new method?
Posted: Tue Nov 13, 2007 11:23 am
by Antonio Linares
Otto,
yes
Posted: Tue Nov 13, 2007 11:34 am
by Otto
Antonio
if I use in the inherited class, example xPrinter from TPrinter
METHOD New(cMyData ) CONSTRUCTOR
do I have all the data in the new class
METHOD New( cDocument, lUser, lMeta, cModel, lModal, lSelection ) CONSTRUCTOR
plus
cMyData?
Thanks in advance
Otto
Posted: Tue Nov 13, 2007 12:01 pm
by Antonio Linares
Otto,
yes