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.

Author
Message
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 25th Feb 2008 05:14
i just got done using search and i read the help file but what is the "data" command for. Ive seen it used but i dont understand its purpose.

<a href="http://lovelyd.shukuya.com/enters/e3.gif"></a>
pirate
18
Years of Service
User Offline
Joined: 18th Apr 2006
Location: u.s.a
Posted: 25th Feb 2008 06:37
this is for qbasic but it does a good job explaining the data and read statements.


i hope this will help you understand data and read.

thanks, pirate
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 25th Feb 2008 08:31
hmm... i still dont really get it. I understand that "read" reads from data. but how does it know where to put the data and what data to put there?

in : "read a(i)"

what is "a" and what is "i"? im so confused.

<a href="http://lovelyd.shukuya.com/enters/e3.gif"></a>
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 25th Feb 2008 11:20
It looks as though A is a reference to an array

it looks as though the i variable is an integer which is incremented each time the 'FOR' loop does another cycle.

Therefor rather than putting:
READ A(0)

READ A(1)

READ A(2)

READ A(3)

READ A(4)

READ A(5)
....up to eight.

Dont worry about the loops etc, the actual concept is really simple, its what you then do with the read data that can really make a program intelligent etc..

hth
Paul
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 25th Feb 2008 16:25
okay I think i figured it out. so basically it reads the values in order. so:



would read data values in order form 1-6 and input them into an array so the final result would be

1
2
3
4
5
6

being printed to screen?

I stayed up all night learning this and memory blocks. I think i pretty much got them both down pat. so heres a sample program tell me if it would work so i know where i stand...(im at school and dont have access to dark basic so some syntax may be wrong...)



that would create an identical effect to the first code right? and i have a another question (i know im asking alot) are mem blocks the same as nodes in singularly linked lists in c++? i had alot of trouble grasping that concept in c++ but if so its alot easier than i thought.

i read somewhere that memblocks are faster that data. is this true? it would make sense as (as far as i have deduced) a memblocks memory address is memorized for quicker refernce its like knowing where your friend lives. whereas using variables is like knocking on every door to every house/apartment you see until your friend answers. in otherwords you computers has to check all data as it does not know the current memory address. I know this is alot to post but hang in there with me. I thank you for anby imformation on this topic that you can give me.

~vesper103

<a href="http://lovelyd.shukuya.com/enters/e3.gif"></a>
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Feb 2008 20:15
Let's try a code sample that doesn't make someone's eyes glaze over.



DATA is a way to have a list of "stuff" ready to used in your program. When you Read a value, an imaginary pointer goes to the NEXT DATA "Thing" (Separated by Commas). This is why the guys above showed you a loop - but I looked at their code - though correct - though - OUCH.

Once the Imaginary Pointer gets PAST the end of the list - you usually get an error if you keep trying to "READ DATA" that's not there.

Additionally you can issue the RESTORE command to move the imaginary pointer back to the first item in your DATA list.

You may have one item per data statement like in my code example... or many like the guys showed ya.

You MAY NOT (usually) EXECUTE DATA commands - that is you should let your program try to "RUN THEM" - I tried to demonstrate this in my sample code for you by putting the data statements at the BOTTOM of the program, and having and END STATEMENT BEFORE the DATA commands to illustrate this point.

Hope this helps you further.

Login to post a reply

Server time is: 2024-11-25 07:33:36
Your offset time is: 2024-11-25 07:33:36