Raph,
Thanks for your response. In fact that's the way I started with. May be
I am doing something else wrong. Just to make one point clear is that I
don't know the ozf file names before hand and only the directory where
they would be residing. So I want to check all the files in that
directory and dynamically link all the .ozf files either through
"import" or through the modules that you are suggesting. So the
following should work inside "define" block - right?
% Get the .ozf files from ProgramSpecificConstraint dir
fun{ImportFiles dirName}
Files = {OS.getDir dirName}
{ForAll Files proc{$ X} Y Z in
{String.token X &. Y Z}
if Z == "ozf" then
%Files = X
{Browse 'linking file'#{String.toAtom Y}}
else
{Browse 'did nothing'}
end
end
} in Files
end
[Sched] = {Module.link [ {ImportFiles
'D:\\data\\amaity\\workspace\\Scheduler\\src\\ProgramSpecificConstraints
'}]}
This does compile though. But getting some runtime issues.
Thanks,
Ashis
________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Raphael Collet
Sent: Thursday, October 16, 2008 2:03 PM
To: Mozart users
Subject: Re: "import" ing ozf dynamically
Dear Ashis,
There is a simpler way to load a module from an .ozf file: Module.link.
It takes a list of urls (or file names) and returns a list of modules
(instantiated from the functors found in the files):
[ModuleFoo]={Module.link ['Foo.ozf']}
Cheers,
raph
On Thu, Oct 16, 2008 at 7:01 PM, Maity, Ashis K <[EMAIL PROTECTED]>
wrote:
Hello,
I am new to Mozart. I am trying the following piece of code where I am
trying to import .ozf files dynamically. Is it possible? Seems like I am
always getting the following error (tried "import" both at inside the
proc or calling it from outside) where I try to link the dynamically
obtained file name with a variable name e.g., Sched at X : syntax error,
unexpected T_VARIABLE, expecting T_OZATOM
% Get the .ozf files from ProgramSpecificConstraint dir
proc{ImportFiles dirName ?File} Files in
Files = {OS.getDir dirName}
{ForAll Files proc{$ X} Y Z in
{String.token X &. Y Z}
if Z == "ozf" then XX in
functor XX
import
Sched at X
end
File = X
else
{Browse 'did nothing'}
end
end
}
end
%import
%Sched at {ImportFiles '.'}
Thanks so much,
Ashis
________________________________________________________________________
_________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users