[Xotcl] Xotcl autonames
Gustaf Neumann
neumann at wu-wien.ac.at
Thu Feb 16 21:26:24 CET 2006
Michael, use
foreach t $tracks {
set m [::wings::model::TrackModel new]
$m dbRead $t
my lappend tracks $m
}
or shorter:
foreach t $tracks {
my lappend tracks [::wings::model::TrackModel new -dbRead $r]
}
Michael Schlenker schrieb:
>Hi all,
>
>i used the autoname instproc to create object instance names and was
>surprised that autonames can conflict.
>
>Basically i have two objects of the same class, which both get rows from
>a database and create objects for each row:
>
>Something like this:
>
>PM instproc dbRead {program_id} {
> # some things ommited
>my set tracks ""
>set tracks [::MOD select list program_tracks {track_id} program_id
>$program_id]
>foreach t $tracks {
> set m [::wings::model::TrackModel [my autoname TrackM]]
> $m dbRead $t
> my lappend tracks $m
>}
>}
>
>After i create two objects of this class, i see the TrackM autonames
>used by both objects starting from 0, basically the second object
>overwrites my autonamed objects from the first one.
>
>I fixed it by adding:
>
>my instproc autoname {args} {
>set name [next]
>while {[llength [info commands $name]]} {set name [next]}
>return $name
>}
>
>to the class, but wondered if this is expected behaviour of autonames.
>
>Michael
>
>
>
>
>
>
>
>
>
>
>
>_______________________________________________
>Xotcl mailing list
>Xotcl at alice.wu-wien.ac.at
>http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>
>
More information about the Xotcl
mailing list