Liberty BASIC Community Forum
« Filling an array from a file... »

Welcome Guest. Please Login or Register.
Jan 22nd, 2018, 5:55pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Filling an array from a file...  (Read 168 times)
fox
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 176
xx Filling an array from a file...
« Thread started on: Oct 23rd, 2017, 09:52am »

Hi all.
Generally if I have to fill an array retrieving data from a file.txt I use this piece of code:
Code:
tot = 0
dim myarray$(x)
open myfile$ for input as #1
while eof(#1) = 0
       input #1, myarray$(tot)
       tot = tot + 1
wend
close #1
 

So if my file.txt has 5 items like the example:
1 item
2 item
3 item
4 item
5 item
myarray$ will be filled so:
myarray$(0) = 1 item
myarray$(1) = 2 item
and so on.
But I wolud like to know if there is a way to fill myarray$ starting directly from 3 item, skipping 1 item and 2 item.
Thanks a lot to all and bye
fox

User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5618
xx Re: Filling an array from a file...
« Reply #1 on: Oct 23rd, 2017, 10:17am »

Code:
tot = 0
dim myarray$(x)
open myfile$ for input as #1
input #1, dummy$
input #1, dummy$
tot=3
while eof(#1) = 0
       input #1, myarray$(tot)
       tot = tot + 1
wend
close #1 


Or similar, on my iPhone so short and sweet.
User IP Logged

fox
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 176
xx Re: Filling an array from a file...
« Reply #2 on: Oct 23rd, 2017, 10:35am »

Ok Rod, thanks a lot.
fox
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls