🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: a.bsu.programming
Article #87186

Re: Type Procedure Pascal(TPW)

#87186
From: R. E. Donais
Date: Fri, 02 Feb 1996 00:00
53 lines
2757 bytes
In article <4eu2a2$910@dub-news-svc-5.compuserve.com> Alfred 
Lorenz wrote:
>
>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;
The problem is that the "subfunction" Test pop'd a hidden 
parameter off the stack.  The call to Test has to model a 
call to a subfunction.  I can't think of how to do this with 
out using  assembler.  The simplest solution would be to add 
a "Result:Boolean" to you list of local variables and replace 
the if-statement with --
ASM
   les  AX, [ AnyObj ]
   push ES
   push AX
   push [ BP.Word.0 ]    { pass caller's stack frame ... }
   call DWORD PTR [ Test ]
   mov  [ Result ], AL
END
   If Result Then ...

This should do the trick.

...red
Technical Details
Message-ID: <4eugsi$9al@news-e1a.megaweb.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <4eu2a2$910@dub-news-svc-5.compuserve.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fd1d1,24ca31f46b32e9ca
X-Google-Attributes: gidfd1d1,public
X-Google-Thread: 110467,24ca31f46b32e9ca
X-Google-Attributes: gid110467,public
X-Google-Thread: fe201,24ca31f46b32e9ca
X-Google-Attributes: gidfe201,public
X-Google-Thread: 107d8b,24ca31f46b32e9ca
X-Google-Attributes: gid107d8b,public
X-Google-Thread: 111659,24ca31f46b32e9ca
X-Google-Attributes: gid111659,public
X-Google-Thread: 102601,24ca31f46b32e9ca
X-Google-Attributes: gid102601,public
X-Google-Thread: f88b3,24ca31f46b32e9ca
X-Google-Attributes: gidf88b3,public
X-Google-Thread: 10263e,24ca31f46b32e9ca
X-Google-Attributes: gid10263e,public
From: RDonais@gnn.com (R. E. Donais)
Subject: Re: Type Procedure Pascal(TPW)
Date: 1996/02/02
Message-ID: <4eugsi$9al@news-e1a.megaweb.com>
X-Deja-AN: 137813285
references: <4eu2a2$910@dub-news-svc-5.compuserve.com>
x-gnn-newsserver-posting-date: 3 Feb 1996 02:22:10 GMT
content-type: text/plain; charset="us-ascii"
organization: Megaweb
mime-version: 1.0
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
x-mailer: GNNmessenger 1.2