QBasic opening notepad files

Reply

Join Date: Dec 2004
Posts: 14
Reputation: Tom Pilk is an unknown quantity at this point 
Solved Threads: 0
Tom Pilk's Avatar
Tom Pilk Tom Pilk is offline Offline
Newbie Poster

QBasic opening notepad files

 
0
  #1
Dec 19th, 2004
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!
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 40
Reputation: Buff is an unknown quantity at this point 
Solved Threads: 0
Buff Buff is offline Offline
Light Poster

Re: QBasic opening notepad files

 
0
  #2
Dec 19th, 2004
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC