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 / Not sure how to use...

Author
Message
UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 7th Nov 2003 05:34
The Data command its a odd command to me so if someone could explain it to me more clearly please =) i read the definition of it in DB and saw the example but yet it dosent help me understand it....im pretty sure its a easy thing to understand but i just dont.

http://www.freewebs.com/ingamers
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 7th Nov 2003 07:30
Quote: "DATA
This command allows you to create a sequence of data values as part of your program. The values can be integer, real or string values. You may place the data values in any order you wish providing you separate each one with a comma or place new data values in a separate DATA statement. Data values can be read from the DATA statement using the READ command, and the point at which the data is read can be reset using the RESTORE command. You can separate batches of DATA statements using labels in order to segment your data for alternative uses.

SYNTAX
DATA Datalist"


Ok... to explain this...

Quote: "You may place the data values in any order you wish providing you separate each one with a comma or place new data values in a separate DATA statement."


this means, put each part of your DATA command either on a new line with a new Data command or seperate it with a comma.
Eg.


Each set of data statements in the above example all hold exactly the same information, in exacactly the same order, they are just set-up differently.

Quote: "Data values can be read from the DATA statement using the READ command, and the point at which the data is read can be reset using the RESTORE command. You can separate batches of DATA statements using labels in order to segment your data for alternative uses."


This is just like a gosub call type-o-thing... The example below will explaing it better..



The screen output of the above example should be:
1
2
6
1


As you can see; the Data command is directly tied in with the Read and Restore commands... Here is a more complex example;



The output for this should be;
1
2
3
6
7
4


That's a start, go from there...

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 8th Nov 2003 02:02
Thanks... I'm just trying to help someone in need...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 8th Nov 2003 07:19
guess that helps me a little so basically data is anything you want it to be as long as the numbers involved actually exist and are seperated by comma's so for like

make matrix 1,1000,1000,10,10
make matrix 2,1000,1000,10,10
make matrix 3,1000,1000,10,10
ect ect...

the data for that would be

data 1,2,3

is that right?

just an example to help me understand cuz the data command is truely confusing me

http://www.freewebs.com/ingamers
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 8th Nov 2003 13:25
No... not quite... um...
Ok, here is an example that will hopefully explain it alot better...



It's long, i know, but just have a read through it first, and try to predict what happens, then run it and see if you got it right... Play with some of the data values and see the results...

This is not really a pratical application of the data command, but it is how it is used...

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 8th Nov 2003 18:49
hmm i think i almost see now....but not to sure one thing still confuses me and thats how you got all the big numbers =\

http://www.freewebs.com/ingamers
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 9th Nov 2003 04:25
The big numbers?

Well, I'm assuming that you are refering to the numbers in the data statements at the bottom... To explain:

this is all the data:


where it says matrix_data:, that, obviously, is the matrix data. I have set it up so that the first element in the data command is the matrix number (the number 1) which is then read into the array position mat(1).
That number is then used to specify the matrix number in the command Make Matrix mat(1),mat(2),mat(3),mat(4),mat(5)
which would mean that, since mat(1) = 1, it is the same as, Make Matrix 1,mat(2),mat(3),mat(4),mat(5)


Then the next number in the data command is the matrix width, 10000, which is read into the array element of mat(2), and the same with the next number, being the matrix depth, is read into the array element mat(3). Each of which are then used to specify the width and depth of the matrix respectively...

Try changing the first 10000 value to 100 and see the results, you should make the matrix a very thin long strip...
That is the advantage of the data statements, it allows you to easyily edit information without haveing to sort through all of your code to find the commad Make Matrix 1,etc,etc... and change the values in that, when all you have to do is change the values in the Data command which is all kept together and is nice and neat...

Hope That Explains it you better...

Oh, and one last thing, the data command can hold Strings and FLoating point variables too, the floating points would be used much the same way that i have shown you to use the interger values in the above examples...

The string variables would be used so that you can keep long strings such as "Created by 'name goes here' On the 22/5/98. This is Version 1.9 of the current project", etc...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 9th Nov 2003 22:43
ok let me see if i got this right

make matrix 1,1000,1000,10,10

then the data for that would be

data 1,1000,1000,10,10

then if i wanted to change say the last 2 numbers on the matrix i could do this

data 1,1000,1000,40,40

and its just another way of editing the matrix without having to seartch for it liek you said....now did i get that right....

http://www.freewebs.com/ingamers
load image "sp1.bmp",1
paste???? 2d games = fun....teach me
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 10th Nov 2003 04:03 Edited at: 10th Nov 2003 04:05
Yes!... you got it.. ok.. now that you understand it properly...

You don't only have to use it for intergers and doing stuff like that...

For example...


That code set's up a matrix using the data commands...
Also, you can use strings etc, which, unfortunatly, i can't go through right now, cos im at school, and class is just about to finish.. lol..

Have fun playing with that example...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 10th Nov 2003 06:38
thanks for the help man i appricate it now only if my spelling would get better =)

http://www.freewebs.com/ingamers
load image "sp1.bmp",1
paste???? 2d games = fun....teach me
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 10th Nov 2003 12:25
Hey that's cool, I'm just being a nice guy


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-21 17:01:42
Your offset time is: 2025-05-21 17:01:42