Главная страница
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.027 c
1-96206
malamba
2003-09-18 10:37
2003.09.29
Настройки программы - treeview и поля к нему


1-96161
lejik
2003-09-18 10:32
2003.09.29
Имя процедуры


3-96087
hawkins
2003-09-09 17:59
2003.09.29
Проблема с BDE: На компютере стоят две Delphi 5 и 6


3-96117
Rel_
2003-09-09 08:53
2003.09.29
Проблема с кодировкой


14-96358
Mr@MsGuns
2003-09-11 19:44
2003.09.29
Ловец снов Стивена Кинга