-Collapse +Expand
Paradox
Search Paradox Group:

Advanced
Paradox To/From
To/FromCODEGuides
Paradox Store
PRESTWOODSTORE

Prestwood eMagazine

April Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyCorel Paradox / ObjectPAL Coding BoardParadox Reports Topic   Print This     

Top 25 Customers Report

Top 25 Customers Report in Paradox Reports topic (part of our Corel Paradox / ObjectPAL Coding group).

Quick Search: Customers   Top 25   Top 25 Customers  
since92
I am writing a routine in objectpal to get the top 25 customers into a table and subsequently a report. I can sort the table using "custTbl.attach" and "sort descending" like:

custTbl.attach("sortme.db")
sort custTbl
on ":PRIV:revenue" D
to ":PRIV:sorted.db"
endSort

But I need some form of TCursor loop or similar method to peel off the first (top) 25 customers.

I could not find a 'Top n' feature in Paradox Reports
Currently using Paradox 11 with sp2.
Any assistance or links to a solution appreciated.
 Posted 21 years ago (Thread Starter)
Comment Quote
About since92
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #11323, 6 replies
Thread Started 10/16/2005 6:41:00 PM
View Counter=3175
Last Reply Posted 10/18/2005 10:32:00 PM)
Location= 
Joined=21 years ago   MB Posts=9  
CliffSuttle
Michigan
This one is real easy.

var
darr dynArray[] anytype
tc tCursor
rev currency
endVar

; sort your table first as in your email

tc.open(":priv:sortme.db")
tc.moveToRecNo(25)
rev = tc."revenue"
darr["Revenue"] = ">=" + string(rev)
tc.setGenFilter(darr)
tc.copy(":PRIV:top25.db")

; that's it

Cliff Suttle
Antler Software Technologies
www.AntlerSoftware.com
Cliff's Corner Author, Prestwood eMag

 Posted 21 years ago
Comment Quote
About CliffSuttle
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About CliffSuttle

Mr. Suttle is the President of Antler Software Technologies and is one of the leading authorities on relational data bases in the mid-west. He has been working with Paradox since version 1.0 for DOS (circa 1987).


Post ID #11324 (Level 1.1)  Reply to 11323
Thread Started 10/16/2005 8:14:00 PM
View Counter=2
Location=Michigan  
Joined=25 years ago   MB Posts=90   KB Posts=4  
Tony M
 (Inactive)
*Slightly* different than Cliff's.

======================
movetorecno(), HELP
This method is recommended only for dBASE tables. If used for a Paradox table, moveToRecNo behaves exactly like the moveToRecord method.
======================

tc.movetorecord(min(25,tc.nrecords()))
Then do Cliff's stuff.

This way, if there are fewer than 25 records in the table, you are covered.

Also, you will probably want to open the table resulting from the copy and verify that there are only 25 records. You could have more than one with the exact 'revenue' value of that 25th record.

In case there are more than 25 after copy,
tc.open(":priv:top25.db")
if tc.nrecords()>25 then
tc.edit()
tc.movetorecord(26)
while true
tc.deleterecord()
if tc.recno()=25 then
quitloop
endif
endwhile
tc.endedit()
endif
tc.close()
 Posted 21 years ago
Comment Quote
About Tony M
Visit Profile
Inactive member.
Member does not subscribe to this thread.

Post ID #11325 (Level 1.2)  Reply to 11323
Reply Posted 10/16/2005 8:52:00 PM
Location= 
Joined=24 years ago   MB Posts=410   KB Comments=1  
Tony M
 (Inactive)
> darr["revenue"] = ">=" +string(rev)

You might change this and try

darr["revenue"] = "not blank, >=" +string(rev)
 Posted 21 years ago
Comment Quote
About Tony M
Visit Profile
Inactive member.
Member does not subscribe to this thread.

Post ID #11327 (Level 1.3)  Reply to 11323
Reply Posted 10/17/2005 10:18:00 PM
Location= 
Joined=24 years ago   MB Posts=410   KB Comments=1  
Tony M
 (Inactive)
Thinking about it further, I would change

tc.movetorecord(26)

to

tc.end()

No use flirting with where the tcursor winds up after a delete.
 Posted 21 years ago
Comment Quote
About Tony M
Visit Profile
Inactive member.
Member does not subscribe to this thread.

Post ID #11328 (Level 1.4)  Reply to 11323
Reply Posted 10/17/2005 10:47:00 PM
Location= 
Joined=24 years ago   MB Posts=410   KB Comments=1  
since92
Thanks for the help Cliff & Montana, it's good to know there is help out there. The code works fine as you suggested and is giving me the result I needed. I did however try out adding a variable, so the end user can enter on the form, say the top 30 or 50 customers depending on what's required. I made it something like this:

method pushButton(var eventInfo Event)
var
custTbl Table
tv TableView
darr dynArray[] anytype
tc tCursor
rev currency
n String
endVar
n = qty
custTbl.attach("sortme.db")
sort custTbl
on "revenue" D
to "sorted.db"
endSort
tc.open("sorted.db")
tc.moveToRecNo(n)
rev = tc."revenue"
darr["revenue"] = ">=" +string(rev)
tc.setGenFilter(darr)
tc.copy("top25.db")
tv.open("top25.db")
endMethod

where "qty" is a field on the form. This worked fine as well, until I entered a value >=70 then the whole table was returned. It turned out that I only had values in 69 records for 'revenue' the rest being blank or no sales. I will now try incorporating Montana's loop to remove '>n'records.
Once again thanks for the assistance.
 Posted 21 years ago (Thread Starter)
Comment Quote
About since92
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #11326 (Level 1.5)  Reply to 11323
Reply Posted 10/17/2005 6:38:00 PM
Location= 
Joined=21 years ago   MB Posts=9  
Most Recent Post
since92
tried:
darr["revenue"] = "not blank, >=" +string(rev)
But it returned the whole table :-( I guess "not blank" does not work the same as in queries in this instance.
Overall though the primary objective has been achieved, thanks once again.
 Posted 21 years ago (Thread Starter)
Comment Quote
About since92
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #11332 (Level 1.6)  Reply to 11323
Reply Posted 10/18/2005 10:32:00 PM
Location= 
Joined=21 years ago   MB Posts=9  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1213A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #11323 Counter
3175
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2026 Prestwood IT Solutions.   [Security & Privacy]