diff examples/stringdemo.cc @ 16867:be41c30bcb44

Re-write documentation and all examples of dynamically linked functions. * doc/interpreter/dynamic.txi: deleted. * doc/interpreter/external.txi: Renamed from dynamic.txi. Rewrote or added much information about dynamically linked functions. * doc/interpreter/Makefile.am: Changed dynamic.txi to external.txi in build system. * doc/interpreter/data.txi, doc/interpreter/intro.txi, doc/interpreter/octave.texi, doc/interpreter/sparse.txi: Changed dynamic.txi to external.txi in cross-references. * doc/interpreter/doccheck/aspell-octave.en.pws: Added new words from external.txi to Octave dictionary. * examples/firstmexdemo.c: deleted. * examples/mex_demo.c: Renamed from firstmexdemo.c. Added many more comments to code. * examples/hello.cc: deleted. * examples/oct_demo.cc: Renamed from hello.cc. Added many more comments to code. * examples/Makefile.am: Changed build system to use mex_demo.c and oct_demo.cc. * examples/addtwomatrices.cc, examples/celldemo.cc, examples/embedded.cc, examples/fortdemo.cc, examples/funcdemo.cc, examples/globaldemo.cc, examples/helloworld.cc, examples/mycell.c, examples/myfeval.c, examples/myfunc.c, examples/myhello.c, examples/mypow2.c, examples/myprop.c, examples/myset.c, examples/mysparse.c, examples/mystring.c, examples/mystruct.c, examples/paramdemo.cc, examples/standalone.cc, examples/stringdemo.cc, examples/structdemo.cc, examples/unwinddemo.cc: Use Octave coding conventions for code. Fixed all compilation errors and warnings.
author Rik <rik@octave.org>
date Sat, 29 Jun 2013 18:08:24 -0700
parents 1b48b209a8d6
children
line wrap: on
line diff
--- a/examples/stringdemo.cc
+++ b/examples/stringdemo.cc
@@ -2,8 +2,8 @@
 
 DEFUN_DLD (stringdemo, args, , "String Demo")
 {
+  octave_value_list retval;
   int nargin = args.length ();
-  octave_value_list retval;
 
   if (nargin != 1)
     print_usage ();
@@ -13,20 +13,16 @@
 
       if (! error_state)
         {
-          if (args(0).is_sq_string ())
-            retval(1) = octave_value (ch, true);
-          else
-            retval(1) = octave_value (ch, true, '\'');
+          retval(1) = octave_value (ch, '\'');  // Single Quote String
 
           octave_idx_type nr = ch.rows ();
           for (octave_idx_type i = 0; i < nr / 2; i++)
             {
               std::string tmp = ch.row_as_string (i);
-              ch.insert (ch.row_as_string (nr-i-1).c_str (),
-                         i, 0);
+              ch.insert (ch.row_as_string (nr-i-1).c_str (), i, 0);
               ch.insert (tmp.c_str (), nr-i-1, 0);
             }
-          retval(0) = octave_value (ch, true);
+          retval(0) = octave_value (ch, '"');  // Double Quote String
         }
     }
   return retval;