Setup Factory 10

Table.Insert

Table.Insert

This is the first topic This is the last topic  

Table.Insert

This is the first topic This is the last topic  

OverviewExamples

Table.Insert (

table   SourceTable,

number Position,

variant Value )

Example 1

Debug.ShowWindow(true);

target_table = {"One","Two","Three"};    --Creates a table whose values are 3 strings.

Table.Insert(target_table, 2, "Four");

for x,y in pairs(target_table) do

   Debug.Print("Index "..x.." = "..y.."\r\n");

end

Inserts the string "Four" into index 2 of the table called "target_table." For this example, a loop has been created to output the new contents of the table to the debug window. The output would be the following:

Index 1 = One

Index 2 = Four

Index 3 = Two

Index 4 = Three

Tip: You can copy the action code from these examples and paste it into the Action Editor to test it.

Example 2

Debug.ShowWindow(true);

target_table = {"One","Two","Three"};    --Creates a table whose values are 3 strings.

Table.Insert(target_table, Table.Count(target_table)+1, "Four");

for x,y in pairs(target_table) do

   Debug.Print("Index "..x.." = "..y.."\r\n");

end

Inserts the string "Four" into index 4 of the table called "target_table." In this example the Table.Count action is used to get the number of items in the table so the new item can be inserted at the end. Here is what would be printed in the debug window:

Index 1 = One

Index 2 = Two

Index 3 = Three

Index 4 = Four

See also: Related Actions


Learn More: Indigo Rose Software - Setup Factory - Buy Now - Contact Us