在Delphi中存储一组值 [英] Storing a set of values in Delphi

查看:69
本文介绍了在Delphi中存储一组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在delphi中存储一组值,但是我希望能够使用它们的名称而不是分配的数字来寻址它们。

I am trying to store a set of values in delp but i want to be able to address them using their name, instead of an assigned number.

例如,一个'OldValues'数组可以让我这样做

For example, an array of 'OldValues' would let me do

OldValue[1] := InflationEdit.Text;

但是理想情况下,例如,我想将值存储在 Data.Inflation.OldValue中。对于每个标识符(例如通货膨胀),都有一个OldValue,NewValue和StoredValue。这些标识符大约有12个。

Ideally however, i would like to have a value stored in 'Data.Inflation.OldValue' for example. For each identifier, such as Inflation, there is an OldValue, NewValue and StoredValue. There are about 12 of these identifiers.

是否可以通过某种方式存储这样的值?这样,我便可以执行以下操作:

Is there some way i could store the values like this? that way i could then do something like:

Data.Inflation.NewValue := Data.Inflation.OldValue;
Data.Inflation.NewValue := InflationEdit.Text;


推荐答案

在此类上,类确实非常方便问题。

A class would really came very handy on this kind of problem. something in the likes of;

// Inflation record
TInflation = record
  NewValue,
  OldValue:string;
end;

/ data class
Tdata = class(object)
private
  Inflation:TInflation;
  // other properties
  ...
public
 constructor ...

end;

data := TData.create(nil)

data.Inflation.NewValue :=  data.inflation.OldValue;
...

这篇关于在Delphi中存储一组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