Type Mismatch ?? 
Author Message
 Type Mismatch ??

I know this is probably simple but it's driving me
up a wall.

I'm trying to pass a variable to a procedure and
I've tried to do it many different ways and I'm
getting a type mismatch error:

LongRecTyp =
    Record
         Rec1   : AsciiZ;
         Rec2         : AsciiZ;
    End;
.
.
VAR
     LongRec    : LongRecTyp;
.
.
Proc1(IDXFile, LongRec, Parm1, Parm2);          
.
.
Procedure Proc1(VAR IDXFile : OtherFileTyp; VAR
LongRec : LongRecTyp; Parm1 : CHAR; Parm2 :
Integer)

The procedure Proc1 is in another unit. The
variable is loaded correctly with 2048 bytes per
record.  When I previously used LongRec as a
single Asciiz string of 2048 bytes it worked
perfectly, when I changed it to acomodate two long
strings this started happening.
I know i'm probably leaving out something so if
you need more info let me know I'll update right
away.

Thanks in advance......
FVM2
http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 Type Mismatch ??

Quote:

> I know this is probably simple but it's driving me
> up a wall.

> I'm trying to pass a variable to a procedure and
> I've tried to do it many different ways and I'm
> [...]
> The procedure Proc1 is in another unit. The
> variable is loaded correctly with 2048 bytes per
> record.  When I previously used LongRec as a
> single Asciiz string of 2048 bytes it worked
> perfectly, when I changed it to acomodate two long
> strings this started happening.
> I know i'm probably leaving out something so if
> you need more info let me know I'll update right
> away.

To really answer your question, I would need some more
Infos about your Program, esp. the Head of the Procedure
"Proc1" and where your types and variables are declared.

Here are some hints to the subject of
Type compatibility in TP.

* if you declare LongRecType twice (once in the Unit and
  once in the main Program) TP will expect a variable of
  the type declared in the Unit (where also the Procedure
  is located), and will not accept the one from the main
  Program (even thought they might have identical Names
  and Content). Remove the second declaration (don't need
  it anyway) !

* The same is true for two Units.

* You can typecast any variable into another type OF THE
  SAME SIZE using the syntax NewType(Variable) ! It will
  then be treated as a Variable of type NewType !

For more infos, please e-mail !

good luck ;-)



Wed, 18 Jun 1902 08:00:00 GMT  
 Type Mismatch ??


Quote:

>I know this is probably simple but it's driving me
>up a wall.

>I'm trying to pass a variable to a procedure and
>I've tried to do it many different ways and I'm
>getting a type mismatch error:

>LongRecTyp =
>    Record
>         Rec1       : AsciiZ;
>         Rec2         : AsciiZ;
>    End;
>.
>.
>VAR
>     LongRec        : LongRecTyp;
>.
>.
>Proc1(IDXFile, LongRec, Parm1, Parm2);              
>.
>.
>Procedure Proc1(VAR IDXFile : OtherFileTyp; VAR
>LongRec : LongRecTyp; Parm1 : CHAR; Parm2 :
>Integer)

>The procedure Proc1 is in another unit. The
>variable is loaded correctly with 2048 bytes per
>record.

I hope you are not redefining the types in that unit. Two separately
defined types are not the same even if the definitions are identical. If
you do that then move the definition to the interface section of the unit.

Quote:
>When I previously used LongRec as a
>single Asciiz string of 2048 bytes it worked
>perfectly, when I changed it to acomodate two long
>strings this started happening.
>I know i'm probably leaving out something so if
>you need more info let me know I'll update right
>away.

>Thanks in advance......
>FVM2
>Http://www.WebArise.com

Osmo


Wed, 18 Jun 1902 08:00:00 GMT  
 Type Mismatch ??

Quote:


>> I know this is probably simple but it's driving me
>> up a wall.

>> I'm trying to pass a variable to a procedure and
>> I've tried to do it many different ways and I'm

>> [...]

>> The procedure Proc1 is in another unit. The
>> variable is loaded correctly with 2048 bytes per
>> record.  When I previously used LongRec as a
>> single Asciiz string of 2048 bytes it worked
>> perfectly, when I changed it to acomodate two long
>> strings this started happening.
>> I know i'm probably leaving out something so if
>> you need more info let me know I'll update right
>> away.

> To really answer your question, I would need some more
> Infos about your Program, esp. the Head of the Procedure
> "Proc1" and where your types and variables are declared.

> Here are some hints to the subject of
> Type compatibility in TP.

> * if you declare LongRecType twice (once in the Unit and
>   once in the main Program) TP will expect a variable of
>   the type declared in the Unit (where also the Procedure
>   is located), and will not accept the one from the main
>   Program (even thought they might have identical Names
>   and Content). Remove the second declaration (don't need
>   it anyway) !

Yes, remove the declaration in your main program and place the
 declaration in the public type section of your unit.  Any changes you
 make in the unit will then be available to all your programs without
 changes.

Also, instead of passing such a large structure, you might save yourself some
 trouble and just pass a pointer to your structure, directly or using the
 var keyword.

Steve



Wed, 18 Jun 1902 08:00:00 GMT  
 Type Mismatch ??



Quote:

>Also, instead of passing such a large structure, you might save yourself some
> trouble and just pass a pointer to your structure, directly or using the
> var keyword.

Use the VAR (or CONST). Passing pointers is very C-like and not proper

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Type mismatch in Query

2. Turbo Pascal 7 type mismatch error

3. Query with dates ==> Type Mismatch

4. Type Mismatch with szName Parameter

5. type mismatch error

6. type mismatch question

7. type mismatch w/csDropDown, etc.

8. type mismatch question

9. OWL...type mismatch...

10. type mismatch HeLP?!

11. Type Mismatch ??

12. Type Mismatch ???

 

 
Powered by phpBB® Forum Software