actually the file-operations are non-deterministic and thus (1) never executed out of order and (2) even executed if you would not return their results ($o, $o2, $o3) and thus might be removed by the compiler.
I came up with the following example that waits 2 seconds before actually writing to $o2:
let $o := file:create-dir("foo")
let $o2 := file:write("foo/file1.xml",
(function(){
prof:sleep(2000),
"Written to File1.xml"
})()
)
let $o3 := file:write("foo/file2.xml", file:read-text("foo/file1.xml"))
return file:read-text("foo/file2.xml“)
So most probably your example does not fully reflect what’s actually happening — maybe you could provide some more context?
If you want to, you may even send your query to me directly so you won’t have disclose it on this mailing list.
Best from Konstanz
Michael
let $o := file:create-dir("/Users/mycomputer/prova")
let $o2 := file:write("/Users/mycomputer/prova/file1.xml", "ciao")
let $o3 := file:write("/Users/mycomputer/prova/file2.xml", file:read-text("/Users/mycomputer/prova/file1.xml"))
return
($o, $o2, $o3)
This actually works. In my real example the writing of $o2 requires e few seconds. It might be that $o3 is evaluated while $o2 is still running?
Dr. Giuseppe G. A. Celano
DFG-project leaderUniversität Leipzig
Institute of Computer Science, NLP
Augustusplatz 10
On Mar 12, 2019, at 11:27 AM, Michael Seiferle <
ms@basex.org> wrote:
Hi Guiseppe,
The following pattern is supposed to / does work:
file:write("1.txt", "Written to 1.txt"),
file:write("2.txt", file:read-text("1.txt")),
"Read from 2.txt: " || file:read-text('2.txt')
Could you maybe elaborate a bit more on your code?
Best from Konstanz
Michael
Hi
I wrote a single script which should do: write a file -> open this file -> write another different file. I put the write expressions in the right sequence, but it seems that the second one cannot happen because the file created by the first write function has not yet been created at the time the second function is invoked. Does anyone have a suggestion about this? Thanks.
Best,
Giuseppe