943,993 Members | Top Members by Rank

Ad:
Dec 19th, 2004
0

QBasic opening notepad files

Expand Post »
I am having trouble getting the right code to look at a .txt file and print a random word from a list, going down the .txt file. I can get it to open the file which i think is:
OPEN "whatever" FOR INPUT AS ?
and then print ?
I am a bit stuck. Sorry if the question is hard to understand. Thanks
TP :rolleyes:
Oh, by the way, this is in QBASIC!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Tom Pilk is offline Offline
14 posts
since Dec 2004
Dec 19th, 2004
0

Re: QBasic opening notepad files

CLS
RANDOMIZE TIMER
OPEN "test.txt" FOR INPUT AS #1
DIM wds$(1000)
count% = 0
WHILE NOT EOF(1)
LINE INPUT #1, LL$
FOR K% = 1 TO LEN(LL$)
IF MID$(LL$, K%, 1) = " " OR K% = LEN(st$) THEN
count% = count% + 1
wds$(count%) = RTRIM$(MID$(LL$, LastK% + 1, K% - LastK%))
LastK% = K%
END IF
NEXT K%
test% = RND * count%

PRINT wds$(test%)
FOR K% = 1 TO count%: wds$(K%) = "": NEXT
count% = 0: LastK% = 0
WEND
CLOSE #1
Reputation Points: 11
Solved Threads: 0
Light Poster
Buff is offline Offline
40 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: Importing Text into Quick Basic 4.5
Next Thread in Legacy and Other Languages Forum Timeline: call absolute in QBasic





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC