Maity, Ashis K wrote:
Sorry -- looks like our smarty-pant firewall blocked your attachment
since it had extension .oz. Would you mind renaming it to
CompileData.allow and resend it?

Thanks again,

Ashis
Here you go.
BTW, you can also see all posts on the Web: http://lists.gforge.info.ucl.ac.be/pipermail/mozart-users/2009/010923.html

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

Reply via email to