Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

CleintDataSet [D7, IB6.x]


OlegL ©   (2004-10-26 13:40:00) 

Скажите пожайлуста как мне добратся до своиства Currency у полей ClientDataSet если они (поля) создаются в run-time.
Я пробовал
(DataModule2.ClientDataSet1.Fields.FieldByName(имя поля) as TFloatField).currency := false;

(Я знаю как поле будет называтся.)
Говорит "Invalid class typecast". В принципе я понемаю что TField это не TFloatField но они же родственники. :-))
Как мне сделать?


Johnmen   (2004-10-26 14:28:00) [1]

>Плохиш ©

Вот оно что ! А я не догнал !

>OlegL  

Тогда см.
DataModule2.ClientDataSet1.Fields.FieldByName(имя поля).FieldType


Ega23   (2004-10-26 14:24:00) [2]

Ну тогда
TFloatField(ds.FieldByName('AAA')).Currency:=False;


Плохиш   (2004-10-26 14:23:00) [3]

2OlegL

Посмотри ClassName у своего поля.


Плохиш   (2004-10-26 14:20:00) [4]


> Johnmen ©   (26.10.04 14:12) [8]
> Ega23 ©   (26.10.04 14:13) [9]

Он вообще-то про свойство currence у TFloadField спрашивает.

> OlegL   (26.10.04 13:40)

> Говорит "Invalid class typecast".

Значит создал поле не типа float.


Johnmen   (2004-10-26 14:15:00) [5]

>Ega23 ©   (26.10.04 14:13) [9]

Судя по OlegL   (26.10.04 14:08) [7] требуется перевод на русский !
:)


Ega23   (2004-10-26 14:13:00) [6]

Читаем:
Currency + F1:
A real type defines a set of numbers that can be represented with floating-point notation. The table below gives the ranges and storage formats for the fundamental real types.

Type Range Significant digits Size in bytes
Real48 2.9 x 10^–39 .. 1.7 x 10^38 11–12 6
Single 1.5 x 10^–45 .. 3.4 x 10^38 7–8 4
Double 5.0 x 10^–324 .. 1.7 x 10^308 15–16 8
Extended 3.6 x 10^–4951 .. 1.1 x 10^4932 19–20 10
Comp –2^63+1 .. 2^63 –1 19–20 8
Currency –922337203685477.5808.. 922337203685477.5807 19–20 8
The generic type Real, in its current implementation, is equivalent to Double.

Type Range Significant digits Size in bytes
Real 5.0 x 10^–324 .. 1.7 x 10^308 15–16 8
Note: The six-byte Real48 type was called Real in earlier versions of Object Pascal. If you are recompiling code that uses the older, six-byte Real type, you may want to change it to Real48. You can also use the {$REALCOMPATIBILITY ON} compiler directive to turn Real back into the six-byte type.

The following remarks apply to fundamental real types.

Real48 is maintained for backward compatibility. Since its storage format is not native to the Intel CPU family, it results in slower performance than other floating-point types.
Extended offers greater precision than other real types but is less portable. Be careful using Extended if you are creating data files to share across platforms.
The Comp (computational) type is native to the Intel CPU and represents a 64-bit integer. It is classified as a real, however, because it does not behave like an ordinal type. (For example, you cannot increment or decrement a Comp value.) Comp is maintained for backward compatibility only. Use the Int64 type for better performance.

Currency is a fixed-point data type that minimizes rounding errors in monetary calculations. It is stored as a scaled 64-bit integer with the four least-significant digits implicitly representing decimal places. When mixed with other real types in assignments and expressions, Currency values are automatically divided or multiplied by 10000.


False + F1 :

The four predefined Boolean types are Boolean, ByteBool, WordBool, and LongBool. Boolean is the preferred type. The others exist to provide compatibility with different languages and the Windows environment.
A Boolean variable occupies one byte of memory, a ByteBool variable also occupies one byte, a WordBool variable occupies two bytes (one word), and a LongBool variable occupies four bytes (two words).

Boolean values are denoted by the predefined constants True and False. The following relationships hold.

Boolean ByteBool, WordBool, LongBool
False < True False <> True
Ord(False) = 0 Ord(False) = 0
Ord(True) = 1 Ord(True) <> 0
Succ(False) = True Succ(False) = True
Pred(True) = False Pred(False) = True
A value of type ByteBool, LongBool, or WordBool is considered True when its ordinality is nonzero. If such a value appears in a context where a Boolean is expected, the compiler automatically converts any value of nonzero ordinality to True.
The remarks above refer to the ordinality of Boolean values—not to the values themselves. In Object Pascal, Boolean expressions cannot be equated with integers or reals. Hence, if X is an integer variable, the statement

if X then ...;

generates a compilation error. Casting the variable to a Boolean type is unreliable, but each of the following alternatives will work.

if X <> 0 then ...;        { use longer expression that returns Boolean value }
var OK: Boolean            { use Boolean variable }

...
if X <> 0 then OK := True;
if OK then ...;


Johnmen   (2004-10-26 14:12:00) [7]

Тогда ещё раз конкретныйвопрос.
А на тот, который в теме - уже ответили [1], [2].


OlegL   (2004-10-26 14:08:00) [8]

Если бы я понял из хелпа я бы не писал в форуме.


Johnmen   (2004-10-26 14:05:00) [9]

>OlegL   (26.10.04 14:01) [5]

Прав в том, что указал на некоторую странность в коде...
А ты не понял потому, что не следуешь рекомендации почитать хелп на currency и false :)


OlegL   (2004-10-26 14:01:00) [10]

Я так и не понял в чём
> Johnmen ©
был прав


Ega23   (2004-10-26 13:54:00) [11]

Я хочу свойство Currency поменять в false.

Набери в хелпе слово Currency, а также False, и ты поймёшь, что Johnmen © в [1] был прав.


OlegL   (2004-10-26 13:52:00) [12]


> Johnmen ©

Так вот и скажи мне что я путаю.

> Ega23 ©

Я хочу свойство Currency поменять в false.


Ega23   (2004-10-26 13:47:00) [13]


ds:TDataSet

if ds.FieldByName('AAA').AsCurrency


Johnmen   (2004-10-26 13:45:00) [14]

TCurrencyField(DataModule2.ClientDataSet1.Fields.FieldByName(имя поля))

>...).currency := false;

А может ты что-то путаешь ? :)


Наверх

Титульная страница Поиск, карта сайта Написать письмо