insert struct

From DavinciWiki
Revision as of 16:50, 3 March 2006 by Cedwards (Talk | contribs)

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.

WARNING! CURRENTLY BUGGY. UNPREDICTABLE OUTPUT.

Examples

dv> elem2
"element 2"

dv> struct
struct, 2 elements
    a: "element 1"
    c: "element 3"

dv> insert_struct(struct,name="b",value=elem)
insert_struct: Variable not found: elem

dv> insert_struct(struct,name="b",value=elem2)
"element 2"

dv> struct
struct, 3 elements
    a: "element 1"
    c: "element 3"
    b: "element 2"

dv> remove_struct(struct,"b")
"element 2"

dv> struct
struct, 2 elements
    a: "element 1"
    c: "element 3"

dv> insert_struct(struct,name="b",value=elem2,before="c") 
"element 2"

dv> struct
struct, 3 elements
    a: "element 1"
    b:     c: "element 3"

dv> struct.b
"struct.b
"

dv> struct.b

dv> struct.b
struct, 3 elements
    a: "element 1"
    b:     c: "element 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