Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / How do i load a txt file with names and values into an array ?

Author
Message
Lryd
20
Years of Service
User Offline
Joined: 6th Mar 2004
Location:
Posted: 10th Mar 2004 02:26
hello, how do i open an txt files with 10 names
and ten helht values like this and load it into an array

i know how to do it in visual basic but how to do it in darkbasic

could i do like this ?

dim ifilnum1 as integer
dim s_arr(10) as variant
file_path="c:\names.txt"
ifilnum1=freefile+1

do while not eof(ifilnum1)
line input #ifilnum1,row
x=x+1
redim preserve s_arr(x)
s_arr(x)=row
loop
close #ifilnum1

that would load an txt file in visual basic into an array
but how do i do it in darkbasic... the syntax is confusing...

Thanks for helping me!


BearCDPOLD
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 10th Mar 2004 02:55
DIM s_arr(10)
OPEN TO READ 1, "c:\names.txt"

FOR i=1 to 10
READ FILE 1, s_arr(i)
NEXT i

Depending on the type of data you have in the file you can use the following read commands:
READ FILE
READ BYTE
READ WORD
READ LONG
READ FLOAT
READ STRING

At least, this is how DB Classic does it.

Crazy Donut Productions
Current Project: KillZone
Lryd
20
Years of Service
User Offline
Joined: 6th Mar 2004
Location:
Posted: 10th Mar 2004 15:12
Thanks...its great! to know.

Cheers Lryd

Login to post a reply

Server time is: 2024-09-22 00:32:13
Your offset time is: 2024-09-22 00:32:13