Matrix Functions

Top  Previous  Next

Summary

MatrixSet("MatrixName[Column,Row], "Image Index")

sets an image (represented with image index) into a cell that addressed with Column & Row.

MatrixGet("MatrixName[Column,Row], "VariableName")

reads image index from a cell that addressed with Column & Row. The image index is then stored in VariableName as an integer value.

MXCOL   ===> Returns current column

MXROW   ===> Returns current row

Now, we can set any of images in a addressed cell.

MatrixSet("MatrixName[Column,Row],"Image Index")

Description

 

MatrixSet("MatrixName[Column,Row], "Image Index")

sets an image (represented with image index) into a cell that addressed with Column & Row.

Code Examples

 

MatrixSet("MyMatrix[2,1]","2")

MatrixSet("MyMatrix[4,3]","1")

MatrixSet("MyMatrix[2,4]","3")

MatrixSet("MyMatrix[4,4]","0")

Above mentioned scripts will set the images into the specified cells :

matrix_exp

How can we fill the whole matrix with a specified image?

RedBall=1

**Fill antire matrix with redball

MatrixSet("MyMatrix[0,0]", "RedBall")

 

Or how can we fill the specified row with a specified image?

GreenBall=2

**Fill second row with greenball

MatrixSet("MyMatrix[0,2]", "RedBall")

And we also fill the specified column with a specified image?

BlueBall=3

**Fill fourth row with second row with blueballl

MatrixSet("MyMatrix[4,0]", "RedBall")

How can we clear whole matrix or a specific part of matrix?

NoImg=0

MatrixSet("MyMatrix[0,0]", "NoImg") **Fill whole cells with null image (no image)

MatrixSet("MyMatrix[0,2]", "NoImg") **Fill second row with null image (no image)

MatrixSet("MyMatrix[4,0]", "NoImg") **Fill fourth row with null image (no image)

MatrixSet("MyMatrix[3,2]", "NoImg") **clear cell(3,2)

What about reading from matrix?

MatrixGet("MatrixName[Column,Row],"VariableName")

Description

 

MatrixGet("MatrixName[Column,Row], "VariableName")

reads image index from a cell that addressed with Column & Row. The image index is then stored in VariableName as an integer value.

 

Code Examples

 

matrix_exp

MatrixGet("MyMatrix[2,1]", "CurImg") ** CurImg = 2

MatrixGet("MyMatrix[4,3]", "NoImg") ** CurImg = 1

MatrixGet("MyMatrix[2,4]", "NoImg") ** CurImg = 3

MatrixGet("MyMatrix[4,4]", "NoImg") ** CurImg = 0

Note: if you use MatrixGet and the col or row is out of range it returns -1.

MatrixGet("MyMatrix[7,5]", "NoImg") ** CurImg = -1 because our Matrix dimensions are 4x4

How can we know which cells is active (in other words selected by user)? There are two variables that always represent current Column & current Row.

MXCOL/MXROW

Description

 

MXCOL   ===> Returns current selected column

MXROW ===> Returns current selected row

MXCOL & MXROW returns 0 if no cell is selected.

 

Code Examples

 

**Get the image index of the current cell

MatrixGet("MyMatrix[MXCOL,MXROW]","MyVariable")

**Set the green ball to the current cell

GreenBall = 2

MatrixSet("MyMatrix[MXCOL,MXROW]","GreenBall")

**Check the user whether selected a cell or not

If (MXCOL=0 & MXROW=0) Then

  Message("You should select a ball","")

End