newLISP Fan Club

Forum => Anything else we might add? => Topic started by: cormullion on July 08, 2006, 12:29:10 AM

Title: Strings without quotes
Post by: cormullion on July 08, 2006, 12:29:10 AM
With something like this:


$ 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:


$ date +"%Y-%m-%d %H:%M:%S"
2006-07-08 08:28:14
Title:
Post by: newdep on July 08, 2006, 12:49:19 AM
newlisp -e '(date (date-value) 0 "%Y-%m-%d %H:%M:%S")'



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



Norman.
Title:
Post by: cormullion on July 08, 2006, 07:50:36 AM
Thanks Norman, a perfect solution. I don't know enough about this stuff yet...!
Title:
Post by: Lutz on July 08, 2006, 08:17:49 AM
.. not as short as Norman's solution but perhaps easier to understand:



~> 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