Re: confused about lists and strings...

Liste des GroupesRevenir à cl tcl 
Sujet : Re: confused about lists and strings...
De : wortkarg3 (at) *nospam* yahoo.com (Harald Oehlmann)
Groupes : comp.lang.tcl
Date : 02. Jul 2025, 10:27:54
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <1042u2q$3eaoi$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
Am 02.07.2025 um 10:39 schrieb Mark Summerfield:
proc process1 args {
     set first [lindex $args 0]
     puts "first='$first' args='$args' list? [string is list -strict $args]"
     set rest [lrange $args 1 end]
     puts "rest='$rest' list? [string is list -strict $rest]"
}
The name "args" is special in TCL returning all remaining arguments as a list.
As you call:
process1 $argv
The one argument is put in a list. The result is a matrix (list in list).
How to solve:
a) don't use "args":
proc process1 myargs {
       set first [lindex $myargs 0]
       puts "first='$first' args='$myargs' list? [string is list -strict $myargs]"
       set rest [lrange $myargs 1 end]
       puts "rest='$rest' list? [string is list -strict $rest]"
}
b) use the delist operator:
process {*}$argv
Hope this helps,
Harald

Date Sujet#  Auteur
2 Jul 25 * confused about lists and strings...8Mark Summerfield
2 Jul 25 `* Re: confused about lists and strings...7Harald Oehlmann
2 Jul 25  `* Re: confused about lists and strings...6Mark Summerfield
2 Jul 25   +* Re: confused about lists and strings...3et99
2 Jul 25   i`* Re: confused about lists and strings...2Rich
2 Jul 25   i `- Re: confused about lists and strings...1et99
2 Jul 25   +- Re: confused about lists and strings...1Rich
2 Jul 25   `- Re: confused about lists and strings...1Christian Gollwitzer

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal