| | |
QBasic opening notepad files
Please support our Legacy and Other Languages advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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!
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!
•
•
Join Date: May 2004
Posts: 40
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- C:\Program Files\Common keeps opening on boot (Windows NT / 2000 / XP)
- Opening 20,000 notepad files and appending to one document (C#)
- Opening 20,000 notepad files and appending to one document (C)
- All exe files are openin in notepad (Windows NT / 2000 / XP)
- QBasic & undeletable files (Legacy and Other Languages)
Other Threads in the Legacy and Other Languages Forum
- Previous Thread: Importing Text into Quick Basic 4.5
- Next Thread: call absolute in QBasic
Views: 4736 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Legacy and Other Languages





