` Printed Icetips Article

Icetips Article



Par2: Additional Sort Order in CW2
1998-07-13 -- Dan Presnell
 
This works with the CW2 templates and Clarion 4.  I can't get it to work
in Clarion 2.003, because CW4 has a resort(view, file) command that CW2
doesn't support.

If I had to name the things that make me wish my CW2 style programs were
using the ABC templates, the "additional sort order" for browses would
be at or near the top.  But some of my programs are so big and bloated
with stuff specific to the CW2 style templates, I can't afford to
convert.

Here is how you do the "additional sort order" using the CW2 style
template chain, by example.  So far, it works, but others might want to
test it on their own programs.  This is from an actual test I did.

Here is the view that is constructed from the file list for the browse
procedure, as the template makes it.

BRW1::View:Browse    VIEW(Clients)
                       PROJECT(CLI:ClientID)
                       PROJECT(CLI:Name)
                       PROJECT(CLI:MailName)
                       PROJECT(CLI:Salutation)
                       PROJECT(CLI:DateOpened)
                       PROJECT(CLI:DateClosed)
                       PROJECT(CLI:InHouseNumber)
                       PROJECT(CLI:DoNotBill)
                       PROJECT(CLI:OnlyOneStatement)
                     END

The three tabs that I started with on the browse are all, of course, on
keys for the clients file.

Now, here is how to add a sort order on cli:dateopened for the browse
(which is not a key field).

1.  In the window formatter, add a tab.  In my case this was the 4th
tab.

2.  Right click on the browse box and choose "Action."  Under the
conditional tab there, add the condition for the new sort order.  In my
case, it is choice(?currenttab)=4.

3.  For the key for the new sort order, leave it blank.  You won't be
able to use a locator because of this, but you just can't do this by
specifying a key.  (I don't think....)

4.  IF the browse is limited in some way, type the filter in.  Any file
relationship limits have to be typed here (such as
"cus:id=acc:custid").  Any other filter conditions should be specified
there too.

5.  Now right click on the browse box and go to embeds.

6.  In the embed "Before opening view" enter this source:

    if choice(?currenttab)=4
       brw1::view:browse{prop:order}='CLI:DateOpened'
     .

    This should be self explanatory.

7.  In the embed "After opening view" enter this source:

     if choice(?currenttab)=4
       reset(brw1::view:browse, clients)
     .

     This resets the view order and position based on the current
position of the primary file Clients.  (This is the part not supported
by CW2.)

NOTE:  You cannot use the source editor enter these embeds.  This is
because somehow, this stuff is generated TWICE for each embed.  So you
can't just go to "the" embed point and edit it.

That's it.  The new sort order should be implemented.  Note that because
you are using the prop:order to set the sort order of the view, you can
sort on not only the primary file, but related files as well.  (Read the
manual.)

I've tried to simulate the reset(view, primaryfile) command in CW2, but
haven't been able to do it.  Does anybody know how to get this to work
in CW2?

Pardon any typos... I have a tendency to muck this stuff up when typing
this much.  My message editor doesn't give me compile errors. :)



Printed November 21, 2024, 11:43 am
This article has been viewed/printed 35190 times.