---
title: "Array as parameter"
canonical: "https://docs.cuesystem.com/space/CVCHELP/504365113/Array%20as%20parameter"
format: markdown
---
> Macro (toc)

---

# ArrayAsParameter

Array as a parameter is specified by several dimensions and a type of item. The number of dimensions and the type of items of the parameter and the array must be the same. The sizes of partial dimensions are not specified. The function SizeOfDim is a useful tool when an array as a parameter is used. 

***Syntax***

```visualbasic
[ByVal | ByRef] Name As Array[,, ... ,] As ItemsType
```

The number of dimensions is defined by several commas inside a square bracket less one. 

***Example**** *

```visualbasic
Function GetMaximum(Array3D As Array[,,] As Long) As Long 
  Var i As Long 
  Var j As Long 
  Var k As Long 
  Var Maximum As Long := 0 
  
  For i := 1 To SizeOfDim(Array3D, 1) 
    For j := 1 To SizeOfDim(Array3D, 2) 
      For k := 1 To SizeOfDim(Array3D, 3) 
        If Maximum < Array3D[i, j, k] Then 
          Maximum := Array3D[i, j, k] 
        End If 
      End For 
    End For 
  End For 
  Return Value Maximum 
End Function


Private Process Autoexec() 
  Var Intensity[5, 10, 20] As Long 
  Var MaxIntensity As Long 

  MaxIntensity := GetMaximum(Intensity) 
End Process
```

# SizeOfDim

The function gets a size of an array dimension. The primary objective of using is shown in the chapter array as a parameter.

#### Syntax

```visualbasic
SizeOfDim(ArrayName, DimensionToGetSize) As Long
```

#### Example

```visualbasic
// one dimensional array
Var data[30] As Long
Var Dim1 As Long

Dim1 := SizeOfDim(data, 1) // := 30
```

```visualbasic
// one dimensional array
Var data[30] As Long
Var i As Long

For i := 1 To SizeOfDim(data, 1)
  DebugPrint(data[i])
End For
```

```visualbasic
// two dimensional array
Var data[10, 20] As Long
Var Dim1 As Long
Var Dim2 As Long

Dim1 := SizeOfDim(data, 1) // := 10
Dim2 := SizeOfDim(data, 2) // := 20
```

```visualbasic
// two dimensional array
Var data[10, 20] As Long
Var i As Long
Var j As Long
For i:=1 to SizeOfDim(data, 1) 
  For j:=1 To SizeOfDim(data, 2)
      DebugPrint(data[i][j])
  End For
End For  

```