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 / Strange error with types

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Apr 2011 19:22 Edited at: 23rd Apr 2011 19:25
I just came across this very weird error... Here's part of the code that reproduces this error:



And here is the error after compiling:

Quote: "Could not find field "Pa" in type "player_type" at line 8"


Now what boggles my mind is that when I take the line with the if statement away, the error is gone



Any explanations?

It can not be the length of the type, because this one here works:



TheComet

RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Apr 2011 21:07
I suspect it is a compiler bug that is reading the line as:

if Player.Pa thEn dFrame>1 then a=1

Since the word Then would be valid statement following the If statement. The compiler should take into account spacing, but it appears that it is not.

Recommendations:
1) Report this as a bug.
2) Temporary solution - replace the type with "EndFrame"
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 23rd Apr 2011 21:59
Why would you make a UDT out of a single variable?...

It is used for dim arrays, you shouldn't get any problems that way.

But the situation doesn't require types at all.

-In.Dev.X: A unique heavy story based shoot'em ~6%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Apr 2011 22:07 Edited at: 23rd Apr 2011 22:08
@Quel
What are you talking about? This is a good time to use UDTs. They are not just for arrays...

[b]
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Apr 2011 22:46 Edited at: 23rd Apr 2011 22:47
@ Quel

The code above was only for demonstration purposes... Of course I wouldn't use a UDT for just 1 variable

They aren't only for arrays... They are usually used for structuring your program so you don't have tons of variables. Let's say you had a player, and an enemy, and wanted to store the positions of both. The inefficient way of doing it would be:



And the way with UDTs:



The beauty now is that I can go ahead and set up positions for any object I want. If I wanted to add a bullet, I'd just have to say global bullet as vec3. Same goes with arrays. If I want 20 birds, I'd say dim bird(19) as vec3. Much more efficient than typing it all out.

TheComet

tiresius
23
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 23rd Apr 2011 23:10
UDTs have a use as a single variable (or all in a "Global" container), and that is spell-checking. If you mistype a variable it doesn't care. Mistype part of a UDT and it will let you know.

I wish we had a strict/superstrict type clause like the BRL languages...


A 3D marble platformer using Newton physics.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 23rd Apr 2011 23:50
I know what UDTs are. I just never had the urge to use it for a single entity.

-In.Dev.X: A unique heavy story based shoot'em ~12%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Apr 2011 01:41 Edited at: 24th Apr 2011 01:41
Well spotted RiiDii - I'm sure you're right. Here's the editor error trace:

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 24th Apr 2011 03:54 Edited at: 24th Apr 2011 03:55
Would it fix it temporarily if the 'then' statement was on a separate line?

@Riidii: Nice one...

Warning! May contain Nuts!
RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 24th Apr 2011 18:41 Edited at: 24th Apr 2011 18:43
Quote: "Would it fix it temporarily if the 'then' statement was on a separate line?"


No. I tried it. The cause is not related to the placement of the "Then" statement, but rather the statement "thEn" is part of the UDT name "PathEndFrame".
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Apr 2011 22:05
Thanks guys, I posted this on bug reports I changed it to PathFrameEnd, and that solved the problem.

TheComet

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Apr 2011 22:21
Quote: "Of course I wouldn't use a UDT for just 1 variable"


I do. Let's me group things together and easier to manage.

Login to post a reply

Server time is: 2026-07-18 14:27:00
Your offset time is: 2026-07-18 14:27:00