It's the weekend again, and my chance to learn some of the new features...

Trying to implement Batches and RowSet, and still not using Fusebox as yet...

The search yields 115 records, a decent size for testing. Given the following code:

import("RowSet")
import("Batch")
    $map := """companyid:[Companies]ID;companyname:[Companies]Name"""
    $rs := RowSet.newFromSelection(->[Companies]; $map)

// Get the starting index from the query string. If it wasn't there
// the num() of it will be zero, so force it to 1.

c_longint($attributes)
$attributes := merge collections(form variables; query params)

$start := max of(num($attributes{"bst"}); 1)

// Now make the batch
$batch := Batch.NewFromRowSet($rs; 20; $start; 0; 3)

// Setup the link info, make the links
$previous := "<< Previous|batch-previous"
$pages := " "
$batches := " "
$next := "Next >>|batch-next"
$href:=full requested url

$needPages := $batch->makeLinks($previous; $pages; $next; $href;"$nbsp;";Batch.kStartParam;10)

$row := $rs->getRow %>
<tr><td colspan="2" class="celltitle"><% =$previous + $pages + $next %></td></tr>
   <%  $loop:=0
           for ($loop; $batch{"start"}; $batch{"end"})
                $rs->gotoRow($loop)
                $Color:=RowColor_Get($loop)
                $id := EncodeQueryString(string([Companies]ID))
                $key := EncodeQueryString("CID")
                $query := build query string(""; $key; $id) %>
<tr><td bgcolor="<% =$Color %>"><a href="/companies/home.html<% = $query %>"><% =$row{"companyid"} %></a></td>
<td bgcolor="<% =$Color %>"><% =$row{"companyname"} %></td></tr>
<% end for %>

the initial page displays 20 records and the batch link is " Next >>" (but no page numbers) clicking "Next" give the next 20 records (so far so good) and the links are "<<Prev Next >>" (again no page numbers)
clicking either Prev or Next gives the error:

$start := max of(num($attributes{"bst"}); 1)
Expecting a numeric expression or a text expression or a boolean expression.

Would some explain the what and the why? Or barring that, a working, non-fusebox example of batches and rowset.

--
Bart Alcorn          AvantraNet, Inc.
Office:   678-580-3265
Mobile: 770-335-5518
AIM/iChat: AvantraNet

_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to