(include "sci.sh")
(use "Obj")
(script 993)



(class {gamefile.sh} of Obj
    (properties
        handle 0
    )

    (method (dispose)
        (self:close())
        (super:dispose())
    )


    (method (showStr param1)
        Format(param1 993 0 name)
    )


    (method (open param1)
        = handle 
            (switch (paramTotal)
                (case 0
                    (FOpen(name 0)  )
                )
                (case 1
                    (FOpen(name param1)  )
                )
                (default 
                    (-1 )
                )
            )
        return 
            (if (== handle -1)
                0
            )(else
                self
            )
    )


    (method (write param1)
        (var temp0)
        (if (not handle)
            (self:open())
        )
        = temp0 0
        (while (< temp0 paramTotal)
            FPuts(handle param1[temp0])
            ++temp0
        )
    )


    (method (read param1 param2)
        (if (<> paramTotal 2)
            return 0
        )
        (if (not handle)
            (self:open(1))
        )
        return FGets(param1 param2 handle)
    )


    (method (close)
        (if (handle)
            FClose(handle)
            = handle 0
        )
    )

)
