spartacus
25th June 2003, 17:56
I would like to read files from a folder which belongs somehow together.

Lets say I find a file named "file1.txt" to that file I need a file "file1.par" from the same folder.

If I don't want to rely upon the sort sequence. What possiblities exist in Baan to open the second file ("file1.par"), and after that continue reading the folder from the position of "file1.txt"?

At the moment I open the folder the second time to read the "parameterfile". This appears to me, not to be a very good style!

Thanks
Spartacus

maximus
25th June 2003, 19:08
Hi,

Do we have a Unix platform on which this operation has to be performed ? If so we may read all the required files in sequence thru pattern match in unix in to a tmp file with delimeters and then in baan, read that delimeted / hashed file.

Just a thought !! We may possibly do seq file preparation in baan itself and then use that file.

If you could fill in more details I may be able to help more.

Regards
Max

NPRao
25th June 2003, 21:31
Spartacus,

here is a sample code for you-

function main()
{
long fd, count, rt, size, mode, fp, posn
string fname1(80), fname2(80), fpath(80), buffer(1024)

count = 0
fpath = "/home/bsp"
fd = dir.open(fpath)
if fd < 0 then
mess("zmadms0046", 1, fpath)
|* Directory Handling Errors: %1$s
exit(1)
endif
fname1 = dir.entry(fd, TFILE, rt, size, mode)
while (not isspace(fname1))
count = count + 1
posn = rpos(fname1, ".txt") - 1
if posn > 0 then
fname2 = fname1(1; posn) & ".par"
fp = seq.open(fname2, "r")
if fp < 0 then
mess("zmadms0036", 1, fname2)
|* File Opening Error: %1$s
|* Parameter file not found...
e = seq.close(fp)
fname1=dir.entry(fd, TFILE, rt, size, mode)
continue
else
while not seq.gets(buffer, 1024, fp)
|* Parameter file found - do.something......
endwhile
e = seq.close(fp)
endif
endif
fname1=dir.entry(fd, TFILE, rt, size, mode)
endwhile
e = dir.close(fd)
if not count then
mess("zmadms0045", 1, fpath)
|* No files in directory: %1$s
exit(2)
endif
}

spartacus
26th June 2003, 10:24
Thank you both for your answers.

At the moment I have a solution simlar zu NPRao's. But I think, to keep things more flexible I will read the "entries" into a table, an continue with this table.

NPRao: How is it possible to enter this nice "baan-code"?


Spartacus