f



Is possible / or how to run?

Is following possible or how to run? I get a crash at the Line GetPropList 
....

TMyClass = class
  AString : string
end;

procedure func1;
begin
  func2(TMyClass); // The Object not a Instanz of a Object (similar to the 
Function SizeOf)
end;

procedure func2(AClassRef : TClass);
var    PropList : TPropList;

begin
  GetPropList(AClassRef.ClassInfo, tkProperties, @PropList);
end

Or how I get the information about field name and typ without a Instanz?

Frank



0
Frank
9/18/2004 3:30:38 AM
comp.lang.pascal.delphi.misc 5769 articles. 1 followers. miniFAQ (1) is leader. Post Follow

3 Replies
400 Views

Similar Articles

[PageSpeed] 10

In article <414babdf$0$162$9b622d9e@news.freenet.de>, "Frank Hahn"
<franky15@freenet.de> writes:

>Or how I get the information about field name and typ without a Instanz?
>

Works for me ...

uses
  TypInfo;

const
  TypeKindStr : array[TTypeKind] of string =
     ('tkUnknown', 'tkInteger', 'tkChar', 'tkEnumeration', 'tkFloat',
      'tkString', 'tkSet', 'tkClass', 'tkMethod', 'tkWChar',
      'tkLString', 'tkWString', 'tkVariant', 'tkArray', 'tkRecord',
      'tkInterface');

procedure FillPropStrings(AClass : TClass; Strings : TStrings);
var
  PropList : TPropList;
  PropListCount, i : integer;
begin
  PropListCount := GetPropList(AClass.ClassInfo, tkProperties, @PropList);
  for i := 0 to PropListCount - 1 do
    Strings.Add(PropList[i].Name +' : '
                + TypeKindStr[PropList[i].PropType^.Kind]);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  FillPropStrings(TForm, ListBox1.Items);
end;

Secrets of Delphi 2 / 3 / etc by Ray Lischner is a good source

Alan Lloyd
alanglloyd@aol.com
0
alanglloyd
9/18/2004 8:48:18 AM
In article <414babdf$0$162$9b622d9e@news.freenet.de>, AlanGLLoyd writes:

>Works for me ...

Additionally - the following adds the type of the property as well as the kind.
Also it seems to work for a TListView when I don't have one on the form.

uses
  TypInfo;

const
  TypeKindStr : array[TTypeKind] of string =
     ('tkUnknown', 'tkInteger', 'tkChar', 'tkEnumeration', 'tkFloat',
      'tkString', 'tkSet', 'tkClass', 'tkMethod', 'tkWChar',
      'tkLString', 'tkWString', 'tkVariant', 'tkArray', 'tkRecord',
      'tkInterface');

procedure FillPropStrings(AClass : TClass; Strings : TStrings);
var
  PropList : TPropList;
  PropListCount, i : integer;
begin
  PropListCount := GetPropList(AClass.ClassInfo, tkProperties, @PropList);
  Strings.Clear;
  for i := 0 to PropListCount - 1 do
    Strings.Add(PropList[i].Name + ' ('
                + TypeKindStr[PropList[i].PropType^.Kind] + ') : '
                + PropList[i].PropType^.Name);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ListBox1.Clear;
  ListBox1.Items.BeginUpdate;
  FillPropStrings(TListView, ListBox1.Items);
  ListBox1.Items.EndUpdate;
end;


Alan Lloyd
alanglloyd@aol.com
0
alanglloyd
9/18/2004 10:04:29 AM
Frank Hahn wrote:
> Is following possible or how to run? I get a crash at the Line GetPropList 

"Get a crash" isn't very descriptive. Quote the type of the exception 
you get, and its error message.

> TMyClass = class
>   AString : string
> end;
> 
> procedure func1;
> begin
>   func2(TMyClass); // The Object not a Instanz of a Object (similar to the 
> Function SizeOf)
> end;
> 
> procedure func2(AClassRef : TClass);
> var    PropList : TPropList;
> 
> begin
>   GetPropList(AClassRef.ClassInfo, tkProperties, @PropList);
> end

The ClassInfo function returns a pointer to the class's RTTI. RTTI is 
not generated for class types unless they are compiled in the $M+ 
compiler state or descend form a class so compiled (such as TPersistent).

Besides, the class you're using doesn't have any properties.

-- 
Rob
0
Rob
9/18/2004 7:02:33 PM
Reply:

Similar Artilces:

misc, refocus: new possible lang idea, BSC
this is a misc and hypothetical idea: IMO all this is unlikely to move much beyond a personal effort. well, I have been beating together a C compiler, and also ended up thinking some about my script lang, integration, ... in this, I have come up with a new possible idea: I don't fully implement C, per se, but technically a different language that just happens to be mostly backwards compatible and can link directly with C (and the existing C runtime, another goal). so, the name BSC will mean BGB-Script/C, or a kind of hybrid (my current script lang is called BGB-Script, and sort of...

