PUTS vs ECHO

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf PUTS vs ECHO

  • Creator
    Topic
  • #54549
    Brian Heather
    Participant

      I’ve been trying to explain that puts is in legacy and echo is the way to go I know Charlie is in Thailand but can anyone else set her straight on this?

    Viewing 1 reply thread
    • Author
      Replies
      • #81937

        The tcl puts command is part of the base Tcl installation.

        puts ?-nonewline? ?channelId? string

        Because puts allows for 3 arguments, the output string must be wrapped in double quotes or curly braces (grouped) when the output contains any white space.

        Ex. puts “Hello, World!”

        Reference page for puts: http://www.tcl.tk/man/tcl8.5/TclCmd/puts.htm

        The echo command is part of the TclX package.

        echo ?str …?

        Since echo only allows only one argument, the output string does not need to be wrapped in grouping characters such as double quotes or curly braces. Because of this, echo is often the preferred command for producing stdout (the screen or process log) output.

        Ex. echo Hello, World!

        Reference page for echo: http://www.tcl.tk/man/tclx8.2/TclX.n.html

        -- Max Drown (Infor)

      • #81938
        Charlie Bursell
        Participant

          Good answer, but to expand a bit

          If indeed the echo command expected a single argument and that argument contained a space it would have to be quoted for the proc to see it as a single argument.  However the echo proc is like:

                     proc echo args

          The special proc variable “args” if passed as the last or only argument to a proc will result in everything to the end of the command (end of Line or 😉 being passed to th

      Viewing 1 reply thread
      • The forum ‘Cloverleaf’ is closed to new topics and replies.