IMCScript variables
  • 07 Nov 2024
  • 1 Minute to read
  • Dark
    Light

IMCScript variables

  • Dark
    Light

Article summary

Variables in IMCScript store values and functions that your script references or manipulates.

Variables characteristics and requirements

  • Variables are case sensitive.

  • Variables must begin with a-z, A-Z, _ (underscore), or $ (dollar sign), followed by 0-9, a-z, A-Z, _ (underscore), or $ (dollar sign).

    ValidNot valid
    var1, _99, $19v, !a99, 1$

Literal variables

Literal variable types available in IMCScript are:

  • Integer
  • Double
  • String

Examples

var count = 5;                          // Integer value
var percentage = 65.7;                  // Double value
var name = "Zilliant";                  // String value

Non-literal variables

Non-literal variables available in IMCScript are:

  • List—Returns the EBList data type.
  • Map—Returns the EBMap data type.

Examples

var emptyList   = List.create();            //List []
var list        = List.create(3,4,5);       //List [3,4,5]
var map         = Map.create();             // Map {}

Working with List and Map

Initialize, access, and manipulate Array and Map as shown in the following example:

var emptyList   =   List.create();          // --> []
var list        =   List.create(3,4,6,7);   // --> [3,4,6,7]
var map         =   Map.create();           // --> {}

list.deleteAt(2);                           // --> [3,4,7]
list.delete(7)  ;                           // --> [3,4]

list.add(5);                                // --> [3,4,5]

map.add('A','Apple') ;                     // --> {'A':'Apple'}
map.add('B','Banana');                     // --> {'A':'Apple','B':'Banana'}

map.delete('A');                            // --> {'B':'Banana'}

map.add('C','Cherry');                     // --> {'B':'Banana','C':'Cherry'}

var firstItem       =   list[0];            // --> 3
var keys            =   map.keys();         // --> ['B','C']
var fruitOfSummer   =   map['C'];           // --> 'Cherry'

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.