comparison src/ov-cell.cc @ 4817:6430596f2238

[project @ 2004-03-04 21:13:33 by jwe]
author jwe
date Thu, 04 Mar 2004 21:13:33 +0000
parents 2eb844b27953
children 81f78a2ff8a6
comparison
equal deleted inserted replaced
4816:4908c82cd1a1 4817:6430596f2238
940 } 940 }
941 941
942 return retval; 942 return retval;
943 } 943 }
944 944
945 DEFUN (cellstr, args, ,
946 "-*- texinfo -*-\n\
947 @deftypefn {Built-in Function} {} cellstr (@var{string})\n\
948 Create a new cell array object from the elements of the string\n\
949 array @var{string}.\n\
950 @end deftypefn")
951 {
952 octave_value retval;
953
954 if (args.length () == 1)
955 {
956 string_vector s = args(0).all_strings ();
957
958 if (! error_state)
959 retval = Cell (s);
960 else
961 error ("cellstr: expecting argument to be a string");
962 }
963 else
964 print_usage ("cellstr");
965
966 return retval;
967 }
968
969 DEFUN (iscellstr, args, , 945 DEFUN (iscellstr, args, ,
970 "-*- texinfo -*-\n\ 946 "-*- texinfo -*-\n\
971 @deftypefn {Built-in Function} {} iscellstr (@var{cell})\n\ 947 @deftypefn {Built-in Function} {} iscellstr (@var{cell})\n\
972 Return true if every element of the cell array @var{cell} is a\n\ 948 Return true if every element of the cell array @var{cell} is a\n\
973 character string\n\ 949 character string\n\
995 break; 971 break;
996 } 972 }
997 } 973 }
998 } 974 }
999 else 975 else
1000 error ("iscellstr: expecting argument to be a cell"); 976 retval = false;
1001 } 977 }
1002 else 978 else
1003 retval = false; 979 retval = false;
1004 } 980 }
1005 else 981 else
1006 print_usage ("iscellstr"); 982 print_usage ("iscellstr");
983
984 return retval;
985 }
986
987 // Note that since Fcellstr calls Fiscellstr, we need to have
988 // Fiscellstr defined first (to provide a declaration) and also we
989 // should keep it in the same file (so we don't have to provide a
990 // declaration) and so we don't have to use feval to call it.
991
992 DEFUN (cellstr, args, ,
993 "-*- texinfo -*-\n\
994 @deftypefn {Built-in Function} {} cellstr (@var{string})\n\
995 Create a new cell array object from the elements of the string\n\
996 array @var{string}.\n\
997 @end deftypefn")
998 {
999 octave_value retval;
1000
1001 if (args.length () == 1)
1002 {
1003 octave_value_list tmp = Fiscellstr (args, 1);
1004
1005 if (tmp(0).is_true ())
1006 retval = args(0);
1007 else
1008 {
1009 string_vector s = args(0).all_strings ();
1010
1011 if (! error_state)
1012 retval = Cell (s);
1013 else
1014 error ("cellstr: expecting argument to be a 2-d character array");
1015 }
1016 }
1017 else
1018 print_usage ("cellstr");
1007 1019
1008 return retval; 1020 return retval;
1009 } 1021 }
1010 1022
1011 DEFUN (struct2cell, args, , 1023 DEFUN (struct2cell, args, ,