1
%# Copyright (C) 2008, Thomas Treichl <treichl@users.sourceforge.net>
3
%# This program is free software; you can redistribute it and/or modify
4
%# it under the terms of the GNU General Public License as published by
5
%# the Free Software Foundation; either version 2 of the License, or
6
%# (at your option) any later version.
8
%# This program is distributed in the hope that it will be useful,
9
%# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
%# GNU General Public License for more details.
13
%# You should have received a copy of the GNU General Public License
14
%# along with this program; if not, see <http://www.gnu.org/licenses/>.
17
%# @deftypefn {Function} {[@var{string}] =} asci ([@var{columns}])
18
%# If this function is called without any input argument and without any output argument then print a nice ASCI-table (excluding special characters with hexcode 0x00 to 0x20) on screen with four columns per default. If this function is called with one output argument then return an ASCI-table string and don't print anything on screen. Finally, if this function is called with one input argument of type scalar then either print (no output argument) or return (one output argument) an ASCI-table with a number of columns given in @var{columns}.
27
function [varargout] = asci (varargin)
29
%# Check number and types of input arguments
32
elseif (isnumeric (varargin{1}) && \
33
isequal (size (varargin{1}), [1, 1]))
34
vcol = floor (varargin{1});
39
%# First char is #32 (0x20) and last char is #128 (0x80)
41
voff = floor ((128 - 32) / vcol);
43
%# Print a first row for the and underline that row
45
vtab = sprintf ("%s Dec Hex Chr ", vtab);
47
vtab = sprintf ("%s\n", vtab);
50
vtab = sprintf ("%s-------------", vtab);
52
vtab = sprintf ("%s\n", vtab);
54
%# Create the lines and columns of the asci table
55
for vpos = 32:(32+voff)
57
vact = (vcnt-1)*voff+vpos;
58
vstr = {num2str(vact), dec2hex(vact), char(vact)};
59
for vctn = 1:length (vstr)
60
vtab = sprintf ("%s %3s", vtab, vstr{vctn});
62
vtab = sprintf ("%s ", vtab);
64
vtab = sprintf ("%s\n", vtab);
66
vtab = sprintf ("%s\n", vtab);
68
%# Print table to screen or return it to output argument
81
%# Local Variables: ***
b'\\ No newline at end of file'