Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with file reading
#1
is there any way i can make this program better in terms of file accecing?
Code:
CLS
OPEN "blank.txt" FOR INPUT AS #1
INPUT #1, a$
FOR letter = 1 TO LEN(a$)
b = ASC(MID$(a$, letter, 1))
SELECT CASE b
    CASE 65 TO 90
        b = (((b - 65) + 1) MOD 26) + 65
    CASE 97 TO 122
        b = (((b - 97) + 1) MOD 26) + 97
END SELECT
MID$(a$, letter, 1) = CHR$(b)
NEXT letter
CLOSE #1
OPEN "blank.txt" FOR OUTPUT AS #1
WRITE #1, a$
PRINT a$
CLOSE #1
and any other sugetions are good, but i dont want peek and poke yet
Reply
#2
PEEK and POKE not needed. The program is OK, but I'd change INPUT for LINE INPUT and WRITE # for PRINT #.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
you might want to use UCASE$ or LCASE$ too.

Code:
CLS
OPEN "blank.txt" FOR INPUT AS #1
LINE INPUT #1, a$
FOR I% = 1 TO LEN(a$)
j% = ASC(LCASE$(MID$(a$, I%, 1)))
MID$(a$, letter, 1) = CHR$(j%-65)
NEXT I%
CLOSE #1

OPEN "blank.txt" FOR OUTPUT AS #1
PRINT #1, a$
PRINT a$
CLOSE #1
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)