Posts: 4,307
Threads: 63
Joined: May 2003
winhack:
Heres a much cleaner way of doing it
Code:
CLS
DIM a$(1 TO 12)
FOR i% = 1 TO 12
READ a$(i%)
NEXT
FOR i% = 1 TO 12
PRINT a$(i%)
NEXT
DATA "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"
Posts: 292
Threads: 31
Joined: Apr 2003
Even cleaner would be to combine the two for/next loops.
Code:
qbasic
for i = 1 to 12
read a$(i)
print a$(i)
next
Posts: 4,307
Threads: 63
Joined: May 2003
Yeah. But its kinda funny to see read and print in the same loop. Seriously the reason i kept the two loops separate was that he may not want to use the "READ" statement.
Posts: 719
Threads: 72
Joined: Mar 2003
TYPE MonthType
Name AS STRING
Days AS INTEGER
END TYPE
DIM Month AS MonthType
FOR i = 1 to 12
READ a$, b%
Month(i).name = a$
Month(i).days = b%
NEXT i
FOR m = 1 to 12
Print Month(m).name; " has "; str$(Month(m).Days);" days."
NEXT m
END
DATA "jan", 31
DATA "feb", 28
DATA "mar", 31
DATA "apr", 30
DATA "may", 31
DATA "jun", 30
DATA "jul", 31
DATA "aug", 31
DATA "sep", 30
DATA "oct", 31
DATA "nov", 30
DATA "dec", 31
Posts: 2,765
Threads: 138
Joined: Nov 2002
could you have done
Code:
FOR i = 1 to 12
READ Month(i).name, Month(i).days = b%
NEXT i
instead?
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 5
Threads: 1
Joined: May 2004
Hrm DATA always makes me nervous... probably because I never liked how you coudln't pick when and where to start loading the data -from-... that's probably just me though. :normal:
nce upon a time there crept through the looking-glass a curious child whose manners were not very good. Perhaps a little clever, yes, but given to spying, and sneaking, and going through dead men's pockets... [
cloudmakers]
Posts: 1,752
Threads: 21
Joined: Jun 2002
Posts: 309
Threads: 15
Joined: Jul 2003
In case you didn't notice it, click on "can" in Plasma's post for a link to the explanation.
Also see Zaps comments in your other thread.
hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)
For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
Posts: 5
Threads: 1
Joined: May 2004
Thanks - I think I will probably start using files once I get the hang of them.
nce upon a time there crept through the looking-glass a curious child whose manners were not very good. Perhaps a little clever, yes, but given to spying, and sneaking, and going through dead men's pockets... [
cloudmakers]