Working with Arrays - In-class Exercise

In preparation for these exercises and the out-of-class assignments, make sure you have read an understood the lesson Introduction to Arrays.

Download the stack "array_exercises.livecode" from server at

Card 1 - Using arrays to set text styles in LiveCode text fields

You can use an array-style property, textStyle[style type] of a chunk of text, to check what styles a chunk of text has set on it, and to change the style of a chunk of text. For example, if you want to set the style of a chunk of text to "bold", you would use a statement like this:

set the textStyle["bold"] of char 5 to 10 of field "mytext" to true

On card 1 the "bold" button is already scripted for you as an example.

Do on your own:

• Add some other style buttons to the group to allow you to change selected text to other styles; e.g. link, box, 3Dbox, strikeout.

Card 2 - Array notation for certain LiveCode object properties

Certain LiveCode object properties are stored in an array format. One example of these is graphic effects. They look like this:

the name of the array is the name of the effect; e.g. dropShadow
the keys of the array are the various characteristics; e.g. opacity, color
the values of the array elements are the settings of the characteristics (keys)
Here is an example:

  set the outerglow["color"] of graphic "circle" to [some color value]


Card 3 - Building a simple dictionary using arrays

See link on schedule Arrays Exercise

Items 1 – 11 under the heading Instructions were mostly done in class. The section under Assignment is to be done before next class period.

Try to complete this on your own if possible. But if you get stuck, there is a key for this assignment on the DigHT 310 file server, in the lesson_materials > arrays folder. It is called

Card 4 - Using a two-dimensional array to create a chess game.

See link on schedule Assignment: Using Arrays--Chessboard part 1

As always, try to work through this on your own. The key for these activities, plus part 1 of the chessboard assignment is on the DigHT 310 file server, in the lesson_materials > arrays folder. It is called "array_exercise_keys.livecode"