Maity, Ashis K wrote:
Thanks Wolfgang. I did not completely get the steps you are recommending! Do
you mind writing a few lines?
Thanks so much,
Ashis
See the attached example.
Cheers,
Wolfgang
declare
%% Data as received by socket
%% (written as a virtual string here because Oz does not have multiline string
literals; but this does not matter to the problem)
TextualData =
"problem("#
" tasks:[ task_Label_100("#
" dur:8 priority:1 start:[102#102] taskType:[t_LESSON t_LECTURE
t_GAO t_FLIGHT_HRS t_TOT_TRAIN_HRS ] resources_used:[ru("#
"
id:[3979 ] num:1
resourceType:c_GEN_STUDENT"#
"
)"#
"
] "#
" )"#
" ]"#
""#
" pdc("#
" name:usagePerPeriodConstraint specificConstraints:sc("#
" taskType:t_LESSON
resourceType:c_GEN_INSTRUCTOR maxTime:160 periodLength:672 stepSize:720"#
" )"#
" )"#
")"
fun {CompileInSeparateProcess DataAsString}
TmpFileNameOz = "tempfile.oz" %% consider using a unique name here,
especially if you plan to call this function concurrently
TmpFileNameOzf = TmpFileNameOz#"f"
TmpFile
CompiledData
ExitCode
in
%% write data
TmpFile= {New Open.file init(name:TmpFileNameOz flags:[write text create
truncate])}
{TmpFile write(vs:DataAsString)}
{TmpFile close}
%% call compiler
ExitCode = {OS.system "ozc -c "#TmpFileNameOz}
{OS.unlink TmpFileNameOz} %% delete temporary file
if ExitCode \= 0 then raise couldNotCompileData(DataAsString) end end
CompiledData = {Pickle.load TmpFileNameOzf}
{OS.unlink TmpFileNameOzf}
CompiledData
end
in
{Browse {CompileInSeparateProcess TextualData}}
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users