Is it possible to run WINE without a DE running?
Hey :) I'm setting up a little personal server to serve files and other stuff. One thing I'd like it to do is to run DC++ 24/7, but I'd like to not run a desktop environment unless it's absolutely necessary. Is it possible to run a graphical app in WINE without running a DE? TIA, Daniel -- "I marry Calculon, divorce him, take half his money, and turn back into a guy - it's sort of a two-person pyramid scheme." --Bender In article <34l8epF4c11nbU1@individual.net>, DanielEKFA <sorry.no.em@il.i.get.vira.and.spam.invalid> writes: &...

is downgrading from Delphi 7 to Delphi 6 or 5 possible???
Hi, folks, I am writing a program together with a friend. The prob is he is using delphi 7 and I have Delphi 5 and 6. Is it possible to continue writing programs which are made in Delphi 7 with the previous versions: Delphi 5 or 6? Or do you have to make large changes to the D7- source code for this? And if it is possible which version is the best for me to use, Delphi 5 or 6? All help is very welcome, already thanks for your advise! Regards Fred Tarvak wrote: > Hi, folks, > > I am writing a program together with a friend. > The prob is he is using delph...

AS400 runs, and runs, and runs
A friend went to a conference last week. One of the speakers said they went to a location as a consultant to review their systems and suggest possible upgrades. The consultants found the file servers but they couldn't find any physical device that was actually performing the daily business task. After a day of searching and tracing cables they had maintenance rip the drywall from an interior wall. Behind the drywall was a closet door, in the closet was an AS400. None of the current employees knew the AS400 existed. It had been buried inside a closet for at least 5 years, but it was stil...

Pascal and Delphi
Pascal, is the old SDK we use. Now, shall we move on to Delphi? "Boo K.M." <khanming@brinkster.net> schrieb im Newsbeitrag news:42e5bd1e_2@news.tm.net.my... > Pascal, is the old SDK we use. Now, shall we move on to Delphi? Why not? PASCAL is not a SDK, but a programming language. Delphi is not a language, but a SDK which uses the PASCAL language. Did you create windows apps in your former SDK using PASCAL? I regard Delphi to be a very straight forward SDK for creating windows apps. The promise in advertising "RAD" (rapid application development) is...

Run as is it possible ??
hello, can i run an executable file from vb with a privilege of an admin on xp or other windows ?? ex: in win 2000 prof we can right click an icon and select run as and select the user name and password so can we do this process run as from the vb code ?? thx a lot. *** Sent via Developersdex http://www.developersdex.com *** ...

run of thread, why codes of run(), only run once ?????
Hi, All, For MIDLET, Runnable, there is a thread, but, why my run(), only run once only? not a loop? Best regards, Boki. Boki a �crit : > Hi, All, > For MIDLET, Runnable, there is a thread, but, why my run(), > only run once only? not a loop? > > > Best regards, > Boki. > > when you have a thread, this is normal that it runs only once . You have the init() run and end method that are call, you must include your while(true or test) in head of run() if you do not that, how does the thread know to end the method !? Best regard...

