On Fri, Sep 5, 2008 at 9:03 PM, mark <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I have this functor definition which processes a spreadsheet .csv file.
>
> functor
> import
>  QTk at 'x-oz://system/wp/QTk.ozf'
>  Open
>  System
> export
>  GetCell
>  GetRow
>  OpenCsv
>  ParseLine
> define
>  fun {ParseLine L}
>     {List.toTuple line {String.tokens L &,}}
>  end
>
>  fun {GetCell Record Row Col}
>     Record.Row.Col
>  end
>
>  fun {GetRow Record Row}
>     Record.Row
>  end
>
>  proc {OpenCsv File?}
>     try
>    FileName={QTk.dialogbox load(title:"Select CSV file"
>                     defaultextension:"csv"
>                     filetypes:q(q("All Files" q("*"))) $)}
>     in
>    {New Open.file init(name:FileName flags:[read]) File}
>     catch
>    error(_)
>     then
>    {System.show 'Error'}
>     end
>  end
> end
>
> How can I wrap all this in a class definition instead so that FileName and
> Record are attributes of a class?
>

My advise is to go to
http://www.mozart-oz.org/documentation/tutorial/node10.html#chapter.classeswhere
classes and objects are explained. Section 10.3 gives you a complete
example on how to define classes and create objects from them.

When you have finished to create a class version of your code then just
export the class in the functor. Having this, you will be able to create
different objects by importing the new created funtor from other functors.

If you have any problem, feel free to post your new code and ask any
question.

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

Reply via email to