Board index » delphi » Unit to Unit types

Unit to Unit types

I am curious as to how you would use declare a variable ov a type
declared on a different unit. For example in my program i declare a
doubly linked list type, but i would like to move those functions and
procedures that manipulate this list to another unit (for
readability's sake), but i get compiler errors when i do this. And, if
i redeclare the type in both units, i get a type mismatch error. Any
help or sughestion would be much appreciated. BTW I am still curious
as to how one prints a bitmap without stretchdraw, if it cannot be
done, or if there is a technique using stretchdraw which cuts down on
the distortion please let me know. Thanks again.

nodapoc93 (timothy93)
noda...@{*word*104}den.com or arhp...@interaccess.com
delphipoetc++cobol(what a wasted skill) -email for more info-

 

Re:Unit to Unit types


On Mon, 30 Oct 1995 18:28:43 GMT, noda...@{*word*104}den.com (nodapoc93)
wrote:

Quote
>I am curious as to how you would use declare a variable ov a type
>declared on a different unit. For example in my program i declare a
>doubly linked list type, but i would like to move those functions and
>procedures that manipulate this list to another unit (for
>readability's sake), but i get compiler errors when i do this.

Suppose you want the type declaration in Unit1, and the manipulation
functions in Unit2.  Then just make sure that the type declaration is
in the interface section of Unit1, and that Unit2 uses Unit1.  It's as
simple as that.

By the way, I would normally put the type declaration in the same unit
as the functions that are connected with it.  I'm not sure why you
think it would be more readable in separate units.

Duncan Murdoch

Re:Unit to Unit types


In article <472v9r$...@nntp.interaccess.com>,
   noda...@{*word*104}den.com (nodapoc93) wrote:

Quote
>I am curious as to how you would use declare a variable ov a type
>declared on a different unit. For example in my program i declare a
>doubly linked list type, but i would like to move those functions and
>procedures that manipulate this list to another unit (for
>readability's sake), but i get compiler errors when i do this. And, if
>i redeclare the type in both units, i get a type mismatch error. Any
>help or sughestion would be much appreciated. BTW I am still curious
>as to how one prints a bitmap without stretchdraw, if it cannot be
>done, or if there is a technique using stretchdraw which cuts down on
>the distortion please let me know. Thanks again.

>nodapoc93 (timothy93)
>noda...@{*word*104}den.com or arhp...@interaccess.com
>delphipoetc++cobol(what a wasted skill) -email for more info-

Declaire the TYPE in a file say FileA, and include FileA in your definition
unit file.

ie.

FileA:

Type
  MyType = YourType;

Then ...

Unit UnitB;

{$I FileA}   {Include the type file}

Implementation

{... Definition ... }

end.

Re:Unit to Unit types


noda...@{*word*104}den.com (nodapoc93) drooled:

I am curious as to how you would use declare a variable ov a type
declared on a different unit. For example in my program i declare a
doubly linked list type, but i would like to move those functions and
procedures that manipulate this list to another unit (for
readability's sake), but i get compiler errors when i do this. And,
if i redeclare the type in both units, i get a type mismatch error.
Any
help or sughestion would be much appreciated.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~disregard this question, its a product
ov staring at the program for 16 hours straight... the answer is
obvious, sorry to waste bandwidth.

BTW I am still curious
as to how one prints a bitmap without stretchdraw, if it cannot be
done, or if there is a technique using stretchdraw which cuts down on
the distortion please let me know. Thanks again.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-but this still stands...

sorry and thanks again...

nodapoc93 (timothy93)
noda...@{*word*104}den.com or arhp...@interaccess.com
delphipoetc++cobol(what a wasted skill) -email for more info-

Re:Unit to Unit types


noda...@{*word*104}den.com wrote in a message to All:

nc> I am curious as to how you would use declare a variable ov a
nc> type declared on a different unit. For example in my program

Importing and exporting types/functions is not possible with Borland Pascal. But that may not be what you mean.

nc> i declare a doubly linked list type, but i would like to
nc> move those functions and procedures that manipulate this
nc> list to another unit (for
nc> readability's sake), but i get compiler errors when i do
nc> this.

From this I think it should be possible, if this is what you mean:

  unit A;

  interface

  type
    PMyList = ^TMyList;
    TMyList = record
        ...
      end;

  implementation
  end.

  unit B;

  interface

  uses
    A;

  procedure AddToList(List: PMyList; Item: TMyItem);
  ...

  implementation
  end.

Groetjes,

Berend (-:
fido: 2:281/527.23
email: ber...@beard.nest.nl
SEEN-BY: 1/1 60/0

Other Threads