View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] Xotcl autonames

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Thu, 16 Feb 2006 21:26:24 +0100

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
>
>