# Set Reference to Group Field; Assign a Value

**URL:** <https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617>\
**Category:** uncategorized\
**Created:** [October 19, 2020, 8:59pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617 "2020-10-19T20:59:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [October 19, 2020, 8:59pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/1 "2020-10-19T20:59:37Z")

</div>

Have to believe I’ve done this before, but no memory now. Little hair left to scratch.  
Need something like:  
MyGroup GROUP  
A CSTRING(31)  
B CSTRING(31)  
C CSTRING(31)  
END  
MyRef &CSTRING

CODE  
MyRef &= WHAT(MyGroup,1)  
MyRef = ‘Some string value’

Gives an illegal reference assignment. What am I missing?

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [October 19, 2020, 9:18pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/2 "2020-10-19T21:18:04Z")

</div>

Change  
MyRef &CSTRING  
to  
MyRef ANY

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [October 19, 2020, 10:19pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/3 "2020-10-19T22:19:30Z")

</div>

Thank you. Amazing what a small change can do.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [October 20, 2020, 6:57am UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/4 "2020-10-20T06:57:58Z")

</div>

If you really need it as the original data type, you can get at it with my private class [GitHub - jslarve/PrivateClass: A Class for getting at PRIVATE properties in Clarion Classes](https://github.com/jslarve/PrivateClass)

But otherwise, the ANY is simpler.

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [October 20, 2020, 12:31pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/5 "2020-10-20T12:31:27Z")

</div>

For educational purposes, at the least, I will give it a look. Thanks for pointing it out.

---

<div class="post-metadata">

**Author:** ![seanh](https://clarionhub.com/letter_avatar_proxy/v4/letter/s/4af34b/32.png) [@seanh](https://clarionhub.com/u/seanh)\
**Post date:** [October 20, 2020, 10:48pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/6 "2020-10-20T22:48:55Z")

</div>

A GROUP acts as a STRING not a CSTRING. I Think it would work if you made MyRef a STRING.

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [October 20, 2020, 11:09pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/7 "2020-10-20T23:09:15Z")

</div>

WHAT is returning a reference to the field in the group. Not the group itself.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [October 21, 2020, 2:44am UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/8 "2020-10-21T02:44:25Z")

</div>

Witches are made of wood.

WHAT() doesn’t return a specific data type.

Like with an ANY, you can get a value or a reference of a particular field within the structure. The overall GROUP being similar to a STRING is irrelevant to what WHAT() returns.

e.g.

`MyValue = WHAT(MyGroup,xx) !Just reading the value`  
or  
`MyAny &= WHAT(MyGroup,xx) !Getting an ANY reference`  
` MyAny = 'Yada' !Writing the value`

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [October 21, 2020, 11:06am UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/9 "2020-10-21T11:06:23Z")

</div>

I entered a PTSS for browses not being able to handle arrays in a list. Yesterday, I noticed that this MAY also include group fields. While I haven’t looked further yet, I’m wondering if the details you note might be involved, perhaps in something like the FieldPairsClass not referencing and then assigning the values?

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [October 21, 2020, 3:17pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/10 "2020-10-21T15:17:14Z")

</div>

Have you got an example of your suspicion/wonderment?

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [October 21, 2020, 4:39pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/11 "2020-10-21T16:39:39Z")

</div>

No simple example yet. Yesterday, as a work around for the array issue, I tried using a group instead.

For the particular browse, the group (or array) is passed to a function to receive formatted strings.  
The debugger showed that the group field values were correct just prior to the parent call in BrowseClass.SetQueueRecord. However, the corresponding queue field values were only a single character after the parent call. Because the FieldPairsClass does the assignment, my “wonderment” is placed there.

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [October 26, 2020, 8:57pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/12 "2020-10-26T20:57:46Z")

</div>

Looks like the problem occurs because the templates do not correctly generate queue field declarations when a group field is included. For instance:

MyGroup GROUP,PRE(My)  
A CSTRING(21)  
B CSTRING(21)  
END

Generates in the queue as:  
My:A STRING(1)  
My:B STRING(1)

Leaving out the prefix also creates an error because dot syntax can’t be included within the queue:  
BrowseQueue QUEUE  
MyGroup.A STRING(1)  
MyGroup.B STRING(1)  
END

If you or anyone knows the template fix, I’d be happy to hear it.

---

<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 27, 2020, 6:29pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/13 "2020-10-27T18:29:08Z")

</div>

Can try PRE() then put the Pre: on each variable:

```
MyGroup GROUP,PRE()
My:A CSTRING(21)
My:B CSTRING(21)
   END

```

---

<div class="post-metadata">

**Author:** ![MarkGoldberg](https://clarionhub.com/user_avatar/clarionhub.com/markgoldberg/32/1511_2.png) [@MarkGoldberg](https://clarionhub.com/u/MarkGoldberg)\
**Post date:** [October 27, 2020, 6:32pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/14 "2020-10-27T18:32:09Z")

</div>

What’s wrong with generating in the queue as

```
My:A STRING(1)
My:B STRING(1)

```

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [October 27, 2020, 6:44pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/15 "2020-10-27T18:44:00Z")

</div>

String length gets cut to 1. Makes for a very brief display value.

---

<div class="post-metadata">

**Author:** ![MarkGoldberg](https://clarionhub.com/user_avatar/clarionhub.com/markgoldberg/32/1511_2.png) [@MarkGoldberg](https://clarionhub.com/u/MarkGoldberg)\
**Post date:** [October 27, 2020, 6:46pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/16 "2020-10-27T18:46:56Z")

</div>

ah, that would matter

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [October 27, 2020, 7:38pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/17 "2020-10-27T19:38:46Z")

</div>

Gotta believe a template fix is not too difficult. Doubt SV will ever get around to it.

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [November 2, 2020, 6:59am UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/18 "2020-11-02T06:59:23Z")

</div>

This issue was analysed in the OpenClarion webinar for Wednesday October 28, 2020 - and can be viewed on YouTube here at [https://www.youtube.com/watch?v=O2usIu93A0g](https://www.youtube.com/watch?v=O2usIu93A0g)

I’ve also reported it in the PTSS system (PTSS #43130). In that PTSS I’ve submitted the recommended template change (by downloading the ZIP attached to that PTSS you’ll see the change.) The correct change is somewhat extensive, but a “simple” change you can apply in the meantime is to change the String(1) to String(255).

In ABOOP.TPW search for the lines;

```auto
  #SET(%FComment, %FComment & ' - unable to determine correct data type')
  #SET(%RVal, 'STRING(1)')

```

And replace the 1 with 255. As in

```auto
  #SET(%FComment, %FComment & ' - unable to determine correct data type')
  #SET(%RVal, 'STRING(255)')

```

cheers  
Bruce

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [November 2, 2020, 1:59pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/19 "2020-11-02T13:59:51Z")

</div>

I believe the “somewhat extensive correct template change” involves corrections to the INLIST lines that attempt to find a variable in local, module, or global data. Just wondering if you or anyone else has yet gone down this path?

---

<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:** [November 2, 2020, 5:17pm UTC](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617/20 "2020-11-02T17:17:35Z")

</div>

Bruce is offline. I suggested %LocalDataFull and he came with the below code. I’m not sure how much he has tested it, I have not. Note Global and Module are not coded the same as Local, but I think it would work because %GlobalDataStatement should be blank

```
#FIND(%LocalDataFull, %FLabel)
#IF(%LocalData)
  #SET(%Declr, %LocalDataStatement)
  #SET(%FComment, %FComment & ' - type derived from local data')
#ENDIF
#IF(%Declr='')
  #FIND(%GlobalDataFull, %FLabel)
  #SET(%Declr, %GlobalDataStatement)
  #SET(%FComment, %FComment & ' - type derived from global data')
#ENDIF
#IF(%Declr='')
  #FIND(%ModuleDataFull, %FLabel)
  #SET(%Declr, %ModuleDataStatement)
  #SET(%FComment, %FComment & ' - type derived from module data')
#ENDIF
#IF(%Declr='')
  #FIND(%Field, %FLabel)
  #IF(%Field = %FLabel)
    #IF(SUB(%FieldType, 1, 5) = 'GROUP')
      #SET(%FComment, %FComment & ' - STRING defined to hold GROUP''s contents')
    #ELSIF(%FieldType = 'MEMO')
      #SET(%FComment, %FComment & ' - STRING defined to hold MEMO''s contents')
    #ELSE
      #SET(%FComment, %FComment & ' - type derived from field')
    #END
    #SET(%Declr, %FieldStatement)
  #ENDIF
#ENDIF

```

[Next page](https://clarionhub.com/t/set-reference-to-group-field-assign-a-value/3617.md?page=2)
