INSERT

From HEWIKI
Jump to: navigation, search

Contents

Insert an item in a list

INSERT <item> TO <list> AT <position>

Arguments

<item> 
The list item that is being added
<list> 
The list that is being added to
<position> 
An integer value specifying where the inserted item is to be placed. The new element effectively goes before an old element at that position.

Description

This is a HeroScript command that inserts an item into a list.

IMPORTANT: This command should only be used to insert an item within the bounds of the current list, or one element beyond. If an attempt is made to insert an element beyond that, a script error will result.

For more info, please see the section on List Information.

Example

  myList as list of string
  insert "a string" to myList at 1
 
  test as list of string
  add back "hello" to test               
  add back "world" to test
  insert "goodbye" to test at 3    //    Will work
  insert "farewell" to test at 9   // This would generate a script error,
                                   //    since it is too far past the end
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox