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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tcl file 1

Status
Not open for further replies.

daisy4u721

Programmer
Aug 24, 2009
34
US
I have a quick tcl question, hope someone can help.

I have 2 files and Im trying to get the information in the second file to the first file. I wrote a code but it doesnt seem to work. This is the code below.
Code:
set infile [open "daisy.doc" r]
set outfile [open "daisy2.doc" w]
 
while {![eof $infile]} {
  set line [gets $infile] 
    puts  $outfile $line
}

When i open the outfile, i find "?? ??" in there.
am i doing anything wrong? any help will be appreciated.
 
Hi

Then why are you trying to process it line by line ?

Use [tt]fconfigure[/tt] and [tt]read[/tt].
Code:
[b]set[/b] infile [teal][[/teal][b]open[/b] [green][i]"daisy.doc"[/i][/green] r[teal]][/teal]
[b]set[/b] outfile [teal][[/teal][b]open[/b] [green][i]"daisy2.doc"[/i][/green] w[teal]][/teal]

[b]fconfigure[/b] [navy]$infile[/navy] [teal]-[/teal]translation [b]binary[/b]
 
[b]while[/b] [teal]{[/teal][teal]![[/teal][b]eof[/b] [navy]$infile[/navy][teal]][/teal][teal]}[/teal] [teal]{[/teal]
  [b]set[/b] line [teal][[/teal][b]read[/b] [teal]-[/teal]nonewline [navy]$infile[/navy][teal]][/teal]
  [b]puts[/b] [teal]-[/teal]nonewline [navy]$outfile[/navy] [navy]$line[/navy]
[teal]}[/teal]

Feherke.
 
Thank you Feherke for the reply. When i try to open the outfile, its giving me an error message that:

"Word experienced an error trying to open the file
 
Feherke,

Are you farmiliar with Tcl TCOM package?

Or is anyone farmiliar with it?

Thanks,
Doyin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top