I'm trying my hand at a simple program to print a Shakespearean Insult.
I thought I'd use the read and data command, but I can't seem to get it to work. The code is listed below.
I keep getting the error Syntax Error (6, READ) (Insufficient DATA available for a READ)
I have it set up so that each DATA statement holds one word from column1, column2, column3 There are 50 DATA statements, so I have a FOR-NEXT loop to load the data, but it never gets that far.
Does this mean I have to put each word on a separate DATA line? I thought they could be separated by commas, and still work.
I haven't touched BASIC in years, so any help would be appreciated
PRINT "Shakespearean Insult Generator" PRINT REM Read the data for the three columns DIM C1$(50):DIM C2$(50):DIM C3$(50) FOR I=1 TO 50 READ C1$(I) READ C2$(I) READ C3$(I) NEXT I REM Choose three random numbers O=(RND(50)+1) T=(RND(50)+1) R=(RND(50)+1) REM Print Insult PRINT "Thou "+C1$(O)+" "+C2$(T)+" "+C3$(R) END DATA "artless","base-court","apple-john" DATA "bawdy","bat-fowling","baggage" DATA "beslubbering","beef-witted","barnacle" etc.
The main thing to note is that all arrays in the program are zero-based. That is, for an array declared DIM C1$(50), the first element is C1$(0), the second element is C$(1), and so on, to the 50th element, which is C1$(49). Thus, your first IF statement should be:
FOR I=0 TO 50
, which will iterate 0, 1, 2...49.
The second thing to change would be those three RND() statements, which shouldn't have 1 added to them, because of the aforementioned zero-based index thing. Leaving them as is is fine, since RND(50) will select a number from 0-49, which is right in the range of the arrays you are declaring.
I don't think you need to RESTORE to the start of the DATA though, since READ by default will start reading from the first DATA in your program.
Activity is overrated. LOLLANDMASTER - SBAllen, 2/2/08