octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Jump from 2.1.65 to 2.9.5


From: Bill Denney
Subject: Re: Jump from 2.1.65 to 2.9.5
Date: Sun, 16 Apr 2006 08:03:20 -0400 (EDT)

On Sat, 15 Apr 2006, Daniel J Sebald wrote:

Hmm, alright.  So I'm guessing that this might not be correct then:

octave:11> sprintf('hi\nthere')
ans = hi
there

which currently is the same as with " ", unless the printf() family has been fixed in CVS.

I'm not sure what you mean by them being fixed. One way to think about this is:

* You create an uninterpreted (single quoted) string.
* You pass that string to a function that interprets the string (sprintf).

*printf does more than just interpret the \'s, though. It also does things like variable substitution which is not done in double quoted strings. For example,

name = 'Daniel';
sprintf("Hello, %s\n", name)
ans = Hello Daniel

On the first line, we make name be an un-escaped string Daniel. This would be fully equivalent to using double quotes since there are no backslashes.

On the second line, we put the string "Hello, %s\n" into sprintf for variable interpretation. Sprintf doesn't actually see the \n it only sees the actual character code (0x13 I think) because the backslash conversion was taken care of by the double quotes. Sprintf still has work to do because it has to do the string substitution of name for %s.

So, I shouldn't be writing lines like this:

  __gnuplot_raw__ (sprintf ('set nokey\n'));

but instead like this

  __gnuplot_raw__ ("set nokey\n");

?

Both of those are accurate. The second just involves one fewer function call (I think-- I'm not sure actually about the internals).

gvim's highlighting works better with single quotes than with double quotes, unfortunately.

It sounds like you may be using a matlab mode for gvim instead of an Octave mode. I don't know if an Octave mode exists, though.

Bill

--
"Plugging it into potatoes will result in potatoes with holes"
  -- totl.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]