Hello friends,
I have one little question, please.
How to make the short routine, for READ data from TXT file?
I have in TXT list:
012346
244565
125475
...
And now, I'd like to get these values into the fields:
a[1]=012346
a[2]=244565
a[3]=125475
...
Thank you in advance!
P.S.
In Freebasic for example is this:
filename="C:\DIR\file.txt"
open filename for input as #1
for i=1 to 1000
input #1,ax(i)
next i
close #1
Read data from TXT
-
- Posts: 20
- Joined: Sun Jan 25, 2015 10:37 am
- Location: Prague, Czech Republic
- Contact:
Re: Read data from TXT
Use Readfile() to open a file and ReadString() to read a line of text.
You find all informations and working examples in the documentation.
You find all informations and working examples in the documentation.
-
- Posts: 20
- Joined: Sun Jan 25, 2015 10:37 am
- Location: Prague, Czech Republic
- Contact:
Re: Read data from TXT
I tried, of course, but the example is too complicated. Contains OpenFileRequester that I can't remove...
Re: Read data from TXT
Here a very simple example:
Note that you can't use the file path like "C:\DIR\file.txt", use relative path.
Code: Select all
filename.s = "file.txt"
Procedure Callback(Status, Filename, File, SizeRead)
If Status = #PB_Status_Loaded
While Not Eof(0)
Debug ReadString(0)
Wend
EndIf
EndProcedure
ReadFile(0, filename, @CallBack())
-
- Posts: 20
- Joined: Sun Jan 25, 2015 10:37 am
- Location: Prague, Czech Republic
- Contact: