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 Discussion / Structs in DB

Author
Message
JakeC
21
Years of Service
User Offline
Joined: 25th Dec 2003
Location:
Posted: 25th Dec 2003 19:29
I've got a bit of experience with c but wanted to try my hand at making a game, so I chose DB, however I want to use structures and can't figure out how. I tried using the DATA and READ commands and that appeared to work, however the RESTORE command appears not to be able to accept a variable as it's lable. Has anyone got any suggestions on making structs in DB without using arrays(suggestions using arrays would be nice too).

thanks
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Dec 2003 22:41 Edited at: 25th Dec 2003 22:42
Just to make sure I remember this right, its something like:
struct
{
int something;
double thing;
} tree

So DB's equivilent would be a TYPE.

type tree
something as integer
thing as double
endtype

dim array(10) as tree

array(3).something = 5
array(3).thing = 3.14
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 25th Dec 2003 22:45
But sadly, Types are only in PRO


Dont forget to Join the Forums!
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 26th Dec 2003 02:10 Edited at: 26th Dec 2003 02:11
They're also in DBC but are part of an extended syntax from within DarkEDIT, you just have to set it to have Type extended syntax and it converts all your code for you at runtime... Extremely useful indeed...

To set it, go Edit >> Edit Options >> check the box next to TYPE Extended Syntax and, voila Types in DB!

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 27th Dec 2003 04:28
any help on how types work?

Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 27th Dec 2003 04:41
um, yeah, here's the DBPro Trial Help file:


They're pretty easy once you get used to them, and extremely useful too.

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 27th Dec 2003 22:23
and you CAN use them in DE...thanx JT

Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 29th Dec 2003 07:32
It's cool.

They're really useful once you get to know how they work and how best to use them ( ie, with arrays ).

I personally never used them untill I moved on to DBPro, although, I DID know about them, just never used them. But, once i started to use them, there's no looking back.

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Pricey
22
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 29th Dec 2003 10:51
i always used them in blitz 2d

waffle
22
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 29th Dec 2003 14:39
just remember that with DE, you can't use preproccesor commands in your include files....

A work around is to have 2 versions...
example MainIncl.dba
in this one, enable preprocessors when testing.
when working, export the final code by

1 - save as (important, don't copy over original)
MainInclDB.dba
use the extra DB to identify DB compatible code
2 - select compile
3 - when prompted to by DE
select REPLACE SOURCE
this will replace all preprocessor commands with remarks
and place in real DB code
4 - now save
5 - now your include file MianIncDB.dba
is ready for other projects....

internet gaming group
current project http://home.comcast.net/~norman.perry/Archon.html

Login to post a reply

Server time is: 2025-05-22 09:15:16
Your offset time is: 2025-05-22 09:15:16