Strings without quotes

For the Compleat Fan
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Strings without quotes

Post by cormullion »

With something like this:

Code: Select all

$ newlisp -e '(date (date-value) 0 "%Y-%m-%d %H:%M:%S")'
"2006-07-08 08:24:42"
How would you get rid of the quotes at either end of the string, for display purposes?

Cf the shell:

Code: Select all

$ date +"%Y-%m-%d %H:%M:%S"
2006-07-08 08:28:14

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

newlisp -e '(date (date-value) 0 "%Y-%m-%d %H:%M:%S")'

(sym (date (date-value) 0 "%Y-%m-%d %H:%M:%S"))

Norman.
-- (define? (Cornflakes))

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Thanks Norman, a perfect solution. I don't know enough about this stuff yet...!

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

.. not as short as Norman's solution but perhaps easier to understand:

Code: Select all

~> newlisp -e '(silent (println (date (date-value) 0 "%Y-%m-%d %H:%M:%S")))'
2006-07-08 11:15:36
~> 
the silent is suppressing the return value, which carries the quotes. The println than produces the output desired. And of course you could use print to get rid of the line feed too.

Lutz

Locked