For Programmers: Free Programming Magazines  


Home > Archive > Tcl > March 2006 > newbe q.: How to read windows path names from a file ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author newbe q.: How to read windows path names from a file ?
Damian

2006-03-31, 8:02 am

hi group!

I'm trying to [get $channel line] from a file containing lines with
something like "c:\Program files\file.ext". after successful reading
$line variable obviously contains "c:Program filesfile.ext". I'd like
to have "c:/Program files/file.ext" instead (maybe after a string
replacement). How to use "gets" to read a line and to read it without
treating "\" character as a special character or with on-the-fly
conversion to "/" character?

Thnx in adv.,
Damian

Paul Whitfield

2006-03-31, 8:02 am

Damian wrote:
> hi group!
>
> I'm trying to [get $channel line] from a file containing lines with
> something like "c:\Program files\file.ext". after successful reading
> $line variable obviously contains "c:Program filesfile.ext". I'd like
> to have "c:/Program files/file.ext" instead (maybe after a string
> replacement). How to use "gets" to read a line and to read it without
> treating "\" character as a special character or with on-the-fly
> conversion to "/" character?


NO NO NO ... gets does no such thing!

gets $channel line
set converted [ file normalize $line ]

Should convert the file to have "/" characters


Paul
Bryan Oakley

2006-03-31, 8:02 am

Damian wrote:
> hi group!
>
> I'm trying to [get $channel line] from a file containing lines with
> something like "c:\Program files\file.ext". after successful reading
> $line variable obviously contains "c:Program filesfile.ext".


There's nothing obvious about that.

When you read data, no substitutions are performed so your 's will
remain intact. gets will _not_ transform the data it reads (other than
line endings under certain circumstances)


If you are having the problem you say you are having, show us your
actual code, data and results and we'll help you figure it out.

--
Bryan Oakley
http://www.tclscripting.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com