Freejack wrote:
Alright...I just slapped together a little echo script to help me get a
feel for text handling in Oz. Here it is my ozecho script...
functor
import
Application
Open
define
Args = {Application.getArgs record('in'(single type:string))}
%% 'out'(single type:string))}
This says that your program as an option --in taking a string as in
"ozecho --in=foo"
If you want your argument to be --foo, just say : record(foo(single
type:string))
Status = try
O={New Open.file init(name: stdout flags:[write create
truncate])}
stdout is already open, so you don't need to pass the flags
in
local
proc {PutOut}
S={Args.'in'}
Crash! Args contains a record of virtual strings, but, by adding the
curly braces, you are actually trying to call a string. This raises an
exception, that you catch blindly.
You should try
S=Args.'in'
in
if S\="" then
{O write(vs:S)} {PutOut}
Are you sure that you want this recursive call? You are cloning "yes",
not "echo".
end
end
in
{PutOut}
end
0
catch _ then 1
end
{Application.exit Status}
end
The compiler doesn't give me any problems with this. However, when
running it with an argument, it pukes. ozecho --foo gives me this error...
%***************** Error: application programming ***************
%**
%** unknown option `foo'
%**
%**
%** Call Stack:
%** procedure 'GetLongOptSpec' in file "./ap/Application.oz", line 474, column
2, PC = 136070008
%** procedure 'ParseLongOpt' in file "./ap/Application.oz", line 497, column 2,
PC = 136070204
%** procedure 'ParseOptions' in file "./ap/Application.oz", line 517, column 2,
PC = 136070952
%** procedure 'ProcessArgv' in file "./ap/Application.oz", line 747, column 3,
PC = 136034076
%** procedure in file "./ozecho.oz", line 1, column 0, PC = 135799404
%** procedure 'RootManager,Pickle/fast' in file "./init/Module.oz", line 244,
column 6, PC = 135764704
%** procedure in file
"/home/kost/compile/build-1.3.0/updates/mozart/share/lib/base/Base.oz", line
92, column 7, PC = 135883484
%
The command "ozecho foo" doesnt do anything.
However, try ozecho --in=foo
However, that last line in the error message looks a little strange. Who's
kost? Their not on my host, that's for certain. Hardcoded path in the
compiler perhaps? This is version 1.3.1 that I've downloaded.
kost is Kostja, one of the main Mozart developers. If you want to get
rid of all the paths like that, you have to bootstrap from sources,
using make bootstrap.
All the other stuff I've written so far seems to work just fine. Any
pointers would appreciated.
Use the Hopi and either the Browser or the Inspector They ease the
prototyping of application and will let you try things much faster than
the writing an application module/compile it/run it cycle. Actually your
Ada background is biting you here : by making your trials bullet-proof,
they don't break, so you cannot look at the pieces. Oz error messages
contains sometimes a lot of information.
Read the tutorials, even if you know what they are talking about, some
constructs are described nowhere else.
Read the reference sections (in particular The Oz Base Environment &
System Modules). They are quite readable and contain most of the API.
If you want something bigger, obtain a copy of "Concepts, Techniques and
Models of Computer Programming" by P. Van Roy and S. Haridi This book
covers most of the concepts in the language.
Freejack
Yves
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users