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.

Bug Reports / Reading booleans

Author
Message
Sepnon
14
Years of Service
User Offline
Joined: 7th Feb 2010
Location: Brazil
Posted: 6th Jul 2010 23:41
this code works:



it shows:
1
1

but this doesnt:



shows:
0
0

if its not a bug, how do i read booleans?
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Jul 2010 17:20
You don't, you read an integer or byte and then put it into a boolean.

[b]
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 7th Jul 2010 18:42
It's a confirmed bug, see here.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jul 2010 13:47
I don't see why you expect this code to work as you expect:



Why not read the byte into a byte variable then assign the value to a Boolean? And while you're at it you can check that the byte really is just 0 or 1.

Not sure what the confirmed bug is - the only safe thing to do is to make sure the read and written types match.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 17th Jul 2010 19:38
It shouldn't matter which types you use (within reason) since all of the unsigned types use the same amount of space and simply get casted at the point of assignment.

Try the same with a DWORD, it still doesn't work.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Jul 2010 18:03
Quote: "it still doesn't work"


Should it?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 18th Jul 2010 18:49
Well yes, why shouldn't it?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2010 00:34
Why should it?

The only sensible thing to do is to read a type into the same type. Anything else is probably undefined behaviour and may or may not work depending on the implementation. As I said, why do you think undefined behaviour should work the way you want it to?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 22nd Jul 2010 07:13
Reading signed data as unsigned and vice-versa is a perfectly valid operation.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2010 15:08
In what language? DBPro? If it isn't explicitly allowed by the language why do you assume it should be implemented the way you want it to be?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 22nd Jul 2010 18:48 Edited at: 22nd Jul 2010 18:49
It should be valid in any programming language and operating system provided you are allowed to change the interpretation of the value yourself.

It makes absolutely no sense that trying to read an integer into a dword variable results in nothing being read. If DBPro doesn't support it then it can give an error, but since it automatically handles casting between integer types itself anyway there should be no error and thus it is a perfectly valid operation.

Unless you're arguing that you shouldn't be able to copy the contents of an integer into a dword and vice versa... but again it's a perfectly valid operation.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2010 21:15
You've wandered off the point.

I agree it would be a helpful feature. There are many things that it would be nice to have in DBPro - such as the ability to texture separate materials on an object's limb. Whether we "should" have all these nice features is another matter. The only things we "should" have are the ones described in the documentation. Anything extra is a bonus.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 23rd Jul 2010 00:04 Edited at: 23rd Jul 2010 08:49
Actually, I think you've completely missed the point. You can do something like this:



So I don't see why the file commands should act any differently. Besides, if it's not allowed the compiler should throw an error.

Login to post a reply

Server time is: 2024-04-26 21:38:18
Your offset time is: 2024-04-26 21:38:18