Re: Referencing values in an array



Daniel,

thanks a lot for your message and help.
I'm still a bit confused as I'm totally new to TCL and I'm not sure if I
understand all your suggestions and how they would make my (actually
more complex) application easier or more elegant.

I do not know either whether they turn your entire application easier
or more
elegant, but at least the code snippet you posted ...

btw: What is the difference between "my" and "self"? Does "my" reference
the instance and self the current object/methode "self" is in?

"my" is perfectly equivalent to [self] (see below for a changed
snippet)

2. You seem to devise the shapes array as devise to store MyShape
instances in
an addressable "store". Well, you double your efforts here, that's
what an object system
should do for you. XOTcl does (in many flavours).

Well, I have many Slides each with a lot of shapes (it's a powerpoint
import application). So I don't want to have ALL instances of MyShape
but only instances of a given slide. This might be doable by defining
another identifier for the slide but creating a container holding the
references to all instances is the typical way I used to program. There
might be better solutions especially in tcl.

Whatever is your design setting! The issue is simply whether you still
want
to devise arrays as reference container for XOTcl objects and pass
arrays
around by means of upvar/uplevel ... it does not really foster a
design based on
locality, as proposed by object orientation.

Including slides and per-slide aggregations of shapes is just a little
step further:

Class Slide -slots {
Attribute shapes -multivalued true
}

Slide proc import {numberOfShapes} {
#
# provide a new slide instance
# "my" is equivalent to [self]:
# reads: "set slide [::Slide new]"
#
set slide [my new]
#
#
# Import shapes
#
for {set i 0} {$i < $numberOfShapes} {incr i} {
# "new" assigns an auto-generated
# identifier to the created object.
set shape [::MyShape new -position $i]
$slide shapes add $shape
}
return $slide
}

Class MyShape -slots {
Attribute position
}

#
# driving range
#

set newlyImportedSlide [Slide import 5]
foreach shape [$newlyImportedSlide shapes] {
puts "*** shape: [$shape position]"
}

It just leverages the luxury of object identites, so
you can use object identities to represent logical identities in your
design (a particular slide, a particular shape, ...).

//stefan



.



Relevant Pages

  • Re: TextFrame and VBA
    ... Thank you Steve. ... >of each hyperlink w/o having to look for the shapes that contain them. ... >Per slide, yes. ...
    (microsoft.public.powerpoint)
  • Re: Animation/ motion path end point/ duplicate objects?
    ... to align the endpoints of the motion paths. ... slide, but it would have been worse trying to fix this later in the process; ... Create dummy shapes that are where you want the real shapes to end up ...
    (microsoft.public.powerpoint)
  • Re: Animation/ motion path end point/ duplicate objects?
    ... Echo- Shyam's tool added the duplicate shapes at the end of the animation- what a great tool! ... I was unable to figure out the rest of his tool and if/how to use it to align the endpoints of the motion paths. ... I added a one-column table to the master slide and added an additional vertical line through the middle of the column; I'm trying to align my motion endpoints so that they are centered on that vertical line and are placed about halfway in each cell. ...
    (microsoft.public.powerpoint)
  • Re: Animation/ motion path end point/ duplicate objects?
    ... Echo- Shyam's tool added the duplicate shapes at the end of the animation- ... if/how to use it to align the endpoints of the motion paths. ... around on the slide, but it would have been worse trying to fix this later ...
    (microsoft.public.powerpoint)
  • Re: using power point to make a ecomap/genogram
    ... Just use the regular shapes to draw what you want -- ovals, ... the slide or click and drag on the slide. ... You can also click the Draw button on the Drawing toolbar to get to the ...
    (microsoft.public.powerpoint)