Board index » delphi » Question on passing pointer to procedure - question.zip (0/1)

Question on passing pointer to procedure - question.zip (0/1)

you don't need to use VAR on your procedural declaration if you can't
change the pointer (for example: when a pointer points to 3CD0:0000 and your
procedure doesn't change this fact ,you will don't need to use var... but
however.. if the pointer must point somewhere else after this procedure /
function you'll need to use VAR)..

simple pascal example:

Procedure WhatDoesThePointerDO (P : Pointer); { no var needed}
begin
  writeln ('Pointer points to segment ', seg (p^),'(d)');
  writeln ('Pointer points to offset ', ofs (p^),'(d)');
end;

Procedure PointToVGA (VAR P : Pointer); {VAR NEEDED HERE!}
begin
  P:=Ptr (Sega000,0);
end;

I hope that this helps..

Quote
----- Original Message -----
From: <d...@chevalier.net>

Newsgroups:
comp.lang.pascal,comp.lang.pascal.ansi-iso,comp.lang.pascal.misc,comp.lang.p
ascal.borland
Sent: Friday, March 26, 1999 2:58 AM
Subject: Question on passing pointer to procedure - question.zip (0/1)

>I have written a program to do huffman compression. However, the
>program has problem.
>If I use VAR to pass the pointer to procedures listed below, "204
>Invalid pointer operation" is reported in "procedure char_dispose"
>in Turbo Pascal 6.

Cut cut cut cut cut cut... :)

 

Re:Question on passing pointer to procedure - question.zip (0/1)


I have written a program to do huffman compression. However, the
program has problem.
If I use VAR to pass the pointer to procedures listed below, "204
Invalid pointer operation" is reported in "procedure char_dispose"
in Turbo Pascal 6.

procedure char_sort
procedure char_release
procedure char_dispose
procedure node_join
procedure node3_join
procedure tree_release

If I add "break point" to "procedure char_dispose" and run step by
step, no run-time error appears.
If I don't use VAR, no run-time error appears, too.
However, the link between the tree structure is broken.
Would anyone help me to solve this problem ?
Also Would anyone tell me when I should use VAR to pass pointer to
procedure and when I should not ? Thanks

Note : A62.PAS is using VAR to pass pointer to procedure.
       A61.PAS is not.

Re:Question on passing pointer to procedure - question.zip (0/1)


In article <36fae938.489...@news.netvigator.com>,

Quote
  d...@chevalier.net wrote:
> I have written a program to do huffman compression. However, the
> program has problem.
> If I use VAR to pass the pointer to procedures listed below, "204
> Invalid pointer operation" is reported in "procedure char_dispose"
> in Turbo Pascal 6.

> procedure char_sort
> procedure char_release
> procedure char_dispose
> procedure node_join
> procedure node3_join
> procedure tree_release

> If I add "break point" to "procedure char_dispose" and run step by
> step, no run-time error appears.
> If I don't use VAR, no run-time error appears, too.
> However, the link between the tree structure is broken.
> Would anyone help me to solve this problem ?
> Also Would anyone tell me when I should use VAR to pass pointer to
> procedure and when I should not ? Thanks

1 - DON'T POST BINARIES TO THESE GROUPS!
2 - comp.lang.pascal is no longer in use - removed from reply

Robert
--
Robert AH Prins
prin...@williscorroon.com

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

Re:Question on passing pointer to procedure - question.zip (0/1)


d...@chevalier.net D?? ???
<36fae938.489...@news.netvigator.com>...

Quote
> I have written a program to do huffman compression. However, the
> program has problem.
> If I use VAR to pass the pointer to procedures listed below, "204
> Invalid pointer operation" is reported in "procedure char_dispose"
> in Turbo Pascal 6.

> procedure char_sort
> procedure char_release
> procedure char_dispose
> procedure node_join
> procedure node3_join
> procedure tree_release

> If I add "break point" to "procedure char_dispose" and run step by
> step, no run-time error appears.
> If I don't use VAR, no run-time error appears, too.
> However, the link between the tree structure is broken.
> Would anyone help me to solve this problem ?
> Also Would anyone tell me when I should use VAR to pass pointer to
> procedure and when I should not ? Thanks

> Note : A62.PAS is using VAR to pass pointer to procedure.
>        A61.PAS is not.

Re:Question on passing pointer to procedure - question.zip (0/1)


Quote
Robert AH Prins wrote:

> In article <36fae938.489...@news.netvigator.com>,
>   d...@chevalier.net wrote:
> > I have written a program to do huffman compression. However, the
> > program has problem.
> > If I use VAR to pass the pointer to procedures listed below, "204
> > Invalid pointer operation" is reported in "procedure char_dispose"
> > in Turbo Pascal 6.

> > procedure char_sort
> > procedure char_release
> > procedure char_dispose
> > procedure node_join
> > procedure node3_join
> > procedure tree_release

> > If I add "break point" to "procedure char_dispose" and run step by
> > step, no run-time error appears.
> > If I don't use VAR, no run-time error appears, too.
> > However, the link between the tree structure is broken.
> > Would anyone help me to solve this problem ?
> > Also Would anyone tell me when I should use VAR to pass pointer to
> > procedure and when I should not ? Thanks

> 1 - DON'T POST BINARIES TO THESE GROUPS!
> 2 - comp.lang.pascal is no longer in use - removed from reply

> Robert
> --

If you don't know the answer, just say so!

Other Threads