Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lappend problem 1

Status
Not open for further replies.

reggler

Programmer
Nov 13, 2008
63
CA
Hi there,

I would like to read out content from a text file into a list, look for a specific value, change it and write it back into the text file.
The problem is lappend doesn';t seem to what I expect, my code:
Code:
	    set path [file join C:/ "Documents and Settings" "FinalTest" "user.txt"]
        set FileID [finaltest::retrieve $path r+ [clock seconds]]
        # see if Operator list is existing already if so, wipe out name and add new 
        # one - if not, write whole new line "Operator=Name"
        set userlst [list "user.txt"]
        while {[eof $FileID]!=1} {
            gets $FileID newline
            #load file content into list
            GUI::Info_DialogWIN "list length: [llength $userlst]\nappending: '$newline'"
            lappend $userlst $newline
        }
now my list stays always length 1 i assume that's from the set command...Any clues what I'm doing wrongly?
Suggestions and hints are appreciated!

Thank you!
Ron

Ron
Hours of planing can save weeks of coding
 
lappend $userlst $newline

The lappend command takes the name of the list as an argument, not the value. So,
lappend [red]userlst[/red] $newline

_________________
Bob Rashkin
 
Yup I have figured that out a few hours ago but since i can't give stars to myself you'll get this one ;)

Thanks,
Ron

Ron
Hours of planing can save weeks of coding
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top