Главная страница
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
6-96330
AlexT1000
2003-07-22 13:56
2003.09.29
Получаю старую версию файла с сервера! как побороть?


3-96128
denis24
2003-09-03 17:00
2003.09.29
работа с excel через ado


6-96327
FST
2003-07-29 18:51
2003.09.29
Передача данных методом POST


6-96334
deadman
2003-07-29 12:51
2003.09.29
учет трафика для RAS-коннекта


3-96064
Санек
2003-09-10 08:35
2003.09.29
Мастера помогите! Как узнать, какие БД уже существуют