Hi!

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
%

Well, you have specified only the "in" option in your getArgs record. What did you mean by "ozecho --foo" ?

The command "ozecho foo" doesnt do anything.

It does: return status code 1. You ate the exception, so you know nothing :-)

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.

It's OK, that's just a path where the distribution was compiled. The version number is OK as well I think.

Try this instead:

functor
import
   Application
   Open
   System
define
   Args = {Application.getArgs record('in'(single type:string))}}
   Status = try
               O={New Open.file init(name: stdout flags:[create truncate 
write])}
            in
               local
                  proc {PutOut}
                     S=Args.'in'
                  in
                     if S\="" then
                        {O write(vs:S)}
                     end
                  end
               in
                  {PutOut}
               end
               0
            catch E then
               {System.showInfo {Value.toVirtualString E 100 100}}
               1
            end
   {Application.exit Status}
end

and run it using "ozecho --in=foo". Note the change of "{Args.'in'}" to "Args.'in'" and the removal of the endless recursion from PutOut. But I suppose you meant "in" to do something else....

Also try replacing PutOut by:
                  proc {PutOut}
                     if {HasFeature Args 'in'} then
                        S=Args.'in'
                     in
                        {O write(vs:S)}
                     end
                  end
You can then use "ozecho" (i.e. not supplying the --in option does not cause an exception).

Cheers,
Filip
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to