On Thu, 2011-03-24 at 19:43 +0100, yvan volochine wrote:
> hi
> when reading from a *.plist file in tcl, if the value asked is an array,
> I get a string:
>
> if {![catch {exec defaults read org.puredata $akey} arr]} {
> puts $arr
> }
>
> // this string is printed
> (
> "foo",
> "bar"
> )
>
> is there any elegant way to get this array as a tcl list directly ?
Some Tcl regsub tricks seem to work pretty well, see attachment.
.hc
#!/usr/bin/tclsh
set domain "recentfilestext"
set key "recentfiles"
catch {exec defaults write recentfilestext recentfiles -array patch.pd another.pd "file with spaces.txt" file,with,commas.pd oneword anotherpatch.pd}
if {![catch {exec defaults read $domain $key} arr]} {
puts "arr $arr"
set filelist $arr
regsub -all -- {("?),\s+("?)} $filelist {\1 \2} filelist
regsub -all -- {\n} $filelist {} filelist
regsub -all -- {^\(} $filelist {} filelist
regsub -all -- {\)$} $filelist {} filelist
puts "filelist: $filelist"
foreach file $filelist {
set filename [regsub -- {,$} $file {}]
puts "file: $filename"
}
}
_______________________________________________
Pd-dev mailing list
[email protected]
http://lists.puredata.info/listinfo/pd-dev