Answered Questions On: File & Socket I/O


NAVIGATION


TABLE OF CONTENTS (File & Socket I/O):

  • What's The Correct Syntax for the Fconfigure command?
  • How Do I Generate Filenames That Include The Current Date/Time?
  • How Do You Create/Make A Directory In Tcl?

SEE ALSO:

  • ...

What's The Correct Syntax for the Fconfigure command?

I am trying to read a file and open it using the browsers mime type. I use the following piece of code to open the file.

    set fIn [ open $sFileName r ]
    fconfigure $fIn TestName.xxx -translation { binary binary }
    puts [ read $fIn $iContentLength ]
    close $fIn

things are working fine. The only annoying thing is that each time i try to open a file by clicking a hyperlink, it shows me a annoying save as window which i want to get rid of ..

Would appreciate any help here.

Thank you, Ashish

Peter Newman 2 April 2004: The "Testname.xxx" on your "fconfigure" line looks like an error to me. Get rid of it. But whether that's the cause of your problem I don't know. I don't really understand what you're trying to do. You'll need to give more details.


How Do I Generate Filenames That Include The Current Date/Time?

02/09/2004

Hello, can somebody tell me how I should generate a filename automatically. I want to use the date of that excact moment and the first three letters of a predefined string.

I hope somebody can help e with this.

GrtZ,

Theo

NEM Try:

 set filename [string range $predefined 0 2][clock seconds]

where $predefined is the string you mention. If you want the date in a more readable format, then look at [clock format].


How Do You Create/Make A Directory In Tcl?

19-Sep-2003

Question: Is there command or procedure which makes directory?

Since I cannot find it, I have forked 'mkdir' but it's too weight. Like readdir in tclx, is there cammand which makes directory without no fork?

Regards from Nams.

ulis: The command you need is file mkdir. From the file page of the Tcl Manual:

file mkdir dir ?dir ...?

Creates each directory specified. For each pathname dir specified, this command will create all non-existing parent directories as well as dir itself. If an existing directory is specified, then no action is taken and no error is returned. Trying to overwrite an existing file with a directory will result in an error. Arguments are processed in the order specified, halting at the first error, if any.