Looping Through Lines of a File in Tcl

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Looping Through Lines of a File in Tcl

  • Creator
    Topic
  • #48833

    In perl you can easily loop through lines of a file like this …

    Code:

    while () {

    or even …

    Code:

    while (<>) {

    Is there a way to do this in Tcl?

    -- Max Drown (Infor)

Viewing 0 reply threads
  • Author
    Replies
    • #59843

      Found this on the web. Seems to work.

      Code:

      set f [open test.txt r]

      while {[gets $f line] != -1} {
         puts $line
      }

      -- Max Drown (Infor)

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