Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot pass array (user defined type) to subprocedure!

Status
Not open for further replies.

teenserve

Programmer
Nov 27, 2003
3
0
0
US
My user defined type is "Wireframe" and I get a type mismatch when I try to pass it to my sub.

SUB Draw3D(WF AS WireFrame)

^^^ Here is where the sub starts

In the main code, here is where my array is defined.

DIM Pyramid(5) AS WireFrame


And here I try to call my sub procedure and pass "Pyramid" along with it. I get a type mismatch error. =(

CALL Draw3D(Pyramid())

Anyone know why it would say that, even though to my eyes it should match as a 'Wireframe' type.
 
I am having the same problem, and I just came on here to post about it when I saw this post, so I thought I'd post my code here. My code is a little bit different, but is about the same idea, so I'll post it here:

'''''''''''START CODE

TYPE TEST
APPLE AS INTEGER
ORANGE AS INTEGER
END TYPE

DIM XYZ(4) AS TEST

SOMEPROCEDURE XYZ()

SUB SOMEPROCEDURE (XYZ())
XYZ.APPLE = 4
END SUB

''''''''''''END CODE

I get the same thing, a parameter type mismatch error.

Secondly, if I put the code

COMMON SHARED XYZ() at the top of my code, it will give me a DUPLICATE NAME error on the

DIM XYZ(4) AS TEST

I don't get either of these errors when they're just normal arrays. (I am using the COMMON SHARED to transfer information between several *.BAS files in one program.)

If anyone could help remedy this, it would be greatly appreciated.
 
Do you have to say...

SUB Draw3D(WF() AS WireFrame) ...?

also is there an ANY data type you can use (it's been awhile, I might be getting this confused w/ another lang...)


Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif

 
Figured out the parameter type mismatch error.

It would still be:

SOMEPROCEDURE XYZ()

But in the sub, it would be

SUB SOMEPROCEDURE (XYZ() AS TEST)

That fixes that.

As for the common shared, it was the same deal, but I had to make sure to put the TYPE set before the COMMON SHARED statement, or it gave me an error that the type was undefined.



As for Teenserve's problem, I think when you go into your sub, you have

SUB Draw3D(WF AS Wireframe)

I think you need to put

SUB Draw3D(Pyramid() AS Wireframe)
 
Thank you, what I changed was the WF to WF() in the top of the sub =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top