Rinkashiki
15th April 2013, 01:22
hello.
have a *.txt. there are several lines of different lengths.
how to read each line?
by seq.read(), but what should be nrbytes?
sample file:
OSN
12/1~005.123.123~dgdfgdfg~fsdfsdf~~~
12/1~010-030~dsfdsfs~~sdfsd~~
~~~~sdfsdf~~
~~~~sdfsdf~~
~~~~sdfsdf~~
~~~~sdfsdf~~
PREDOK
dgdfgdf~dgtyrtyrty~005~dfrsdfsd~dfsdfsd~040~kghkg
...

Anton.k
15th April 2013, 07:23
Hi.

string file.name(255), line(50)
string str(2048), delemiter
domain tcitem item
domain tcclot clot
long i

file.name = "D:/baan_data_import/item.txt"
File.import = seq.open(file.name, "r")
if (File.import<=0) then
message("Not found file!")
endif

delemiter= "~"

while seq.gets(str,2048,File.import)=0

i=pos(str,delemiter)
item=strip$(str(1;i-1))
str=str(i+1)

i=pos(str,delemiter)
clot = str

endwhile

Rinkashiki
25th May 2013, 03:01
how to find the file in the folder, if the unknown full file name?for example, the name of the file that is in the folder 123 rty.txt, and I only know that it starts at 123.

mark_h
25th May 2013, 04:04
Look at this thread (http://www.baanboard.com/baanboard/showthread.php?t=43237&highlight=read+local+directory) and see if it helps. Of course if they have multiple files in the directory starting with 123 I am not sure how you would know which one it should be.

Rinkashiki
25th May 2013, 06:12
in the folder there are many files: 123 try 1.txt, 123 re 2.txt, 123 gh 1.txt. and I know that it starts at 123 re. where the files are located on a local drive. the specified function dir.open ("d:\MP"). results are -2.