Article View: a.bsu.programming
Article #87185Type Procedure Pascal(TPW)
From: Alfred Lorenz
Date: Fri, 02 Feb 1996 00:00
Date: Fri, 02 Feb 1996 00:00
40 lines
2233 bytes
2233 bytes
Hallo All,
I tried to create a Method for a TCollection which works similar to
ForEach or FirstThat. Unfortunately I allways receive a Runtime-Error
when calling the Method. I know exactly where the Error occurs but i
dont know why. Any idea how it could work?
Type
PColFunc = ^TColFunc;
TColFunc = function(item: Pointer):boolean;
Type
PObjSave = ^TObjSave;
TObjSave = Object(TCollection)
procedure DelEach(Test: pColFunc);
end;
procedure TObjSave.DelEach(Test: pColFunc);
Var AnyObj: Pointer; idx: word; TestFunc: tColFunc;
begin
if Count = 0 then exit;
idx:= 0;
TestFunc:= Test^;
Repeat
AnyObj:= At(idx);
if TestFunc(AnyObj) then => Runtime-Error!!!
Delete(AnyObj)
else inc(idx);
until idx = count;
end;
{*********** Testmethode im Window **********************************}
procedure TWind.DelEachTest(var Msg: TMessage);
function isOdd(AnyObj: pGraphObj): boolean;far;
begin
isOdd:= Odd(AnyObj^.ObjID);
end;
begin
pObjSave2^.DelEach(@isOdd);
end;
Thanks Freddy
Technical Details
Message-ID:
<4eu2a2$910@dub-news-svc-5.compuserve.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 110467,24ca31f46b32e9ca,start X-Google-Attributes: gid110467,public X-Google-Thread: fd1d1,24ca31f46b32e9ca,start X-Google-Attributes: gidfd1d1,public X-Google-Thread: 102601,24ca31f46b32e9ca,start X-Google-Attributes: gid102601,public X-Google-Thread: f88b3,24ca31f46b32e9ca,start X-Google-Attributes: gidf88b3,public X-Google-Thread: 107d8b,24ca31f46b32e9ca,start X-Google-Attributes: gid107d8b,public X-Google-Thread: 10263e,24ca31f46b32e9ca,start X-Google-Attributes: gid10263e,public X-Google-Thread: fe201,24ca31f46b32e9ca,start X-Google-Attributes: gidfe201,public X-Google-Thread: 111659,24ca31f46b32e9ca,start X-Google-Attributes: gid111659,public From: 101457.1776@CompuServe.com (Alfred Lorenz) Subject: Type Procedure Pascal(TPW) Date: 1996/02/02 Message-ID: <4eu2a2$910@dub-news-svc-5.compuserve.com> X-Deja-AN: 137724022 organization: CompuServe Incorporated newsgroups: a.bsu.programming,comp.lang.pascal.borland,comp.os.ms-windows.programmer.tools.owl,ctdl.lang.pascal,de.comp.lang.pascal,fido.ger.pascal,maus.lang.tpascal,slac.lang.pascal,z-netz.sprachen.pascal