Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
READing from an opened file
#1
i have a 32 by 32 DATA statement in a seperate file. how could i open that file, read the data, put it on the screen and get it?
or would it be easier to just put the data in my program.
(soon the file will contain close to 30 of these 32x32 bitmaps as i make new tiles for my application.
if somebody cuts of your hand you still have two sharp bones to stick in thier eyes"
Reply
#2
It would be easier to put that in your command.

If you still want to use the file as external, remove the "DATA" statements and leave just the numbers:

Code:
4, 5, 6, 4, 3, ...
4, 3, 1, 2, ...

for example. Then you can read it using OPEN and the like:

Code:
f%=FREEFILE
OPEN "MyFile.txt" FOR INPUT AS #f%
FOR i%=1 TO 32
   FOR j%=1 TO 32
      INPUT #f%,c%
      PSET (j%-1, i%-1), c%
NEXT j%,i%
CLOSE #f%

It would be better if you posted the file so we can see the format it has.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
hmm good good. i think you solved my problem
if somebody cuts of your hand you still have two sharp bones to stick in thier eyes"
Reply
#4
Or you could shorten the program a few characters...

Code:
f%=FREEFILE
OPEN "MyFile.txt" FOR INPUT AS #f%
FOR i%=0 TO 31
   FOR j%=0 TO 31
      INPUT #f%,c%
      PSET (j%, i%), c%
NEXT j%,i%
CLOSE #f%
earn.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)