Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2f2349770d7da8342f9b9539a064ad19963e76b5
Ticket: 218036ffffffffffffffffffffffffffffffffff
MSWindows: array anymore fails as while condition
User & Date: nobody on 2000-10-26 00:52:25
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 1341 Bug
    Version: 8.0.4
    SubmitDate: '1999-03-02'
    LastModified: '1999-08-07'
    Severity: MED
    Status: Closed
    Submitter: pat
    ChangedBy: hobbs
    OS: Windows 98
    Machine: X86
    FixedDate: '2000-10-25'
    ClosedDate: '1999-08-07'
    
    
    Name:
    
    Richard Cochran
    
    
    
    ReproducibleScript:
    
    cmdline: tclsh80 test.tcl
    
    
    
    file test.tcl:
    
    #-----------------------
    
    
    
    set patterns(a) 1
    
    set patterns(b) 2
    
    set patterns(c) 3
    
    set patterns(d) 4
    
    set patterns(e) 5
    
    set patterns(f) 6
    
    
    
    parray patterns
    
    puts ""
    
    
    
    set s [array startsearch patterns]
    
    while 1 {
    
        set code [array anymore patterns $s] 
    
        puts "anymore? $code"
    
        if 0==$code break
    
        set tmp [array nextelement patterns $s]
    
        puts "the next element is: $tmp"
    
        puts "element,patterns(element) = $tmp, $patterns($tmp)"
    
    }
    
    array donesearch patterns $s
    
    puts ""
    
    
    
    set s [array startsearch patterns]
    
    while [array anymore patterns $s] {
    
        set tmp [array nextelement patterns $s]
    
        puts "the next element is: $tmp"
    
        puts "element,patterns(element) = $tmp, $patterns($tmp)"
    
    }
    
    
    
    
    
    
    
    
    
    
    
    ObservedBehavior:
    
    output from running test.tcl on MS Windows98:
    
    
    
    patterns(a) = 1
    
    patterns(b) = 2
    
    patterns(c) = 3
    
    patterns(d) = 4
    
    patterns(e) = 5
    
    patterns(f) = 6
    
    
    
    anymore? 1
    
    the next element is: d
    
    element,patterns(element) = d, 4
    
    anymore? 1
    
    the next element is: e
    
    element,patterns(element) = e, 5
    
    anymore? 1
    
    the next element is: a
    
    element,patterns(element) = a, 1
    
    anymore? 1
    
    the next element is: f
    
    element,patterns(element) = f, 6
    
    anymore? 1
    
    the next element is: b
    
    element,patterns(element) = b, 2
    
    anymore? 1
    
    the next element is: c
    
    element,patterns(element) = c, 3
    
    anymore? 0
    
    
    
    the next element is: d
    
    element,patterns(element) = d, 4
    
    the next element is: e
    
    element,patterns(element) = e, 5
    
    the next element is: a
    
    element,patterns(element) = a, 1
    
    the next element is: f
    
    element,patterns(element) = f, 6
    
    the next element is: b
    
    element,patterns(element) = b, 2
    
    the next element is: c
    
    element,patterns(element) = c, 3
    
    the next element is:
    
    can't read "patterns()": no such element in array
    
        while executing
    
    "puts "element,patterns(element) = $tmp, $patterns($tmp)""
    
        ("while" body line 4)
    
        invoked from within
    
    "while [array anymore patterns $s] {
    
        set tmp [array nextelement patterns $s]
    
        puts "the next element is: $tmp"
    
        puts "element,patterns(elemen..."
    
        (file "test.tcl" line 24)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    DesiredBehavior:
    
    The output running test.tcl on Linux 
    
    (what I expect to see):
    
    
    
    patterns(a) = 1
    
    patterns(b) = 2
    
    patterns(c) = 3
    
    patterns(d) = 4
    
    patterns(e) = 5
    
    patterns(f) = 6
    
    
    
    anymore? 1
    
    the next element is: d
    
    element,patterns(element) = d, 4
    
    anymore? 1
    
    the next element is: e
    
    element,patterns(element) = e, 5
    
    anymore? 1
    
    the next element is: a
    
    element,patterns(element) = a, 1
    
    anymore? 1
    
    the next element is: f
    
    element,patterns(element) = f, 6
    
    anymore? 1
    
    the next element is: b
    
    element,patterns(element) = b, 2
    
    anymore? 1
    
    the next element is: c
    
    element,patterns(element) = c, 3
    
    anymore? 0
    
    
    
    the next element is: d
    
    element,patterns(element) = d, 4
    
    the next element is: e
    
    element,patterns(element) = e, 5
    
    the next element is: a
    
    element,patterns(element) = a, 1
    
    the next element is: f
    
    element,patterns(element) = f, 6
    
    the next element is: b
    
    element,patterns(element) = b, 2
    
    the next element is: c
    
    element,patterns(element) = c, 3
    
    
    
    
    
    
    
    
    
    
    
    
    
    I can't understand why this simple script doesn't produce the
    
    same output on Windows as on Linux. If its not a bug, then it is a
    
    very stange anomoly.
    
    
    
    The windows behavior is correct, and the behavior on Linux is
    
    suspect (check version numbers).  The problem is that in the
    
    while loop, the condition is not {}ed, so it is evaluated only
    
    the first time to 1, and will thus always loop until your error.
    
    If you do:
    
        while {[array anymore patterns $s]} { ...
    
    instead, you will get the expected behavior.
    
     
    
    -- 08/07/1999 hobbs
    
  4. foundin changed to: "obsolete: 8.0.4"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "MSWindows: array anymore fails as while condition"
  11. type changed to: "Bug"