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 / Crash on Exit After Reading From Array

Author
Message
Sigh
20
Years of Service
User Offline
Joined: 26th Dec 2005
Location: The Big 80s
Posted: 10th Apr 2012 03:38
An odd problem I need another pair of eyes to look at.

I\'ve got a resource index/version control database I\'m trying to implement and the program crashes on exit at seemingly random times. The only item I\'ve been able to successfully look up w/o errors is \"BMN-12\" (see the attached database).

It seems the program successfully loads the entire DB. However, several problems rear their ugly heads when you try to look up a resource. First, if the resource isn\'t found, the program crashes on exit. Second, the DB lookup code returns with failure even if it should find the item in the DB.

Anyone have any ideas about what the problem could be? Note that when I have the program just print out the DB there\'s no crash, even though I don\'t clean up memory before terminating the program.

Thanks for the help.


type Database_Entry
Designator as string
Path as string
Version as string
endtype

type Environment_Variables
Version as string
DatabaseLoaded as boolean
Directory as string
endtype

dim Database() as Database_Entry
global Database

global Environment as Environment_Variables

set display mode 1440, 900, 32

Database_Load()

`Enable for error (use \"BMN-12\" for success)
P$ = Database_Get_Path(\"TBSM-0002\")
print P$

`Enable to print the DB to the screen
`for a = 0 to a

Keep your Hope & Change to yourself, I choose Liberty! Stop by for a chat! [IXE]Nateholio on irc.maxgaming.net:6667 #GarageGames
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 10th Apr 2012 04:20
P$ = Database_Get_Path(\"TBSM-0002\")

You are mixing types here. If you are passing a string here then the quotes should be around the entire "thing" being passed to the function.

I'd be surprised if this was intentional.

Nateholio
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: I\'ve Been Everywhere
Posted: 10th Apr 2012 20:53
Thanks for the idea, but those slashes got added by Apollo. My internets has been flaky lately so half the post got cut off. Let's try this again....


In Development: K96 - Combat Simulation
Sigh
20
Years of Service
User Offline
Joined: 26th Dec 2005
Location: The Big 80s
Posted: 10th Apr 2012 23:34
I've tried changing the while loops to for loops yet no change. I've also tried doing a lookup of a non-existent DB entry from the main program and no errors occurred. It seems the Database_Get_ function causes some internal error, when an entry doesn't exist in the DB, that doesn't manifest itself until the program ends.
I wouldn't care too much about this if I knew the DB would always be correct, but the whole point of the DB is to see what assets need to be pulled from the server and installed/updated.

Keep your Hope & Change to yourself, I choose Liberty! Stop by for a chat! [IXE]Nateholio on irc.maxgaming.net:6667 #GarageGames
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Apr 2012 23:58
If I recall correctly there's a bug in DBPro affecting returned strings from functions and looking at your code I think that could be the problem. It's something to do with returning literal strings.

Ah! Here's the link:

problems returning empty strings

You may be OK if you return a string variable, e.g.



Obviously you'll need to make a few other related chnges to your code.
Sigh
20
Years of Service
User Offline
Joined: 26th Dec 2005
Location: The Big 80s
Posted: 11th Apr 2012 00:24
Ahhh, thanks GG! Works great now. As usual, you da man. I was starting to figure it might be some sort of problem with DBP...I've ran into several before.

Keep your Hope & Change to yourself, I choose Liberty! Stop by for a chat! [IXE]Nateholio on irc.maxgaming.net:6667 #GarageGames

Login to post a reply

Server time is: 2026-07-10 10:20:25
Your offset time is: 2026-07-10 10:20:25