Copy an object programmatically.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Copy an object programmatically.

Blake-5
How can I create a copy of an object at runtime?

Can I destroy a copy?

Thanks.
_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: Copy an object programmatically.

Randy Heiland
Hi Blake,

Your question gets into the semantics of a 'copy' vs a 'sibling', but...

short answer:
http://squeakland.org/pipermail/squeakland/2005-August/002707.html 
(and there's a 'sketch erase' tile, also in the 'miscellaneous' category of
tiles, although I don't think I've ever used it.
 
longer answer: do a squeakland site-specific google search, appending your
keywords as follows:
site:squeakland.org/pipermail/squeakland sibling

--Randy

> -----Original Message-----
> From: [hidden email] [mailto:squeakland-
> [hidden email]] On Behalf Of Blake
> Sent: Friday, March 03, 2006 4:18 AM
> To: [hidden email]
> Subject: [Squeakland] Copy an object programmatically.
>
> How can I create a copy of an object at runtime?
>
> Can I destroy a copy?
>
> Thanks.
> _______________________________________________
> Squeakland mailing list
> [hidden email]
> http://squeakland.org/mailman/listinfo/squeakland

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: Copy an object programmatically.

Alan Kay
Also consider that you can put objects into a playfield both by hand and by
program and clear the playfield.

I usually put my seed object into a separate little playfield before doing
this.

One way to look at this is that the playfields act as variables for single
objects and sets of objects. (If you put 0 at center of a playfield and
drop in a player, then you have a very nice visible representation of a
vector -- and there is a vector arithmetic trait that you can turn on, etc.)

Cheers,

Alan

  03:56 AM 3/3/2006, Randy Heiland wrote:

>Hi Blake,
>
>Your question gets into the semantics of a 'copy' vs a 'sibling', but...
>
>short answer:
>http://squeakland.org/pipermail/squeakland/2005-August/002707.html
>(and there's a 'sketch erase' tile, also in the 'miscellaneous' category of
>tiles, although I don't think I've ever used it.
>
>longer answer: do a squeakland site-specific google search, appending your
>keywords as follows:
>site:squeakland.org/pipermail/squeakland sibling
>
>--Randy
>
> > -----Original Message-----
> > From: [hidden email] [mailto:squeakland-
> > [hidden email]] On Behalf Of Blake
> > Sent: Friday, March 03, 2006 4:18 AM
> > To: [hidden email]
> > Subject: [Squeakland] Copy an object programmatically.
> >
> > How can I create a copy of an object at runtime?
> >
> > Can I destroy a copy?
> >
> > Thanks.
> > _______________________________________________
> > Squeakland mailing list
> > [hidden email]
> > http://squeakland.org/mailman/listinfo/squeakland
>
>_______________________________________________
>Squeakland mailing list
>[hidden email]
>http://squeakland.org/mailman/listinfo/squeakland


_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: Copy an object programmatically.

Randy Heiland
In reply to this post by Blake-5
The key is that you can create a variable which is of type 'Player' (on the
variable's menu, select 'change value type' and choose 'Player').  E.g., I
created a player variable called 'clone1' for my sketch (actually I called
it 'clone', but apparently it conflicted with some reserved var, so a '1'
was appended).  You can then
1) assign something to that var - e.g. 'sketch's copy', and
2) use that var on the left-hand of an assignment - e.g. replace the
'sketch' in 'sketch's x <- <value>' with 'sketch's clone'

Hopefully the attached image will help clarify.

You might also want to get in the habit of doing things in a playfield
instead of in the world.

Please copy the list if you still have problems.
--Randy

> -----Original Message-----
> From: Blake [mailto:[hidden email]]
> Sent: Monday, March 06, 2006 5:26 AM
> To: Randy Heiland
> Subject: Re: [Squeakland] Copy an object programmatically.
>
> On Fri, 03 Mar 2006 03:56:35 -0800, Randy Heiland <[hidden email]>
> wrote:
>
> > Your question gets into the semantics of a 'copy' vs a 'sibling', but...
>
> Well, I think I understand that.
>
> > short answer:
> > http://squeakland.org/pipermail/squeakland/2005-August/002707.html
>
> Thanks.
>
> I think what threw me is that it's called "ship's copy", which doesn't
> seem like an action.
>
> OK, so I make a copy and put it into the world with
>
> word include:ship's copy
>
> so how do I get a variable of ship's copy that I can set the starting
> location in the world? Or perhaps that's the wrong question. What do I do
> to get the newly created object to perform whatever actions are needed at
> set-up?

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland

var-type-player.jpg (32K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Copy an object programmatically.

Randy Heiland
In reply to this post by Blake-5


> -----Original Message-----
> From: Blake [mailto:[hidden email]]
> Sent: Tuesday, March 07, 2006 2:05 AM
> To: Randy Heiland
> Subject: Re: [Squeakland] Copy an object programmatically.
>
> On Mon, 06 Mar 2006 07:20:10 -0800, Randy Heiland <[hidden email]>
> wrote:
>
> > The key is that you can create a variable which is of type 'Player' (on
> > the variable's menu, select 'change value type' and choose 'Player').
> > E.g., I created a player variable called 'clone1' for my sketch
> > (actually I called it 'clone', but apparently it conflicted with some
> > reserved var, so a '1'
> > was appended).  You can then
> > 1) assign something to that var - e.g. 'sketch's copy', and
> > 2) use that var on the left-hand of an assignment - e.g. replace the
> > 'sketch' in 'sketch's x <- <value>' with 'sketch's clone'
> >
> > Hopefully the attached image will help clarify.
>
> Yes, thank you. So you have to do everything with the base type first and
> then replace with the variable?

That's my understanding.

>
> > You might also want to get in the habit of doing things in a playfield
> > instead of in the world.
>
> Yeah, I noticed the problems with using the world pretty quickly.

Please copy the list!  Archives are a wonderful resource.
--Randy

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: Copy an object programmatically.

Blake-5
In reply to this post by Randy Heiland
On Mon, 06 Mar 2006 07:20:10 -0800, Randy Heiland <[hidden email]>
wrote:

> The key is that you can create a variable which is of type 'Player' (on  
> the variable's menu, select 'change value type' and choose 'Player').  
> E.g., I created a player variable called 'clone1' for my sketch  
> (actually I called it 'clone', but apparently it conflicted with some  
> reserved var, so a '1'
> was appended).  You can then
> 1) assign something to that var - e.g. 'sketch's copy', and
> 2) use that var on the left-hand of an assignment - e.g. replace the
> 'sketch' in 'sketch's x <- <value>' with 'sketch's clone'
>
> Hopefully the attached image will help clarify.

Yes, thank you. So you have to do everything with the base type first and
then replace with the variable?

> You might also want to get in the habit of doing things in a playfield
> instead of in the world.

Yeah, I noticed the problems with using the world pretty quickly.
_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland