Using GROUP with QUEUE inside CLASS

Hello,

How I can use GROUP with QUEUE inside CLASS? What I mean is:

If I have QUEUE:

Queue:One           QUEUE,TYPE
var_1                   LONG
					END

Queue:Two           QUEUE,TYPE
var_2                   LONG
					END

GROUP is defined:

MyGroup             GROUP,TYPE
first_queue             &Queue:One
some_var_1              LONG
some_var_2              LONG
second_queue            &Queue:Two
					END

And in CLASS I have:

MyClass.SomeProc    PROCEDURE()
ClassGroup          &MyGroup
CODE
	ClassGroup &= NEW(MyGroup)
	
	RETURN

I get compile error

Invalid variable data parameter type

and

Illegal data type: MYGROUP

Why am I getting an error?

Thank you.

Clarion doesn’t let you NEW a GROUP

There are work arounds, but before we get into those
I think you’d be better served if we knew more about what you’re actually trying to accomplish

You can use a CLASS instead of a GROUP. That will allow you to NEW() it.

Another option would be to NEW a STRING the same size as the GROUP, then assign the group reference to that address. You’d need to dispose of the STRING when you’re done with it.

2 Likes

Thank you for your feedback.

So, this can not work. I will figure out something.

And I am trying to get the correct XML structure for XFiles.

Of course it can work,
@jslarve has already described work arounds for
ClassGroup &= NEW MyGroup

The question is, what’s the best design going forward.
Why do you need a group in the first place?
And why do you need to NEW the group?

Using GROUP with whatever inside CLASS:

MyClass  CLASS
grp  LIKE(MyGroup)
  END

Or
MyClass CLASS(MyGroup),TYPE
END

Thank you all for replies and suggestions.

xFiles does not accept CLASS, so I have defined GROUP in procedure where object is used.

This is the first you mentioned xFiles
What does that have to do with the issue ?

I mentioned it in post no. 4.

Again, thank you for feedback.

Something I discovered several years ago, when writing my PrivateClass.

If you pass a REFERENCE of the object to XFiles, maybe that would work. It allows RTL functions (such as WHAT()) to treat a class object similarly to a GROUP.

e.g.

YourClass CLASS
YadaYada
END
YourRef &YourClass

CODE

YourRef &= YourClass
!Now try passing YourRef to xFiles