Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9fb397ae2f3ab0d359101864af26eaa51fa0d08c
Ticket: 2164282fffffffffffffffffffffffffffffffff
Variety of bugs in tutorial code examples
User & Date: tallniel on 2008-10-13 18:51:28
Changes

  1. assignee changed to: "davidw"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Thanks to John W. Hamill for reporting these bugs:
    
    
    I found an error that I though you might like to know about.
    
    on URL 
    http://www.tcl.tk/man/tcl8.5/tutorial/Tcl20.html
    
    At the bottom is this example.
    ---
    set sample "Where there is a will, There is a way."
    
    #
    # Match the first substring with lowercase letters only
    #
    set result [regexp {[a-z]+} $sample match]
    puts "Result: $result match: $match"
    
    #
    # Match the first two words, the first one allows uppercase
    set result [regexp {([A-Za-z]+) +([a-z]+)} $sample match sub1 sub2 ]
    puts "Result: $result Match: $match 1: $sub1 2: $sub2"
    
    #
    # Replace a word
    #
    regsub "way" $sample "lawsuit" sample2
    puts "New: $sample2"
    
    #
    # Use the -all option to count the number of "words"
    #
    puts "Number of words: [regexp -all {[^ ]} $sample]"
    ---
    
    The last line should be:
    
    puts "Number of chars not equal to space: [regexp -all {[^ ]}
    $sample]"
    
    since it counts how many none space characters. (30 instead of 9.)
    If it was suppose to count words then it needs to be fixed.
    
    ----------------
    http://www.tcl.tk/man/tcl8.5/tutorial/Tcl18.html
    
    around the 6th paragraph.
    
    string wordstart string index 
    Returns the index of the character >>>>>>>>just before<<<<<<<<<<< the first
    one in the word which contains the index'th character of string. A word is
    any contiguous set of letters, numbers or underscore characters, or a single
    other character. 
    
    should be:
    
    string wordstart string index 
    Returns the index of the character >>>>>>>>at<<<<<<<<<<<<<<<<<<<< the first
    one in the word which contains the index'th character of string. A word is
    any contiguous set of letters, numbers or underscore characters, or a single
    other character. 
    
    or it could be worded better then what I did.
    ----------------
    http://www.tcl.tk/man/tcl8.5/tutorial/Tcl10.html
    
    Example at the end:
    
    ...
    puts "Start"
    set i 0
    while {$i < 10} {
        puts "I inside first loop: $i"              <<<<<<<<<<<<<<<<<<
        incr i
        puts "I after incr: $i"
    }
    ...
    Should be:
    
    ...
    puts "Start"
    set i 0
    while {$i < 10} {
        puts "I inside third loop: $i"             <<<<<<<<<<<<<<<<<<<
        incr i
        puts "I after incr: $i"
    }
    ...
    
    ----------------
    http://www.tcl.tk/man/tcl8.5/tutorial/Tcl22.html
    
    The example at the bottom
    refers to arrays a(0) ... a(4)
    but they are never create before being referenced.
    
    Maybe some of the code in
    http://www.tcl.tk/man/tcl8.5/tutorial/Tcl6.html
    should be added to Tcl22.html
    to define these arrays.
    Tcl16.html doesn't have a(1)
    Maybe a(0) needs to be a(1).
    
    ----------------
    C:\__jh\ftp\tkTcl\www_tcl_tk\tutorial\29Information about Files - file,
    glob.mht
    
    The example at the end
    
    ...
    set dirs [glob -nocomplain -type d *]
    if { $dirs != {} } {
        puts "Directories:                    <<<<< Missing end quote "
    ...
    set files [glob -nocomplain -type f *]
    if { $files != {} } {
        puts "Files:                          <<<<< Missing end quote "
    ...
    ----------------
    C:\__jh\ftp\tkTcl\www_tcl_tk\tutorial\31State of the interpreter - info.mht
    
    In the Example at the bottom of the page
    
    ...
    proc factorial {val} {
        puts "Current level: [info level] - val: $val"
        set lvl [info level]
        if {$lvl == $val} {
            return $val
        }
        return [expr {($val-$lvl) * [factorial $val]]}]  <<<<<<< Too many "]"
    square brackets
    }
    ...
    #
    # Use [info script] to determine where the other files of interest
    # reside
    #
    set sysdir [file root [info script]]            <<<<<<<<<<<<<<< root didn't
    work. It game me the first part of
                                                                    of my
    "my.tcl" program name "my"
    source [file join $sysdir "utils.tcl"]
    
    should be:
    
    ...
        return [expr {($val-$lvl) * [factorial $val]}]
    ...
    set sysdir [file dirname [info script]]         <<<<<<<<<<<<<< I needed to
    use dirname to make this work
    ...                                                            It gives me
    "." for current directory.
                                                                   Now the join
    statement create ./utils.tcl
                                                                   and I created
    this program and it runs
    
  4. foundin changed to: "obsolete: 8.6a3"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "tallniel"
  10. subsystem changed to: "75. Tutorial"
  11. title changed to: "Variety of bugs in tutorial code examples"
  12. type changed to: "Bug"