Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #!/usr/bin/env tclsh
  2.  
  3. set fname "my testing file.txt"
  4.  
  5. set access(read) "r"
  6. set access(write) "w"
  7.  
  8. set f_out [open $fname $access(write)]
  9. puts $f_out "Hello world!"
  10. for {set i 0} {$i < 10} {incr i} {
  11. puts $f_out "loto number: [expr {12000 + int(rand() * 1000)}]"
  12. }
  13. close $f_out
  14.  
  15. set f_in [open $fname $access(read)]
  16. # emulates a 'puts [read $f_in]' command
  17. while {![eof $f_in]} {
  18. puts [gets $f_in]
  19. }
  20. close $f_in
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement