[fpc-pascal] GetPropValue and Unknown property

Leonardo M. Ramé martinrame at yahoo.com
Tue Jun 23 13:54:44 CEST 2009

How are you filling the ASortProps array? if it is by hand, you have to take care of Case Sensitivity of property names.

You can use this function to know the published properties of any class. Try it inside your DoCompareProps, passing TFTPListRec(AItem1).ClassType as param, if AItem1 is an instance it should list all its properties:

procedure GetClassProperties(AClass: TClass);
(* get published properties into a list *)
  PropList:      ppropList;
  ClassTypeInfo: PTypeInfo;
  I:             Integer;
  lProps:        Integer;
  (* Get properties and a pointer to class *)
  lProps := GetTypeData(AClass.ClassInfo)^.PropCount;
  if lProps <> 0 then
    (* Properties list to be analyzed *)
    for I := 0 to GetPropList(AClass.ClassInfo, PropList) -1 do


Leonardo M. Ramé

----- Original Message ----
From: Antonio Sanguigni <a.sanguigni at gmail.com>
To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
Sent: Tuesday, June 23, 2009 7:41:56 AM
Subject: [fpc-pascal] GetPropValue and Unknown property

Hi all,

I'm trying to derive a new class TSortFtpSend from synapse TFtpSend
class, which implements a quicksort algo based on published property
passed to this method.
I'm having some troubles with this code because GetPropValue seems
does not find the published property I need:

function TSortFtpSend.DoCompareByProps(AItem1: Pointer; AItem2: Pointer;
  const ASortProps: array of string; AAscendingOrder: Boolean): integer;
  i : integer;
  lsPropName : string;
  lValue1 : variant;
  lValue2 : variant;
  result := 0;
//  try
    for i := Low(ASortProps) to High(ASortProps) do
      lsPropName := ASortProps[i];
      lValue1 := GetPropValue(TFTPListRec(AItem1),lsPropName); // <==
Here I got the Unknown property FileSize exception
      lValue2 := GetPropValue(TFTPListRec(AItem2),lsPropName);


It seems GetPropValue cannot find published property FileSize but the
writeln statement works well printing the exact value, and of course
the properties are published. Someone has an idea why that is not
working here ?


Antonio Sanguigni alias slapshot
GioveLUG (Linux User Group) - http://www.giovelug.org
Edupup (Educational distro) - http://www.pieroni.biz/edupup
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org


More information about the fpc-pascal mailing list