function getinstance(ae,bd, st, se, sop)
local remotecode =
[[
local ae=']]..(ae or servercommand('get_param:MyACRNema'))..[[';
local q2=DicomObject:new();
q2.QueryRetrieveLevel='IMAGE'
q2.StudyInstanceUID=']]..st..[['
q2.SeriesInstanceUID=']]..(se or '')..[['
q2.SOPInstanceUID=']]..(sop or '')..[['
local r = dicomget(ae, 'IMAGE', q2)
local s=tempfile('.txt')
r[0]:Write(s)
returnfile=s
]]
local f = servercommand('lua:'..remotecode, 'binary')
io.write("--"..bd.."\r\n")
io.write("Content-Type: application/dicom\r\n");
io.write("Content-Transfer-Encoding: binary\r\n\r\n")
io.write(f)
io.write("--"..bd.."--\r\n\r\n")
end
But if I use the next, it fail. Could you see what is wrong?
function getinstance(ae, bd, st, se, sop)
local remotecode =
[[
local ae=']]..(ae or servercommand('get_param:MyACRNema'))..[[';
local obd=']]..bd..[['
local q2=DicomObject:new();
q2.QueryRetrieveLevel='IMAGE'
q2.StudyInstanceUID=']]..st..[['
q2.SeriesInstanceUID=']]..(se or '')..[['
q2.SOPInstanceUID=']]..(sop or '')..[['
local r = dicomget(ae, 'IMAGE', q2)
local s=tempfile('.txt')
local t=tempfile('.txt')
f = io.open(s, "wb")
for i=0, #r-1 do
r[i]:Write(t)
f:write("--"..obd.."\r\n")
f:write("Content-Type: application/dicom\r\n")
f:write("Content-Transfer-Encoding: binary\r\n\r\n")
g = io.open(t, "rb")
f:write(g:read('*a'))
f:write("\r\n\r\n")
g:close()
end
f:write("--"..obd.."--\r\n\r\n")
f:close()
os.remove(t)
returnfile=s
]]
local f = servercommand('lua:'..remotecode, 'binary')
io.write(f)
end