Book Image

LiveCode Mobile Development Cookbook

By : Dr. Edward Lavieri
Book Image

LiveCode Mobile Development Cookbook

By: Dr. Edward Lavieri

Overview of this book

Table of Contents (17 chapters)
LiveCode Mobile Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using multidimensional arrays


One-dimensional arrays are simple lists of information. Multidimensional arrays can hold related data in columns and rows such as with a spreadsheet. This recipe will show you how to create, populate, and retrieve information from a multidimensional array.

How to do it...

Perform the following steps to create and use multidimensional arrays:

  1. Create a new main stack in LiveCode.

  2. On the stack or card, create the following code to create a two-dimensional array and populate it with three rows of information:

    command makemyarray
      local aMyArray
      put "J" into aMyArray[1][1]
      put "Jones" into aMyArray[1][2]
      put "United States" into aMyArray[1][3]
      --
      put "R" into aMyArray[2][1]
      put "Smith" into aMyArray[2][2]
      put "United Kingdom" into aMyArray[2][3]
      --
      put "T" into aMyArray[3][1]
      put "Johnson" into aMyArray[3][2]
      put "Canada" into aMyArray[3][3]
      
    end makemyarray
  3. Use the following line of code to retrieve a specific piece of information. In this case...