insert struct

From DavinciWiki
Jump to: navigation, search


64-bit SafeYes

Description

Insert an element into a structure

Arguments and Return Values

Arguments: A structure and the label of the element desired

Return Value: The element extracted from the structure

Usage

Syntax: insert_struct(object = STRUCT, name = STRING, value = VAL [, before = STRING/INT] [, after = STRING/INT])

The insert_struct() function adds an element to a structure at a specified location. The location can be specified as being either before or after another named element, or an index position.

The name and value fields are optional. Values inserted with no name simply have no name (they can only be accessed by position), and names inserted with no value are given a value of zero.

Examples

dv> a = { alpha=1, beta=2, delta=3 }
struct, 3 elements
   alpha: 1
   beta: 2
   delta: 3

dv> insert_struct(a, name="delta", value=4, before="beta")
4

dv> a
struct, 4 elements
   alpha: 1
   delta: 4
   beta: 2
   gamma: 3

dv> insert_struct(a, name="epsilon", value=5, after="delta")
5

dv> a
struct, 5 elements
   alpha: 1
   delta: 4
   epsilon: 5
   beta: 2
   gamma: 3

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Related Functions

Recent Core Changes

Modified On: 07-06-2009

Personal tools