Subject Re: html report
From Mervyn Bick <invalid@invalid.invalid>
Date Thu, 14 Jul 2016 08:37:41 +0200
Newsgroups dbase.getting-started
Attachment(s) launch_report.wfm

On 14-Jul-16 2:58 AM, Ken Mayer wrote:
> On 7/13/2016 5:25 PM, Charlie wrote:
>> Hi...
>>
>> If using html as the output in a report can the outputfilename be a
>> variable such as date()?  I tried this in several ways but couldn't
>> get it to work.  Anyone have success with this?  Thanks!
>
> Try:
>
> r.outputFilename := dtos(date())
>
> dtos() converts the date to a string (DateTOString), in the format
> YYYYMMDD ...

There's "gotcha" hidden here. :-)

If this is placed in the source code either in the bootstrap

local r
r = new whateverREPORT()
r.outputFilename = dtos(date())
r.output = 4
r.render()

or in the class definition

class whateverREPORT of REPORT
    with (this)
       outputFilename = dtos(date())
       output = 4        
       autoSort = false
    endwith

it is vulnerable to attack by the designer.

The report will work just fine until it is changed in the designer. When
the code is streamed out additions to the bootstrap will simply be
discarded.  The function in the class definition will be evaluated and
the result will be streamed out so all future reports will have the same
file name.

For this to work safely the report needs to be launched from a simple
form where the output filename can be set each time before the form is
rendered.

In the attached example change whatever.rep and whateverreport() to the
actual report file name and the class name.

By leaving the output type as the default 3 in the report and not
hard-coding the output type as 4 you will be able to run the report from
the Navigator and view it on-screen.

The little form could easily be enhanced by adding some radiobuttons to
give the choice of creating the HTML file, of printing to a printer for
a paper copy or of printing to a PDF file for a copy that could be
attached to a email.


Mervyn.







** END HEADER -- do not remove this line
//
// Generated on 2016/07/14
//
parameter bModal
local f
f = new launch_reportForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class launch_reportForm of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 16.0
      left = 62.4286
      top = 1.5455
      width = 40.0
      text = "Launch report"
   endwith

   this.PUSHBUTTON1 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON1)
      onClick = class::PUSHBUTTON1_ONCLICK
      height = 1.0909
      left = 12.0
      top = 7.0
      width = 15.2857
      text = "Launch report"
   endwith


   function PUSHBUTTON1_onClick()
      form.rep.output = 4
      form.rep.outputFilename = dtos(date())
      form.rep.render()
      return

   function form_onOpen()
      set procedure to whatever.rep
      form.rep = new whateverreport()
      return

endclass