view scripts/plot/orient.m @ 5365:c9c773d8333f

[project @ 2005-05-23 20:05:15 by jwe]
author jwe
date Mon, 23 May 2005 20:05:15 +0000
parents dd230a6f68f6
children 34f96dd5441b
line wrap: on
line source

## Copyright (C) 2001 Paul Kienzle
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, write to the Free
## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.

## -*- texinfo -*-
## @deftypefn {Function File} {} orient (@var{orientation})
## Set default print orientation.  Valid values for @var{orientation}
## include @code{"landscape"} and @code{"portrait"}.  If called with no
## arguments, return the default print orientation.
## @end deftypefn

## Author: Paul Kienzle
## Adapted-By: jwe

## PKG_ADD: mark_as_command orient

function retval = orient (orientation)

  static __print_orientation__ = "landscape";

  if (nargin == 0)
    retval = __print_orientation__;
  elseif (nargin == 1)
    if (strcmp (orientation, "landscape") || strcmp (orientation, "portrait"))
      __print_orientation__ = orientation;
    else
      error ("orient: unknown orientation");
    endif
  else
    usage("orient ([\"portrait\"|\"landscape\"])  OR  ret = orient ()");
  endif

endfunction

%!assert(orient,"landscape") # default
%!test orient('portrait')
%!assert(orient,"portrait")  # change to portrait
%!test orient('landscape')
%!assert(orient,"landscape") # change to landscape
%!fail("orient('nobody')","unknown orientation")
%!assert(orient,"landscape") # errors don't change the state