AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Get count of members in record

Ein Thema von nanix · begonnen am 10. Jan 2010 · letzter Beitrag vom 10. Jan 2010
Antwort Antwort
Seite 1 von 2  1 2      
nanix
(Gast)

n/a Beiträge
 
#1

Get count of members in record

  Alt 10. Jan 2010, 12:07
Delphi-Quellcode:
PerfFormattedData_PerfOS_Processor = record
  C1TransitionsPerSec: String;
  C2TransitionsPerSec: String;
  C3TransitionsPerSec: String;
  Caption: String;
  Description: String;
  DPCRate: String;
  DPCsQueuedPerSec: String;
  Frequency_Object: String;
  Frequency_PerfTime: String;
  Frequency_Sys100NS: String;
  InterruptsPerSec: String;
  Name: String;
  PercentC1Time: String;
  PercentC2Time: String;
  PercentC3Time: String;
  PercentDPCTime: String;
  PercentIdleTime: String;
  PercentInterruptTime: String;
  PercentPrivilegedTime: String;
  PercentProcessorTime: String;
  PercentUserTime: String;
  Timestamp_Object: String;
  Timestamp_PerfTime: String;
  Timestamp_Sys100NS: String;
end;

var
WMI_PerfFormattedData_PerfOS_Processor:array of PerfFormattedData_PerfOS_Processor;
so i could do something like this so i could reduce the code size
 WMI_PerfFormattedData_PerfOS_Processor[i].Property[i2]
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.861 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: Get count of members in record

  Alt 10. Jan 2010, 12:18
No, because the Entries are named not indexed.
Markus Kinzler
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#3

Re: Get count of members in record

  Alt 10. Jan 2010, 12:20
Well how could this be done then?Couse i have like 30 records

changing everything would be nightmare



Maybe

WMI_PerfFormattedData_PerfOS_Processor[i].Property(WMI.GetPropertyName[i2]):=WMIResults
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
 
Delphi 12 Athens
 
#4

Re: Get count of members in record

  Alt 10. Jan 2010, 12:33
If you want to have such functionality, then you must implement it yourself.

Since Delphi 2010 it is could possibly even take the new RTTI support.




since Delphi 2006 / Turbo Delphi

Delphi-Quellcode:
TPerfFormattedData_PerfOS_Processor = record
  C1TransitionsPerSec: String;
  C2TransitionsPerSec: String;
  ...
  Timestamp_Sys100NS: String;
private
  function GetProp(i: Integer): String;
public
  property Prop[i: Integer]: String read GetProp;
end;
or

Delphi-Quellcode:
TPerfFormattedData_PerfOS_Processor = record
  C1TransitionsPerSec: String;
  C2TransitionsPerSec: String;
  ...
  Timestamp_Sys100NS: String;
end;

TPerfFormattedData_PerfOS_Processor_Helper = record helper for TPerfFormattedData_PerfOS_Processor
private
  function GetProp(i: Integer): String;
public
  property Prop[i: Integer]: String read GetProp;
end;
Delphi-Quellcode:
function TPerfFormattedData_PerfOS_Processor{_Helper}.GetProp(i: Integer): String;
begin
  case i of
    0: Result := C1TransitionsPerSec;
    1: Result := C2TransitionsPerSec;
    ...
    23: Result := Timestamp_Sys100NS;
    else Raise Exception.Create('invalid index');
  end;
end;
$2B or not $2B
  Mit Zitat antworten Zitat
Benutzerbild von thkerkmann
thkerkmann

Registriert seit: 7. Jan 2006
Ort: Pulheim Brauweiler
464 Beiträge
 
Delphi 2010 Professional
 
#5

Re: Get count of members in record

  Alt 10. Jan 2010, 12:35
Hi,

if it's all string data ? why not use a dictionary instead of a record:

Use a tStringlist and add values like "ProcessorName=Intel Core2"

regards
Thomas Kerkmann
Ich hab noch einen Koffer in Borland.
http://thomaskerkmann.wordpress.com/
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#6

Re: Get count of members in record

  Alt 10. Jan 2010, 12:38
Thanks for the information but such concept isnt possible ? By name not by index

WMI_PerfFormattedData_PerfOS_Processor[i].Property(WMI.GetPropertyName[i2]):=WMIResults
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
 
Delphi 12 Athens
 
#7

Re: Get count of members in record

  Alt 10. Jan 2010, 12:48
Delphi-Quellcode:
private
  function GetProp(Name: String): String;
public
  property Prop[Name: String]: String read GetProp;
end;
$2B or not $2B
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#8

Re: Get count of members in record

  Alt 10. Jan 2010, 12:51
yea himitsu add all these functions for each record i have over 35 would be mad crazy
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
 
Delphi 12 Athens
 
#9

Re: Get count of members in record

  Alt 10. Jan 2010, 13:02
Zitat von nanix:
yea himitsu add all these functions for each record i have over 35 would be mad crazy
Well, whoever wants it easier later, you first have to invest some work.


WMI_PerfFormattedData_PerfOS_Processor: array of StringList; Hier im Forum suchenTDictionary
WMI_PerfFormattedData_PerfOS_Processor: array of TDictionary; http://www.delphipraxis.net/internal...t.php?t=156343
WMI_PerfFormattedData_PerfOS_Processor: array of TAssocArray<String>; declared in Hier im Forum suchenhimXML.pas
WMI_PerfFormattedData_PerfOS_Processor: array of TAssocStringArray; ...
$2B or not $2B
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#10

Re: Get count of members in record

  Alt 10. Jan 2010, 13:24
Can you explain to me whats the advantage to use

WMI_PerfFormattedData_PerfOS_Processor: array of TAssocArray<String>;
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:01 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz