Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env tclsh
- # Open the file, with truncation
- set f [open foo w]
- puts $f "one"
- puts $f "two"
- close $f
- # Open again, with a+ ==> read/write/append
- set f [open foo a+]
- puts $f "three" ;# This goes to the end of the file
- seek $f 4 ;# Seek to the beginning of the word "two"
- puts $f "2.0" ;# Overwrite the word "two"
- close $f
- # Open and verify the contents
- set f [open foo r]
- puts [read $f]
- close $f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement