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.

Newcomers DBPro Corner / Data Statements and Reading Them

Author
Message
Crystal Darkness
19
Years of Service
User Offline
Joined: 7th Feb 2005
Location: United States
Posted: 7th Sep 2005 20:47
I am in some serious need for help concering a very basic topic: data Statements!!! I don't know what it is, but I am lost! Could someone please post some explainations and perhas a few examples? Thank you very much!

Regards,
CD
Silent Knight
19
Years of Service
User Offline
Joined: 25th Jan 2005
Location: In Your Mind
Posted: 7th Sep 2005 22:24
you use them to include data within your program so that you dont need extra files
for example

I have made a matrix using MatEdit, and i have written the .dba code for it (in case you wonder, .dba code is the files saved using the compiler). now, i could just say
#include "mymap.dba"
but if i load the code in the dba file directly into my program, i just need a subroutine instead of 2 files.

it also helps to prevent the user from changing the coding.

Version--DB Classic
900 mhz AMD Athlon, 128 MB RAM,
16 MB NVidia Vanta gfx card, Windows ME System software
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 8th Sep 2005 00:31
I suppose that involves data statements...maybe...but it is a very obtuse example...If i had time I would post an example.
Unfortunatly you may have to wait for another.
Sorry

Try searching the newcomers forum...this question will have been asked before.

BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 8th Sep 2005 02:17
You pass data with DATA. Basically it accumulates a giant stack of data, and if you use RESTORE or RESTORE label it will go back to the beginning of the stack or wherever the label is in front of some data. I tried to use restore recently in my project, and it weirded out, found it easier to just restate the DATA. To get this data you use READ. That will get the next data from wherever the pointer is.

DATA 1
READ number
print number

That will print "1" to the screen.

Say you have data for several player enemies.

DATA "bad dude 1", 100, "pistol"
DATA "bad dude 2", 120, "whip"
DATA "bad dude 3", 150, "bananagun"

You could get data for these three bad guys with something like this:

dim EnemyName$(3)
dim EnemyHealth(3)
dim EnemyWeapon$(3)

for i = 1 to 3
read EnemyName$(i)
read EnemyHealth(i)
read EnemyWeapon$(i)
next i

I can't remember if you can read to arrays or not, but it doesn't really matter, some experimenting can answer that.


I like to separate my DATA statements into functions, so that way I can call it at any time to get specific data I'm looking for. Then you can stick those functions in #include files as somebody else mentioned. Don't just put DATA statements in an #include file though, DB will get angry at you--#includes do functions only.


I'm going to eat you!
Nul error
19
Years of Service
User Offline
Joined: 12th Aug 2005
Location:
Posted: 8th Sep 2005 06:02
is there a way to make it so you can add/edit the data via spreadsheet style? example

Hull (tab) cost (tab) mass (tab) ect...
scout (tab) 1000 (tab) 30kt (tab) ect...

It would make stats easier when im using excel to make the item stats.
Crystal Darkness
19
Years of Service
User Offline
Joined: 7th Feb 2005
Location: United States
Posted: 8th Sep 2005 20:10
Thanks a lot guys! Especially BearCDP! That really helped. One quick question though, is there any reason to put the DATA statements on different lines? and when you READ them, do they automatically read the next one in line? If I could get these last questions answered, I think that I'd be set! Thanks again!

Regards,
CD
Crystal Darkness
19
Years of Service
User Offline
Joined: 7th Feb 2005
Location: United States
Posted: 8th Sep 2005 20:19
Hey, you know what! Thanks to BearCDP's tutorial, I got it! Thanks a million!

Regard,
CD

Login to post a reply

Server time is: 2024-11-27 18:35:28
Your offset time is: 2024-11-27 18:35:28