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 / I think I found a bug

Author
Message
mindsclay
14
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Jul 2013 02:31 Edited at: 5th Jul 2013 02:35
The attached code seems to reveal a DB bug. The length of dispMode$ is zero. It should be the same as CHECKLIST QUANTITY().



.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Jul 2013 02:38
That's because len excpects a string and not an array.

What you're doing should be written like so:


The main problem is that the array dispMode$() and the variable dispMode$ are two different objects. As you haven't initialized the variable dispMode$, yet use it as argument to the len()-function, it will be created and zero initialized by default. Thus the result that it is an empty string is in fact correct and to be expected


"Why do programmers get Halloween and Christmas mixed up?"
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Jul 2013 03:15
You don't need to type global dim.....

Arrays are always global.

This is my current project, check it out! [href]forum.thegamecreators.com/?m=forum_view&t=204576&b=8[/href]
This is my website, check it out! [href]http:\\www.TeamDefiant.co.uk[/href]
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 5th Jul 2013 04:04
Mobiius, previously I found some weird declaration order happening, where I had to declare Arrays as global, otherwise they failed to compute correctly.

From memory it was a project using multiple DBA files, with sub-routines declaring arrays, and if they weren't declared as global, they failed. I can't remember any further specifics though.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 5th Jul 2013 05:29 Edited at: 5th Jul 2013 05:30
I'll just add that if you ever want a local array (an array that is not global) then put "Local" before the Dim statement.
Local Dim arrayName( size )

CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 5th Jul 2013 12:15
I've had plenty of arrays not recognized within functions unless I use the GLOBAL statement...


Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Jul 2013 17:24
I've never had any issues with them at all. I use multiple self declaring include files in all of my programs??

I use things like this:



I've converted all the various shader routines I've downloaded from the forums to this format too. (As well as coding all my own functions this way) This way, I don't have to explicitly declare them, they get declared when they're used. (Better on memory this way)

This is my current project, check it out! [href]forum.thegamecreators.com/?m=forum_view&t=204576&b=8[/href]
This is my website, check it out! [href]http:\\www.TeamDefiant.co.uk[/href]
mindsclay
14
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Jul 2013 23:15
Okay. I was using the wrong query. Thanks.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)

Login to post a reply

Server time is: 2026-07-06 20:31:21
Your offset time is: 2026-07-06 20:31:21