CValueSet:ToTable


The ToTable method returns the CValueSet as a lua table of (string key, value) pairs.

Syntax

table = CValueSet:ToTable()

bullet.gif    table is a lua table of (string,value) pairs.

bullet.gif    On failure, nil is returned.

Example

The following example creates a CValueSet S and then returns it as a lua table:

S = new_valueset("number")

-- constructor, set to values of type "number"

S:Add( "key_1", 158.25 )

-- add a key and value at index 1

S:Add( "key_2", -7.23 )

-- add a key and value at index 2

S:Add( "key_3", 78.6 )

-- add a key and value at index 3

tbl = S:ToTable()

-- return the set as a table of (string, value) pairs

list(tbl)

-- use the global list function to list the table

Below is the lua table created in the previous script as listed in a CTextView window.

{

  [1]=

  {

    [1]=key_1

    [2]=158.25

  }

  [2]=

  {

    [1]=key_2

    [2]=-7.23

  }

  [3]=

  {

    [1]=key_3

    [2]=78.6

  }

}

Related Topics

CValueSet Class, Add, list


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.