Главная страница
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.02 c
7-96461
V
2003-07-16 20:16
2003.09.29
По реестру


14-96420
Vint
2003-09-10 15:16
2003.09.29
Читать у кого хреновое настроение :)


1-96280
Russko
2003-09-17 09:21
2003.09.29
InstallShield Express for Delphi


1-96247
Starkom
2003-09-17 15:01
2003.09.29
Вопрос об удивительном глюке пропертей компонентов VCL


1-96252
Dysan
2003-09-17 15:34
2003.09.29
Halt(1)