Posts: 245
Threads: 48
Joined: Dec 2004
I have never understood how to work the DATA command. I've seen it used by Relsoft and others, but I never could get it to work. Qbasic help doesn't explain, and I don't have the file Remline.bas, so there are no good examples. Who will help me?
Also, how can I get more than the 16 colors available with the COLOR command? I've seen Relsoft (again with Relsoft!) use different shades (again he used DATA) but every time I attempt it it goes all funky.
HELP!
:wink: :rotfl: :bounce: :oops: :barf: :wink: :rotfl: :bounce: :oops: :barf:
Oh, that stuff about me leaving... well, I decided to stay, against my mom's wishes(she's the type that fears my protection online).
Posts: 3,522
Threads: 189
Joined: Dec 2003
Code: Read a
Read b
Read c$
Print a; b; c$
DATA 10, 20, "Hello there!"
Code: Dim Array(4) As Integer
For a = 0 To 4
Read Array(a)
Next
For a = 0 To 4
Print Array(a);
Next
DATA 9, 8, 7, 6, 5
Code: Dim Array1(4) As Integer
Dim Array2(4) As Integer
For a = 0 To 4
Read Array1(a)
Next
Restore DataLocation
For a = 0 To 4
Read Array2(a)
Next
For a = 0 To 4
Print Array1(a);
Print Array2(a)
Next
DataLocation:
DATA 9, 8, 7, 6, 5
Which screen mode are you using? Screen 12 only has 16 colors for example, to change a color use the palette command:
Code: col = 15
Red = 10
Green = 63
Blue = 29
Palette col, 65536*Blue + 256*Green + Red
Color 15
Print "Not white =)"
Red, Green and Blue can range from 0 to 63
And you're quite safe on the internet, just don't give away phone number or home adress, ever. Well, I do, but then again, I'm crazy :lol:
Posts: 243
Threads: 12
Joined: Aug 2001
Good examples, Z!re
I would like to add that you cannot use DATA statements within a SUB or FUNCTION.
So you have to put all data in Main. You can give it labels and use RESTORE to get the data you want.
I hate DATA therefore and in SUBs, would use
Code: for n=1 to 50
A(n)="This is line one"
A(n)="This is line two"
...
A(n)="This is the last line"
next n
rather than stick
DATA "This is line one"
etc. in the Main and READ it into the SUB.
For what it's worth...
Mac
Posts: 6,419
Threads: 74
Joined: Mar 2002
Quote:I would like to add that you cannot use DATA statements within a SUB or FUNCTION.
You can:
Code: DECLARE SUB poo
someNumbers:
DATA 1, 1, 2, 3, 5, 8, 13, 21
SUB poo
RESTORE someNumbers
FOR i% = 1 TO 8
READ n%
PRINT n%;
NEXT
END SUB
Posts: 243
Threads: 12
Joined: Aug 2001
Sorry, na_th_an
I said:
"I would like to add that you cannot use DATA statements within a SUB or FUNCTION"
I should have said:
I would like to add that you cannot place DATA statements within a SUB or FUNCTION
I spoke vaguely about RESTORE. Thank for clearing it up. j2krei08 was confused enough without my addition.
Mac
Posts: 75
Threads: 11
Joined: Nov 2003
j2krei08,
What's already been posted is good, but since it wasn't clear, (at least to me anyway), about how much you already understand,I'd like to add a couple of things.
First: The comma's(,) are used to seperate the information.
(i;e If you have four bit's of information: a,b,c,d
The "a" would be your first bit of information read in, then b, and so on.
Second: Be sure to use quotation marks when using phrases:
(i;e a,b,c,d," Here's the phrase, I think! ".
You can use comma's within a phrase/sentence like I did above, because this is read in as a string($) item.
That's why Z!re used the $ sign in his example: "Read c$"
This tells the computer that it's going to be a phrase/sentence.
In short, if the comma is outside of quotation marks it's used as a seperator/divider, if it's inside, it's just part of the sentence.
One last note.
Make sure there is no comma after the last bit of information to be read in as there isn't anything else to be read in.
If there is a comma, you will get an error message. Guarenteed!
I hope this helped and didn't confuse you any futher. :o
adsherm
Posts: 544
Threads: 27
Joined: Jan 2005
Also, read the post, "MULTIPLE DATA STATEMENTS", in this same forum. The "RESTORE SomeLabel" method of selecting a particular group of DATA ithat na_th_an and Mac have talked about is also shown there.
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Posts: 2,771
Threads: 96
Joined: Oct 2003
an aptly named sub there, nathan.
Posts: 143
Threads: 35
Joined: Oct 2004
Mac........im sorry but that is the coolest avatar i have ever seen :o
|