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, 11:35:38
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <100cd5q$unbu$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 5/17/2025 10:36 PM, Luis Alejandro Muzzachiodi wrote:

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
You know, the problem here is something else completely: your proc is expecting a list of file names. Instead it gets a string containing a single file name.  So what happens is that the foreach loop takes that string, splits it into a list at each space character, and processes each part separately. So "$::env(SystemRoot)\my dir" turns into "$::env(SystemRoot)\my" and "dir" as you see in your output. You don't want this implicit conversion.
Instead, turn your input into a proper list before calling your proc above and all should be good.

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