why the pascal family of languages (Pascal, Ada, Modula-2,2,Oberon, Delphi, Algol,...) failed compared to the C family?
The first language I really liked was Pascal. But the Pascal family of languages (including Ada) have clearly failed to become popular, at least compared to the C-family (C, C++, C#, ....) The question is why did this happen? My theory: C was used to develop Unix/Linux and Windows, and this made it easier for applications to be written in C/C++ since the interface to the OS was easier. VMS did not choose C (considered a huge blunder by many. They choose Bliss http://en.wikipedia.org/wiki/BLISS instead! and we all know what happens to VMS. What is your theory on this? Was t...

sql running slow when run from java but runs fine when run from toad
A sql statement is taking a long time to run from Java, but it runs quicky from Toad. I am on 10.1.0 on Windows. Can anybody tell me where to look at? Thanks. I am pasting two trace files below. This is the TRACE File generated when i run the query from TOAD: ***************************************************************************************************** Dump file c:\oracle\product\10.1.0\admin\saracenp\udump\saracenp_ora_6028.trc Thu May 04 16:40:48 2006 ORACLE V10.1.0.2.0 - Production vsnsta=0 vsnsql=13 vsnxtr=3 Oracle Database 10g Release 10.1.0.2.0 - Production Windows Server 2003...

Fortran to Delphi (pascal)
Hi there; How to convert the below statement which is written in a Fortran code to Delphi? DVS = INTGRL(DVS, DVR, 1) Thanks for your help. Best Mo. On 27 Nov 2003 09:00:59 -0800, dariush2003jp@yahoo.com (Darius) wrote: >How to convert the below statement which is written in a Fortran code to Delphi? > >DVS = INTGRL(DVS, DVR, 1) The last time I used FORTRAN (a long time ago) INTGRL was not part of the language, so I assume that it is a function declared by the programmer. If so, the translation is DVS := INTGRL(DVS, DVR, 1); But if INTGRL is something built ...

Pascal/Delphi Kermit
Hello all, I am looking for implementing the Kermit protocol into an application. (I am a one-man company and doing special contract software in the auto-id market) Currently, our customer uses a registered version of Kermit-95 but is not completely happy with it as it uses a flock of features he never will need and his point and click dudes have difficulties with the commandline interface.- So he is asking for something simple, included into some custom specific application. When searching the net I found the QKKermit 3.0 (Ported from CP/M); Finally I realized that this also c...

Turbo Pascal to Delphi
Dear All, I'm Sagar, an Indian student working in Germany towards a project in Rheology. Sir, the software we use is based on Turbo Pascal while we need it in Delphi. I'm not so great at programming and have only used Fortran to some extent in my undergraduate study at the Indian Institute of Technology, IIT Bombay. The source files are huge (For me i.e.) which amount to some lakhs of lines. I would be highly obliged if you could tell me whether there is an easier way to do this rather than understanding the whole code and rewriting it again in Delphi. Look...

Is it possible for MATLAB to run a .exe?
I have a program written in C++ which produces output that will be processed in MATLAB. To save the trouble of creating MEX files, is there any way that I can just have MATLAB call the .exe somehow? Thanks Julian wrote: > I have a program written in C++ which produces output that will be > processed in MATLAB. To save the trouble of creating MEX files, is > there any way that I can just have MATLAB call the .exe somehow? > > Thanks If it's in your PATH, try system Christopher Hulbert wrote: > > > Julian wrote: >> I have a program written in C++ which prod...

Is it possible to run Tcl from Ruby??
Hey I would like to know whether its possible to integrate Ruby with Tcl?? Ie create a Tcl frontend with a Ruby backend?? Also if its possible to create databases in Ruby?? On 2013-03-12, ishaanbaokar@gmail.com <ishaanbaokar@gmail.com> wrote: > Hey I would like to know whether its possible to integrate Ruby with Tcl?? > Ie create a Tcl frontend with a Ruby backend?? > Also if its possible to create databases in Ruby?? Do you mean Tk? -- maus . . .... ...

Web resources about - Is possible / or how to run? - comp.lang.pascal.delphi.misc

New Hampshire Primary Wrap-Up
[Content Note: Islamophobia; misogyny.] Congratulations to Senator Bernie Sanders, who not only decisively won the New Hampshire primary last ...

What does the Supreme Court's emissions regulation freeze mean?
Christian Science Monitor What does the Supreme Court's emissions regulation freeze mean? Christian Science Monitor The US Supreme Court's ...

IoT Could Be Used To Spy, Admits James Clapper
The latest high profile individual to debunk the notion that surveillance is at risk of ‘going dark’ in an age of increasingly robust encryption ...

The hilarious final chapter of Tim Cook’s humiliating blurry Super Bowl photo saga
It appears as though Apple CEO Tim Cook agrees with my assessment of the iPhone 6s Plus : it's the first iPhone I simply couldn't live with . ...

Rocket League on Xbox One gets a release date, bonus items
Regardless of what platform you choose to game on, you're always going to have to deal with timed exclusives for a different one. Timed exclusives ...

Kanye West tweets ‘Bill Cosby Innocent’ because he’s absolutely an idiot
Kanye West was tweeting nonsense for a full 24 hours yesterday. Everyone thought it was cute… until it wasn’t. In the midst of promoting his ...

Apple bringing more of its content delivery in-house, possible preparation for streaming TV
When you download or stream content from Apple – be it Apple Music, an app or an OS X update – that content is often delivered by a third-party ...

Warner Pays $14 Million For Illegitimate “Happy Birthday” Claims
Happy Birthday is one of the best known songs worldwide and up until a few months ago Warner/Chappell music claimed to own the rights. The melody ...

Skype Partners With Sir Paul McCartney To Launch 10 Valentine’s Day ‘Mojis’
If you’re a Skype user, chances are somebody will send you an emoticon of a flirting banana in the next couple of days (accompanied by a short ...

US regulators: Google's self-driving car AI 'can be a driver'
Filed under: Government/Legal , Green , Transportation Alternatives , Emerging Technologies , Technology , Electric The NHTSA finds that Google's ...

Resources last updated: 2/10/2016 3:16:23 PM