Subject Re: snake report addition
From Charlie <trainman@traincity.com>
Date Tue, 29 Nov 2016 17:16:59 -0500
Newsgroups dbase.getting-started

Hi Mervyn..

OK I understand what you are doing with the temp dbf now.  (Have never done this before but now understand the concept.)

I copied the code between the astericks  and the end header.

The table's name is golfers_scores so I changed snake to golfers_scores in each instance.

On this line I get an error:  Invalid field name...

insert into temp_golfers_scores (data1,late_entry) values ('99',true)

Have never done this before so I have no clue!!!

If I get this resolved is this the only little bit of code I have to add between the astericks and the end header??  Anything else have to be changed?

Thanks much!!

Mervyn Bick Wrote:

> On 2016-11-26 6:31 PM, Mervyn Bick wrote:
> > That should be dead simple but unfortunately it exposes a bug.
> >
> > The reportgroup footerband prints after the last detailband or group
> > footerband if one is using groups.  Unfortunately dBASE doesn't honour a
> > beginNewframe if the reportgroup footerband preRender event handler sets
> > its own property before rendering.  This means that one can't move the
> > text on to the next streamframe if there isn't enough space for
> > additional matches after the last match.
> >
> > That said, it can be done but it needs a bit of fancy footwork.  We have
> > friends coming for dinner just now so I can't work on it now but I'll
> > try and give you an example tomorrow.
>
>
> The reportgroup footerband's beginNewFrame can be set true or false.  If
> it's true the footerband prints on a new streamframe. If it's false the
> footerband prints immediately after the last record or group footerband.
>
> Ideally one would check the space available and set the property to true
> if there wasn't enough space on the last page and to false if there was.
>   The trouble is the setting can't be changed by the preRender event
> handler so one is left with the choice made at design time.
>
> Depending on the number of records one could wind up with the
> "Additional" heading on a new page while there was plenty of room on the
> last page or right at the bottom of the page with no room to enter any
> additional matches.  If the same number of records will be processed
> each time the report is run one can, of course, set the beginNewframe
> property at design time.
>
> I've added a second group to the report as a way round the limitation.
> This involves using a temporary table to which an extra field and a
> dummy record are added.  This is done automatically by code in the
> report's header zone.
>
> Mervyn.
>
>
>
>
>
> if file('snake.dbf')
>    drop table snake
> endif
>
> if not file('snake.dbf')
>    create table snake  (id autoinc,data character(15),data1 character (5))
>         use snake
>         generate 51
>         go top
>          n = 1
>         do while not eof()
>             if n < 10
>                     x1 = 4
>                 else
>          x1 = 3
>       endif                        
>            for x = 1 to x1
>                         if not eof()
>                                       replace data1 with str(n,2,0)
>                                                 skip
>                                  endif                
>                 next
>                 n  ++
>                 enddo
>           use
> endif
>
> *****************************************
> // You only need the following code in the headersection of your report
>
> if file("temp_snake.dbf")
>    drop table temp_snake
> endif
>
> copy table snake to temp_snake
> alter table temp_snake add late_entry boolean
> update temp_snake set late_entry = false
> insert into temp_snake (data1,late_entry) values ('99',true)
>
> ** END HEADER -- do not remove this line
> //
> // Generated on 2016-11-27
> //
> local r
> r = new SNAKE1CREPORT()
> r.render()
>
> class SNAKE1CREPORT of REPORT
>    with (this)
>       metric = 0        // Chars
>       autoSort = false
>    endwith
>
>    this.SNAKE1 = new QUERY(this)
>    with (this.SNAKE1)
>       left = 10.6667
>       top = 0.2
>       sql = 'select * from "temp_snake.DBF" order by late_entry,data1'
>       requestLive = false
>       active = true
>    endwith
>
>    this.PAGETEMPLATE1 = new PAGETEMPLATE(this)
>    with (this.PAGETEMPLATE1)
>       height = 56.1233
>       width = 132.2778
>       marginTop = 3.6
>       marginLeft = 12.0
>       marginBottom = 3.6
>       marginRight = 12.0
>       gridLineWidth = 0
>    endwith
>
>    this.PAGETEMPLATE1.STREAMFRAME1 = new STREAMFRAME(this.PAGETEMPLATE1)
>    with (this.PAGETEMPLATE1.STREAMFRAME1)
>       height = 38.65
>       left = 4.0
>       top = 4.55
>       width = 50.0
>       form.STREAMFRAME1 = form.pagetemplate1.streamframe1
>    endwith
>
>    this.PAGETEMPLATE1.STREAMFRAME2 = new STREAMFRAME(this.PAGETEMPLATE1)
>    with (this.PAGETEMPLATE1.STREAMFRAME2)
>       height = 38.65
>       left = 56.5
>       top = 4.55
>       width = 50.0
>       form.STREAMFRAME2 = form.pagetemplate1.streamframe2
>    endwith
>
>    this.STREAMSOURCE1 = new STREAMSOURCE(this)
>    this.STREAMSOURCE1.GROUP1 = new GROUP(this.STREAMSOURCE1)
>    with (this.STREAMSOURCE1.GROUP1)
>       groupBy = "late_entry"
>    endwith
>
>    with (this.STREAMSOURCE1.GROUP1.headerBand)
>       preRender = class::HEADERBAND_PRERENDER
>       onRender = class::HEADERBAND_ONRENDER
>       expandable = false
>       height = 3.0
>    endwith
>
>    this.STREAMSOURCE1.GROUP2 = new GROUP(this.STREAMSOURCE1)
>    with (this.STREAMSOURCE1.GROUP2)
>       groupBy = "data1"
>       headerEveryFrame = true
>    endwith
>
>    with (this.STREAMSOURCE1.GROUP2.footerBand)
>       onRender = class::FOOTERBAND_ONRENDER
>       height = 1.0
>    endwith
>
>    this.STREAMSOURCE1.GROUP2.footerBand.TEXT1 = new TEXT(this.STREAMSOURCE1.GROUP2.footerBand)
>    with (this.STREAMSOURCE1.GROUP2.footerBand.TEXT1)
>       height = 1.0
>       left = 6.5
>       top = 0.0
>       width = 12.0
>       visible = false
>       prefixEnable = false
>       text = "Text1"
>    endwith
>
>    with (this.STREAMSOURCE1.GROUP2.headerBand)
>       preRender = class::HEADERBAND_PRERENDER1
>       height = 6.0
>    endwith
>
>    this.STREAMSOURCE1.GROUP2.headerBand.TEXTDATA11 = new TEXT(this.STREAMSOURCE1.GROUP2.headerBand)
>    with (this.STREAMSOURCE1.GROUP2.headerBand.TEXTDATA11)
>       canRender = class::TEXTDATA11_CANRENDER
>       height = 1.0
>       left = 14.5
>       top = 4.0
>       width = 7.0
>       variableHeight = true
>       prefixEnable = false
>       text = {||this.form.snake1.rowset.fields["data1"].value}
>    endwith
>
>    this.STREAMSOURCE1.GROUP2.headerBand.TEXT1 = new TEXT(this.STREAMSOURCE1.GROUP2.headerBand)
>    with (this.STREAMSOURCE1.GROUP2.headerBand.TEXT1)
>       canRender = class::TEXT1_CANRENDER
>       height = 1.0
>       left = 1.8333
>       top = 4.0
>       width = 12.0
>       prefixEnable = false
>       alignHorizontal = 2        // Right
>       text = "Match No"
>    endwith
>
>    this.STREAMSOURCE1.GROUP2.headerBand.TEXT2 = new TEXT(this.STREAMSOURCE1.GROUP2.headerBand)
>    with (this.STREAMSOURCE1.GROUP2.headerBand.TEXT2)
>       height = 1.0
>       left = 3.6667
>       top = 1.15
>       width = 26.1667
>       prefixEnable = false
>       fontSize = 12.0
>       fontBold = true
>       text = "Late entries"
>    endwith
>
>    with (this.STREAMSOURCE1.detailBand)
>       onRender = class::DETAILBAND_ONRENDER
>       height = 0.8333
>    endwith
>
>    this.STREAMSOURCE1.detailBand.TEXTDATA1 = new TEXT(this.STREAMSOURCE1.detailBand)
>    with (this.STREAMSOURCE1.detailBand.TEXTDATA1)
>       height = 0.9767
>       left = 3.6666
>       top = 0.3433
>       width = 27.8333
>       variableHeight = true
>       prefixEnable = false
>       text = {||this.form.snake1.rowset.fields["data"].value}
>    endwith
>
>    with (this.printer)
>       duplex = 1        // None
>       orientation = 1        // Portrait
>       paperSource = 7
>       paperSize = 9
>       resolution = 3        // Medium
>       color = 2        // Color
>       trueTypeFonts = 1        // Bitmap
>    endwith
>
>    with (this.reportGroup.footerBand)
>       height = 0.8333
>    endwith
>
>    this.firstPageTemplate = this.form.pagetemplate1
>    this.form.pagetemplate1.nextPageTemplate = this.form.pagetemplate1
>    this.form.pagetemplate1.streamframe1.streamSource = this.form.streamsource1
>    this.form.pagetemplate1.streamframe2.streamSource = this.form.streamsource1
>    this.form.streamsource1.rowset = this.form.snake1.rowset
>
>    function DETAILBAND_onRender()
>           this.parent.group2.footerband.text1.text :=  this.renderOffset
>       return
>
>    function FOOTERBAND_onRender()
>      //group2 footerband.
>      //check if there is enough space for another match.  If not go to a new fame
>            if  this.parent.parent.parent.streamframe1.height - this.parent.footerband.text1.text <  8
>                         this.parent.headerband.beginNewframe := true
>                 else
>                         this.parent.headerband.beginNewframe := false
>                 endif    
>       return
>
>
>     function HEADERBAND_onRender()
>       //group1 headerband
>      //Check if there is enough space for additional matches.  If not force group2 headerband to a new frame
>      //Adjust the value if necessary
>            if  this.parent.parent.parent.streamframe1.height - this.parent.parent.group2.footerband.text1.text <  12
>                         this.parent.parent.group2.headerband.beginNewframe := true
>                 else
>                         this.parent.parent.group2.headerband.beginNewframe := false
>                 endif          
>       return
>
>    function HEADERBAND_preRender()
>         //group1 headerband
>         //Set height to 0 here so that the headerband shows in the designer
>        this.height  := 0
>         return
>
>    function HEADERBAND_preRender1()
>       //group2 headerband
>           if this.parent.parent.parent.snake1.rowset.fields["late_entry"].value = true
>               //Resize the group2 headerband  and show "Late entries"  text and hide the match no
>                this.beginNewframe := true
>                this.text2.height := 1
>                this.text2.top := 1
>                this.text1.top := 0
>                this.textdata11.top := 0
>                this.height := 3
>            else
>               //Resize the group2 headerband and hide the "Late entries" text.
>               this.text2.height := 0
>               this.text2.top := 0
>                this.text1.top := 2
>                this.textdata11.top := 2    
>                this.height := 3
>             endif      
>       return
>
>
>    function TEXT1_canRender()
>      //Don't print for dummy match 99
>       lRet = true
>       if this.parent.textdata11.text() = '99'
>          lRet = false
>       endif  
>       return lRet
>
>    function TEXTDATA11_canRender()
>      //Don't print for dummy match 99
>       lRet = true
>       if this.text() = '99'
>           lRet = false
>       endif    
>       return lRet
>
> endclass
>
>