Re: Problems with paths of Windows

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Problems with paths of Windows
De : saitology9 (at) *nospam* gmail.com (saito)
Groupes : comp.lang.tcl
Date : 18. May 2025, 05:42:57
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <100bogh$quv6$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 5/17/2025 10:36 PM, Luis Alejandro Muzzachiodi wrote:
The specific question would be:
given the following procedure
proc myproc { listofpaths } {
     foreach p  $listofpaths {
         puts "$p - is valid? : [file isdirectory $p]"
     }
}
if a parameter is passed as "$::env(SystemRoot)\my dir"
the result obtained is
C:Windowsmy - is valid? : 0
dir - is valid? : 0
Then, is there a way to convert - within the procedure - that input into a valid directory?
 
OK, that clarifies it. So your proc is correct as above.  Here is a test:
% myproc [list [file join $::env(SystemRoot) "Offline Web Pages"]]
C:/WINDOWS/Offline Web Pages - is valid? : 1
What is causing trouble is a combination of a couple of factors: basic Tcl quoting involving spaces and the unfortunate use of backslash by Windows and Tcl for different purposes. In general, I would recommend using [file] commands like the test above to construct file names as opposed to what you are doing with "$::env(SystemRoot)\my dir".
If you insist on doing it your way, you need to escape the spaces as well as the backslash that Windows uses as file separator.  Here is an example:
% myproc [list "$::env(SystemRoot)\Offline\ Web\ Pages"]
C:\WINDOWS\Offline Web Pages - is valid? : 1
Note that each space is escaped with a backslash, and the file separator backslash is escaped as well with an extra backslash. But really it goes back to the basics of quoting.

Date Sujet#  Auteur
17 May 25 * Problems with paths of Windows11Luis Alejandro Muzzachiodi
17 May 25 `* Re: Problems with paths of Windows10saito
18 May 25  `* Re: Problems with paths of Windows9Luis Alejandro Muzzachiodi
18 May 25   +- Re: Problems with paths of Windows1saito
18 May 25   +- Re: Problems with paths of Windows1saito
18 May 25   `* Re: Problems with paths of Windows6Alan Grunwald
18 May 25    `* Re: Problems with paths of Windows5et99
19 May 25     `* Re: Problems with paths of Windows4Luis Alejandro Muzzachiodi
19 May 25      +- Re: Problems with paths of Windows1Ralf Fassel
19 May 25      +- Re: Problems with paths of Windows1Ralf Fassel
19 May 25      `- Re: Problems with paths of Windows1et99

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal