Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Why can't I store my UDT array element into a local variable?

Author
Message
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 20th Jan 2012 19:43 Edited at: 20th Jan 2012 19:44
I did a search on the matter but in most cases the 'type values must use the same type' error topic in the forums tend to be related to returning UDTs from functions. But I can't return a UDT from an array into a UDT variable.

It is not the end of the world, and this snippet is not the most useful form of local UDT variable usage, but I posted this one because it is brief.

It would be nice to not have to keep telling the CPU where the entry is in the array for every operation and expression.



Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Jan 2012 20:07
You have to declare the type before you use it, not after.

The error message is a little confusing but it's because initially the array has a special type representing undefined, since the UDT doesn't exist at that point, but when it sees "r" the type has been defined, so when it sees you assign an array element to "r", it sees it as assigning the undefined type to "UpdateRatingType", and sees that they are two different types.

[b]
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 20th Jan 2012 20:50
Ahh, thanks. I put the type in the wrong place.

Login to post a reply

Server time is: 2026-07-10 05:57:35
Your offset time is: 2026-07-10 05:57:35