Board index » delphi » Sorting a table, non alphabetical and alphabetical (mixed)

Sorting a table, non alphabetical and alphabetical (mixed)

Who's a wizz on Paradox tables. Who can releive my troubled mind...

The problem is this:

I have a table in the order in which it is inputted (paradox). into my
program. Now I need to make two sets of files out of this. One set has to
be orderderd like this:

Province        town
gr              (alphabetical)
fr              (alphabetical)
dr              (alphabetical)
ov              (alphabetical)
ge              (alphabetical

etc.....

The second set has to be ordered in this order:

Group           Item
(alphabetical)  (alphabetical)

Now I'm going to make a text-file for each record in the table. In that
file I have to put general data, plus a notification of:

The previous record in set 1, the next record in set 1, the previous record
in set 2, the next record in set 2

How do I acomplish this in the easiest way? I haven't made normal indexes
before either, so if some basic knowledge is required, please include that
in your answer.

Thanks to all who want to help me!

Yours Sincerly

Marc van leeuwen
mar...@localaccess.nl
m...@m4groep.nl
http://www.localaccess.nl/marcvl/pasnet.htm

 

Re:Sorting a table, non alphabetical and alphabetical (mixed)


Hi there Marc,

Unfortunately there is no quick solution to your problem, except to pick up
a book and learn SQL. Using a SQL statement in a Query component within
Delphi you should be able to order your tables on the fly, and condtionally
link data from one or more tables to another.

SQL can be as simple as Select * from MyTable, or it can get extremely
complex and melt your brain, hence the reason I suggested picking up a
book.

I haven't seen this book myself yet but you really could do a lot worse
than take a look at the Database Developers Guide with Delphi 2.0,
published by Sams Press. As I said, I have yet to see this book in the
flesh, but judging from the quality of the equivalent titles for Visual C++
and Visual Basic it should be an excellent book and give you all the
material you need.

Good luck with your project,

Peter Wright.
--
=-=-=----=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Surfing, browsing, crawling, crashing?
  http://www.gendev.demon.co.uk
  ^^^  Try STALKING instead.  ^^^^

          Psynet Interactive Ltd      
       Suite  3, 22 Silverdale Rd    
       Eastbourne, East Sussex    
       England,         BN20 7AZ
=-=-=----=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Re:Sorting a table, non alphabetical and alphabetical (mixed)


In article <01bbdd95$960e3640$8a279...@gendev.demon.co.ukq>,
pe...@gendev.demon.co.uk says...

Quote

>Hi there Marc,

>Unfortunately there is no quick solution to your problem, except to pick up
>a book and learn SQL. Using a SQL statement in a Query component within
>Delphi you should be able to order your tables on the fly, and condtionally
>link data from one or more tables to another.

I find it easy to work with TStringList.  To sort the list on a number I use
the following "cludge":  Let's say the number, N, is in positions 11-15, and
is between -20 and +20.  I change each record in the stringlist:

  with MystringList do
  for i := 0 to count-1 do begin
   x := 100+strtoint(copy(strings[i],11,15));
   strings[i] := format('%6d',[x]) + strings[i];
   end;

  MystringList.sort;

This approach seems to work fine.

Other Threads