TIP: Click on subject to list as thread! ANSI
echo: z3_pascal
to: Darryl Luff
from: Peter Lavender
date: 1996-04-20 21:33:28
subject: Sorting an array?

Hi Darryl,

And thus Darryl let it be known to Peter:

  DL>     Hi Peter,

Hey there.. hows things.  That 286 I got is still in pieces... I might get
round to setting it up on day.. :)

[..cut..]

  DL>     If WhichArray contains 'Customer', then WhichArray[1] = 'C',
  DL> WhichArray[2] = 'u', etc. You're sorting using the string in
  DL> WhichArray instead of the data in the arrays.

Ahh..  I see.

  DL>     To do this, you'd have to use something like:

  DL> VAR
  DL>   fltNum    : Array[1..10] OF String;
  DL>   customer  : Array[1..10] OF String;
  DL>   sear      : Array[1..10] OF Integer;

  DL> PROCEDURE Sort(sortOn : Char);
  DL> BEGIN
  DL>   IF (sortOn = 'C') THEN
  DL>   BEGIN
  DL>     { do the sort using customer    }
  DL>   END

[..etc..]

  DL> You can't use a string as the name of an array, ie:

Thanks for that.  This is indeed what I ended up having to do.  The sort
works as it should, I was just hoping to cut down on what really is
redundant code, since all I did was cut and paste the sorting code and
change the array to sort.

It also means that if I add more info, say arrival and depart times and I
want to do a sort on that, I now have to add the code _again_.  Pity it
couldn't be done in the manner I had tried.  That way all that needs to be
done is a a few lines of extra code rather than a few screens of code.

Thanks for clearing it up tho.



Cya,

Pete

... Nothing is fool-proof as long as there are fools.
--- GoldED/386 2.50 UNREG
--- 
* Origin: Reality Sucks Back from Reality. (3:635/309)
SEEN-BY: 633/267 270
@PATH: 635/309 727 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.