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

Вниз

Помогите написать функцию   Найти похожие ветки 

 
Шишкин Илья ©   (2003-09-17 15:39) [0]

У меня есть тип:

type
TPlayer = record
FileName:string;
Str:HStream;
ISPlaying:boolean;
Volume:integer;
end;

Как мне встроить в него функцию Play(filename:string):boolean чтобы её можно было вызвать TPlayer.Play("C:\music.mp3")


 
Jeer ©   (2003-09-17 15:40) [1]

Придется перейти к объектам, как ни прискорбно.
А в объектах есть методы.


 
Шишкин Илья ©   (2003-09-17 15:45) [2]

А можно примерчик?


 
Шишкин Илья ©   (2003-09-17 15:47) [3]

А можно примерчик?


 
Jeer ©   (2003-09-17 16:28) [4]

Та без проблем

{************************* TFilterA - aperiodic filter ******************}
type
TFilterA = class
protected
fT,ftau,fa,fb: double;
fValue, fOut, Yii: double;
public
Constructor Create(vT,vtau: double);
Destructor Destroy;
Procedure Clear;
Procedure SetFilter(vT,vtau: double);
Function GetOutput: double;
function Next: double; overload;
function Next(vIn: double): double; overload;
property Value: double read fValue write fValue; // input
property T: double read fT; // time const
property tau: double read ftau; // sampling period
property cA: double read fa;
property cB: double read fb;
property Output: double read GetOutput;
end;


 
PVOzerski ©   (2003-09-17 16:34) [5]

Да нет, можно и record оставить, хотя это уже будет называться "собрать объект вручную"...
type
pPlayer=^tPlayer;
TPlayerMethod=procedure(ISelf:pPlayer);
TPlayer = record
FileName:string;
Str:HStream;
ISPlaying:boolean;
Volume:integer;
PlayerMethod:tPlayerMethod;
end;
procedure ImplementedPlayerMethod;
begin
///
end;
var
Player:tPlayer;
begin
Player.PlayerMethod:=@ImplementedPlayerMethod;
Player.PlayerMethod(@Player);
end.


 
PVOzerski ©   (2003-09-17 16:36) [6]

Только я, правда, в примере в заголовке функции ImplementedPlayerMethod параметр дописать забыл. Прошу прощения.


 
Jeer ©   (2003-09-17 16:39) [7]

Не морочь вьюношам говолю:))


 
PVOzerski ©   (2003-09-17 16:46) [8]

2Jeer: Зато я принцип организации примитивного объекта показал :^). А ты бы хоть всякие property, protected и public выкинул из своего примера - вот этим-то еще больше запутать с непривычки можно :^)



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

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

Наверх




Память: 0.48 MB
Время: 0.023 c
14-96386
Fitness
2003-09-11 12:49
2003.09.29
Вопрос по поводу пластиковых карт, стоит или нет?


3-96068
Senator
2003-09-10 09:52
2003.09.29
Restore


7-96463
GuestTM
2003-07-14 19:35
2003.09.29
Folder Guard своими руками


14-96421
pwl
2003-09-10 17:17
2003.09.29
MDI форма


14-96424
Кен
2003-09-10 04:26
2003.09.29
18-летняя национал-большевичка получила год условно за удар губер