Qbasicnews.com
April 03, 2020, 07:19:21 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: Reading a file into multiple variables  (Read 3881 times)
Ruudboy
Ancient Guru
****
Posts: 544



« Reply #15 on: September 04, 2003, 09:09:46 AM »

right this is what i basically want to do

open filename$ for output as #1
     input #1, fileinput$
     if fileinput$ > then
 then it continues saving here and so on.

no please help me
Logged

url=http://www.spreadfirefox.com/?q=affiliates&id=0&t=79][/url]
Neo
Na_th_an
*****
Posts: 2150



« Reply #16 on: September 04, 2003, 10:32:52 AM »

You can try this code:

Code:
OPEN filename$ FOR BINARY AS #1
   DIM Array(LOF(1) / 2500) AS STRING
   got& = 0
   flen& = LOF(1)
   buffer$ = SPACE$(2500)
   buffersize = 2500
   index = 0
   DO
      IF got& + buffersize > flen& THEN buffersize = flen& - got&
      buffer$ = SPACE$(buffersize)
      GET #1, , buffer$
      Array(index) = buffer$
      index = index + 1
      got& = got& + buffersize
   LOOP UNTIL got& = flen&
CLOSE #1


This code stores the file into the Array().
Logged
Ruudboy
Ancient Guru
****
Posts: 544



« Reply #17 on: September 04, 2003, 02:23:24 PM »

mm thanx. is there any better code than this(no offence neo)
Logged

url=http://www.spreadfirefox.com/?q=affiliates&id=0&t=79][/url]
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #18 on: September 04, 2003, 04:28:59 PM »

Quote from: "GDMGames"
mm thanx. is there any better code than this(no offence neo)

I don't think there's a lot that could be done to improve on his code - it's well thought out and does what you asked for.
The question is: are you really sure you want it in a set of 2500 byte blocks?
There might be a better approach, but it depends: What kind of file will it be loading, what will it do with it? etc...
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #19 on: September 04, 2003, 10:16:15 PM »

Quote from: "Sterling Christensen"
...The question is: are you really sure you want it in a set of 2500 byte blocks?
There might be a better approach, but it depends: What kind of file will it be loading, what will it do with it? etc...

GDM:
Sterling and I have the same fundamental questions about the 2500 byte blocks, the kind of input file, and what will you do with it? Share your ideas with us.
*****
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!