# Procedure Parameter \*Group Type - Passed an Array Element of the Group Type

**URL:** <https://clarionhub.com/t/procedure-parameter-group-type-passed-an-array-element-of-the-group-type/7562>\
**Category:** questions\
**Tags:** language\
**Created:** [October 15, 2024, 10:40am UTC](https://clarionhub.com/t/procedure-parameter-group-type-passed-an-array-element-of-the-group-type/7562 "2024-10-15T10:40:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Genricke](https://clarionhub.com/user_avatar/clarionhub.com/genricke/32/5271_2.png) [@Genricke](https://clarionhub.com/u/Genricke)\
**Post date:** [October 15, 2024, 10:40am UTC](https://clarionhub.com/t/procedure-parameter-group-type-passed-an-array-element-of-the-group-type/7562/1 "2024-10-15T10:40:36Z")

</div>

Hi !

Please tell me what could be the error when passing an array element to the procedure ?

```auto
  Map
    MyProc(*TypeMyGroup MyGroup)
  end
  
TypeMyGroup Group,Type
Field1 Byte
  end

MyGroup Group(TypeMyGroup).
MyDim Group(TypeMyGroup),Dim(3).
  
  Code  
  MyProc(MyDim[1]) ! Compile: No matching prototype available :(
  
  MyGroup = MyDim[1] ! OK
  MyProc(MyGroup)

```

Is it possible that the array was declared incorrectly? Thanks ! 🙂

---

<div class="post-metadata">

**Author:** ![Mark\_Sarson](https://clarionhub.com/user_avatar/clarionhub.com/mark_sarson/32/6132_2.png) [@Mark\_Sarson](https://clarionhub.com/u/Mark_Sarson)\
**Post date:** [October 15, 2024, 11:51am UTC](https://clarionhub.com/t/procedure-parameter-group-type-passed-an-array-element-of-the-group-type/7562/2 "2024-10-15T11:51:26Z")

</div>

Hi @Genricke

There maybe other ways folks here come up with. This works how you would expect though. It does mean a slight change of syntax.

```clarion
          PROGRAM
          Map
            MyProc(long pGroup)
          end
  
TypeMyGroup Group,Type
Field1 Byte
              end

MyGroup Group(TypeMyGroup).
MyDim Group(TypeMyGroup),Dim(3).
  
  Code  
  MyDim[1].Field1 = 32
  MyProc(ADDRESS(MyDim[1]))
  
  MyGroup = MyDim[1]  
  MyProc(ADDRESS(MyGroup))
    
MyProc PROCEDURE(long pGroup)
MyProcGroup &TypeMyGroup
  CODE
  MyProcGroup &= (pGroup) !Bracket important here
  MESSAGE('Group field value: ' & MyProcGroup.Field1)

```

Regards

Mark

---

<div class="post-metadata">

**Author:** ![Genricke](https://clarionhub.com/user_avatar/clarionhub.com/genricke/32/5271_2.png) [@Genricke](https://clarionhub.com/u/Genricke)\
**Post date:** [October 15, 2024, 12:32pm UTC](https://clarionhub.com/t/procedure-parameter-group-type-passed-an-array-element-of-the-group-type/7562/3 "2024-10-15T12:32:27Z")

</div>

Thank you. It turns out that MyGroup and MyDim[1] have different data types… ☹

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [October 15, 2024, 5:36pm UTC](https://clarionhub.com/t/procedure-parameter-group-type-passed-an-array-element-of-the-group-type/7562/4 "2024-10-15T17:36:58Z")

</div>

> [@Mark\_Sarson](#):
>
> There maybe other ways folks here come up with. This works how you would expect though. It does mean a slight change of syntax.

Another way is a Reference assignment of a single to the Array i.e. `MyGroupRef &= MyDim[1]`. That way the Procedure can remain typed to take a MYGroupType, and the pass by address works so changes in the procedure change the MyDim[1].

I would say more typical Clarion code would be a Queue of these Groups.

```clarion
  PROGRAM
  Map
    TestPassArrayOfTypedGroup()
    MyProc(*TypeMyGroup MyGroup)
  end
  
TypeMyGroup Group,Type
Field1 Byte
            End
    CODE
    TestPassArrayOfTypedGroup()

TestPassArrayOfTypedGroup PROCEDURE()    
MyGroup Group(TypeMyGroup).
MyDim Group(TypeMyGroup),Dim(3).
MyGroupRef &TypeMyGroup
  Code 
! MyProc(MyDim[1]) ! Compile: No matching prototype available 
  
  MyDim[1].Field1 = 2
  MyGroup = MyDim[1] ! OK
  MyProc(MyGroup)         
  MyDim[1] = MyGroup !Carl--> Must set Array [1] = passed *MyGROUP

  !Carl--> New code to pass Reference &= Array [1]
  MyGroupRef &= MyDim[1] !Reference assign to pass (*MyGroup) changes MyDim[1]  
  MyDim[1].Field1 = 3
  MyProc(MyGroupRef) !Really oass *MyDim[1] 
  Message('After Pass MyGroupRef &= MyDim[1] '& |
         '|? Field1 = 30| MyDim[1].Field1 = '& MyDim[1].Field1 )
!---------------------------------------
MyProc PROCEDURE(*TypeMyGroup MyGroup)  
    CODE
    Message('In MyProc Field1=' & MyGroup.Field1) 
    !Change to see pass * changes caller data
    MyGroup.Field1 *= 10
    RETURN

```

---

<div class="post-metadata">

**Author:** ![Genricke](https://clarionhub.com/user_avatar/clarionhub.com/genricke/32/5271_2.png) [@Genricke](https://clarionhub.com/u/Genricke)\
**Post date:** [October 16, 2024, 8:17am UTC](https://clarionhub.com/t/procedure-parameter-group-type-passed-an-array-element-of-the-group-type/7562/6 "2024-10-16T08:17:33Z")

</div>

Thanks ! If there are no options with the “correct” array declaration, this solves the problem. 😃
