Page 1 of 1

[08 May 2007] Copy table element

Posted: Sat Jun 13, 2020 5:31 pm
by lazi
Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 08 May 2007 14:24:45 +0100

Hi!

I would like to copy an element of a table array to another element like this:

Code: Select all

dim but[10]

but[1] = { off=1,
        on= 2,
        x=  100,
        y=  100,
        w=  59,
        h=  46,
        nr= 1
      }

but[2]=but[1]    
but[2] will be just a reference to but[1] however I need a copy of but[1].

Is there a way to copy the contents of the table to another variable?

[11 May 2007] Re: Copy table element

Posted: Sat Jun 13, 2020 5:31 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 11 May 2007 11:44:51 +0200
Hi!

I would like to copy an element of a table array to another element like this:

Code: Select all

dim but[10]

but[1] = { off=1,
       on= 2,
       x=  100,
       y=  100,
       w=  59,
       h=  46,
       nr= 1
     }

but[2]=but[1]    
but[2] will be just a reference to but[1] however I need a copy of but[1].

Is there a way to copy the contents of the table to another variable?
Hmm... good question. I would go for a manual copy, i.e.

Code: Select all

but[2].off = but[1].off
but[2].on = but[1].on
but[2].x = but[1].x
etc.

There's probably no other way to do a full copy.