Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.09.12;
Скачать: CL | DM;

Вниз

.Items , .lines   Найти похожие ветки 

 
Ragazor   (2004-08-30 14:27) [0]

Как правильно объявить в типе сабж
TAdata = class(Tobject)
  ItemID: array [0..100] of integer;
  ItemName: array[0..100] of string;
  ItemDescr: array[0..100] of string;
  ItemNotes: array[0..100] of Ansistring;
  ItemATTR: array[0..100] of string;
...
Вот ItemID нужен как .Items типа стринг


 
Digitman ©   (2004-08-30 14:38) [1]


> Как правильно объявить в типе сабж


что еще зв тип "сабж" ? ты про пунктуацию в рус.языке слышал хоть что-нибудь ?


> Вот ItemID нужен как .Items типа стринг


бред какой-то ... имзложи мысль нормальным языком программиста !


 
Ragazor   (2004-08-30 14:51) [2]

сори, я на скорую руку спешу очень...
Вот скажем Combobox имеет св-во Items
вот и мне такое объявить нужно в Type


 
default ©   (2004-08-30 14:57) [3]

Ragazor   (30.08.04 14:51) [2]
а исходники открыть?(а вообще почитать как свойства объявляются...)


 
KSergey ©   (2004-08-30 15:00) [4]

> [3] default ©   (30.08.04 14:57)
> а исходники открыть?

Он спешит, ему некогда


 
GuAV ©   (2004-08-30 15:02) [5]


> Вот ItemID нужен как .Items типа стринг

так и делай.

type
 TItemID = class(TStrings)
 ...
 end;

 TAdata = class(Tobject)
   ItemID: TItemID ;


 
GuAV ©   (2004-08-30 15:03) [6]


> Вот ItemID нужен как .Items типа стринг

так и делай.

type
 TItemID = class(TStrings)
 ...
 end;

 TAdata = class(Tobject)
   ItemID: TItemID ;


 
Digitman ©   (2004-08-30 15:03) [7]


> Ragazor   (30.08.04 14:51) [2]
> сори, я на скорую руку спешу очень...


а вот спешка-то как раз нужна в оч известных случаях


>   ItemName: array[0..100] of string; //раз !
>   ItemDescr: array[0..100] of string; //два !
>   ItemNotes: array[0..100] of Ansistring; //три !
>   ItemATTR: array[0..100] of string; //четыре !
> ...
> Вот ItemID нужен как .Items типа стринг


ты мозгами-то шевели малясь !

ты хочешь вернуть некое значение типа String

в твоем классе аж 4 поля такого типа могут возвращать значение данного типа

что, догадываться нужно о каком поле идет речь ?


 
default ©   (2004-08-30 15:06) [8]

1)"Вот ItemID нужен как .Items типа стринг(это String)"
2)"Вот скажем Combobox имеет св-во Items(это TStrings)
вот и мне такое объявить нужно в Type"
вот вам типа задачка что же мне нужно надо отгадать
кто отгадает тому бонус ввиде спасиба


 
Ragazor   (2004-08-30 15:11) [9]

to default
\\Вот скажем Combobox имеет св-во Items(это TStrings)
ну так что написать вроде:
type ...
ItemID:Tstrings;
...
?


 
Digitman ©   (2004-08-30 15:17) [10]


> Ragazor   (30.08.04 15:11) [9]


да с какого перепугу-то св-во ItemId[] будет текстовым ?!
если соотв.одноим.массив у тебя имеет тип эл-тов integer ?!


 
icWasya ©   (2004-08-30 15:19) [11]


TAdata = class(Tobject)
private
 FItemID: array [0..100] of integer;
 FItemName: array[0..100] of string;
 FItemDescr: array[0..100] of string;
 FItemNotes: array[0..100] of Ansistring;
 FItemATTR: array[0..100] of string;
 function GetItemID(index:Integer):Integer;
 function GetItemName(index:Integer):string;
 function GetItemDescr(index:Integer):string;
 function GetItemNotes(index:Integer):Ansistring;
 function GetItemATTR(index:Integer):string;
 procedure SetItemID(index:Integer;Value:Integer);
 procedure SetItemName(index:Integer;const Value:string);
 procedure SetItemDescr(index:Integer;const Value:string);
 procedure SetItemATTR(index:Integer;const Value:string);
 procedure SetItemID(index:Integer;const Value:string);
public
 property ItemID[index:integer]:integer read GetItemID write SetItemId;
 property ItemName[index:integer]:String read GetItemName write SetItemName;

...
 end;

implementation
function TAdata.GetItemID(Index:Integer):Integer;
begin
 if (Index<0) or (Index>100) then Exception.CreateFMT("Index Error %d",[Index]);
 Result:=FItemID[Index];
end;

procedure TAdata.SetItemID(Index:Integer;Value:Integer);
begin
 if (Index<0) or (Index>100) then Exception.CreateFMT("Index Error %d",[Index]);
 if FItemID[Index] = Value then Exit;

 FItemID[Index]:=Value;
end;

а лучше посмотреть property+F1


 
default ©   (2004-08-30 15:19) [12]

TMyClass = class
private
 FItems: TStrings;
protected
 procedure SetItems(const Value: TStrings); virtual;
public
 property Items: TStrings read FItems write SetItems;
end;

procedure TMyClass.SetItems(const Value: TStrings);
begin
 if Assigned(FItems) then
   FItems.Assign(Value)
 else
   FItems := Value;
end;

что-то навроде этого


 
Ragazor   (2004-08-30 15:26) [13]

о, это уже то, что я криво просил...



Страницы: 1 вся ветка

Текущий архив: 2004.09.12;
Скачать: CL | DM;

Наверх




Память: 0.5 MB
Время: 0.029 c
1-1093525656
AlexXn
2004-08-26 17:07
2004.09.12
Тэги HTML


3-1092723998
HMT
2004-08-17 10:26
2004.09.12
Подскажите плз как это будет в Interbase SQL


1-1093853845
BillyJeans
2004-08-30 12:17
2004.09.12
I/O Error 183.


1-1093844218
Ega23
2004-08-30 09:36
2004.09.12
Как методу класса присвоить процедуру?


4-1091164721
wild_arg
2004-07-30 09:18
2004.09.12
Контекстное меню