I am a trial and error man. Right now I try to figure out how to sort records.
I have some questions and some coding.
The sort routine Ive found on the net and in the helpfile on Delphi 5 looks like this:
function Compare(Item1, Item2: Pointer): Integer;
if PM(Item1)^.TestPM(Item2)^.Test then Result :=1;
if PM(Item1)^.Test=PM(Item2)^.Test then Result :=0;
Above PM is what I used when I declared the type.
PM = ^TM;
TM = record
Why do I have to use PM and and not PTette (Var PTette : PM)? Is it because I use it in a function?
Does the routine above sort more than 2 items without me telling it to?
Because the only call Ive found to the routine is: List.Sort(@Compare)
I tried without the '@', dont even know what that character does to it.
In my program I try to sort some numbers (3 to 0), Is it in that coding I make the error?
procedure TForm1.FormCreate(Sender: TObject);
for a:=0 to 3 do
Or maybe the big error lies in this coding?
I am unsure if I am on the right way using TList.Items to point to the record I want to use, if not, what is the right way?
Have I got it all right when I understand the ^like this?
^P points to an address in the memory, but p^ is used to use the contense of an address?
procedure TForm1.Button1Click(Sender: TObject);
I hope someone understands my questions, otherwise tell me so I can make another try to ask my questions.
Regards Stefan, Sweden