807
|
1 // strfns.cc -*- C++ -*- |
|
2 /* |
|
3 |
1884
|
4 Copyright (C) 1996 John W. Eaton |
807
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
807
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
807
|
26 #endif |
|
27 |
1355
|
28 #include <cctype> |
807
|
29 |
|
30 #include "dMatrix.h" |
|
31 |
1355
|
32 #include "defun.h" |
807
|
33 #include "error.h" |
|
34 #include "gripes.h" |
1355
|
35 #include "help.h" |
1742
|
36 #include "pt-const.h" |
1355
|
37 #include "oct-obj.h" |
807
|
38 #include "utils.h" |
|
39 |
1488
|
40 DEFUN ("isstr", Fisstr, Sisstr, 10, |
807
|
41 "isstr (X): return 1 if X is a string, 0 otherwise") |
|
42 { |
|
43 Octave_object retval; |
|
44 |
|
45 int nargin = args.length (); |
|
46 |
|
47 if (nargin == 1 && args(0).is_defined ()) |
|
48 retval = (double) args(0).is_string (); |
|
49 else |
|
50 print_usage ("isstr"); |
|
51 |
|
52 return retval; |
|
53 } |
|
54 |
1488
|
55 DEFUN ("setstr", Fsetstr, Ssetstr, 10, |
807
|
56 "setstr (V): convert a vector to a string") |
|
57 { |
|
58 Octave_object retval; |
|
59 |
|
60 int nargin = args.length (); |
|
61 |
|
62 if (nargin == 1 && args(0).is_defined ()) |
|
63 retval = args(0).convert_to_str (); |
|
64 else |
|
65 print_usage ("setstr"); |
|
66 |
|
67 return retval; |
|
68 } |
|
69 |
1488
|
70 DEFUN ("toascii", Ftoascii, Stoascii, 10, |
807
|
71 "toascii (STRING): return ASCII representation of STRING in a matrix") |
|
72 { |
|
73 Octave_object retval; |
|
74 |
|
75 int nargin = args.length (); |
|
76 |
|
77 if (nargin == 1) |
|
78 { |
808
|
79 tree_constant arg = args(0); |
807
|
80 |
|
81 if (arg.is_string ()) |
|
82 { |
1572
|
83 charMatrix chm = args(0).all_strings (); |
807
|
84 |
1572
|
85 retval = Matrix (chm); |
807
|
86 } |
|
87 else |
|
88 gripe_wrong_type_arg ("toascii", arg); |
|
89 } |
|
90 else |
|
91 print_usage ("toascii"); |
|
92 |
|
93 return retval; |
|
94 } |
|
95 |
|
96 /* |
|
97 ;;; Local Variables: *** |
|
98 ;;; mode: C++ *** |
|
99 ;;; page-delimiter: "^/\\*" *** |
|
100 ;;; End: *** |
|
101 */ |