Articles Archive
Director Forums
Director Wiki
Job Board
Search
 
 Director Online WikiMain Page | About | Help | FAQ | Special pages | Log in | Printable version | Disclaimers
Categories: Dictionary | Lingo

Duplicate

From Director Online Wiki

duplicate
Type: method
Version:  ?
Language: Lingo
Dependencies: none
Links/Related

List command; for linear lists and property lists. Copies the existing list to a new memory address. Subsequent operations on vNewList will not affect vExistingList.

Also elements of vExistingList that are (list-)references are duplicated. (See example below)

Syntax

vList.duplicate()
duplicate(vList)

Examples

vElement = [99,3,3]

vExistingList = [vElement, vElement]
put vExistingList
-- [[99, 3, 3], [99, 3, 3]]

vExistingList[1][1] = 3
put vExistingList
-- [[3, 3, 3], [3, 3, 3]]
-- As expected, both references of vElement changed.

vNewList = duplicate( vExistingList )
put vNewList
-- [[3, 3, 3], [3, 3, 3]]

vNewList[1][1] = 99
put vNewList
-- [[99, 3, 3], [3, 3, 3]]
put vExistingList
-- [[3, 3, 3], [3, 3, 3]]
-- Note that even the two elements of vNewList were duplicated indepently.


See also


Retrieved from "http://www.director-online.com/dougwiki/index.php/Duplicate"

This page has been accessed 1358 times. This page was last modified 10:42, 8 Jun 2005.