# Reference to queue

**URL:** <https://clarionhub.com/t/reference-to-queue/1268>\
**Category:** questions\
**Tags:** queue\
**Created:** [June 23, 2017, 7:04am UTC](https://clarionhub.com/t/reference-to-queue/1268 "2017-06-23T07:04:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HectroPrima](https://clarionhub.com/user_avatar/clarionhub.com/hectroprima/32/6147_2.png) [@HectroPrima](https://clarionhub.com/u/HectroPrima)\
**Post date:** [June 23, 2017, 7:04am UTC](https://clarionhub.com/t/reference-to-queue/1268/1 "2017-06-23T07:04:17Z")

</div>

How to fix?  
How do you know that the link is spoiled without crashing the program?

```
Q &QUEUE 
  CODE      
  InProcedure
  IF Q &= NULL        
    STOP('NULL')
  END
  MESSAGE(RECORDS(Q)) ! GPF
    
InProcedure PROCEDURE
TestQueue QUEUE
Var1 BYTE
                        END
  CODE      
  Q &= TestQueue

```

---

<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:** [June 23, 2017, 3:10pm UTC](https://clarionhub.com/t/reference-to-queue/1268/2 "2017-06-23T15:10:28Z")

</div>

Hectro,

That is not going to work. The global variable Q holds the address of TestQueue but when InProcedure exits TestQueue goes out of scope and the memory is unallocated.  
So Q still has an address assigned but TestQueue doesn’t exist anymore.  
I don’t know of anyway to detect that.

Rick

---

<div class="post-metadata">

**Author:** ![Mathew](https://clarionhub.com/letter_avatar_proxy/v4/letter/m/5daacb/32.png) [@Mathew](https://clarionhub.com/u/Mathew)\
**Post date:** [June 23, 2017, 3:43pm UTC](https://clarionhub.com/t/reference-to-queue/1268/3 "2017-06-23T15:43:24Z")

</div>

> [@Rick\_UpperPark](#):
>
> I don’t know of anyway to detect that.

Agree with Rick. Instead, why don’t you try this.

!—Global Type  
Q QUEUE(),TYPE  
Var1 BYTE  
END

**OuterProcedure PROCEDURE()**  
LOC:MyQ QUEUE(Q).  
**CODE**  
InProcedure(LOC:MyQ)  
MESSAGE(RECORDS(LOC:MyQ))

**InProcedure PROCEDURE(Q pQ)**  
**CODE**  
pQ.Var1 = Value  
ADD(pQ)

pQ.Var1 = OtherValue  
ADD(pQ)

---

<div class="post-metadata">

**Author:** ![HectroPrima](https://clarionhub.com/user_avatar/clarionhub.com/hectroprima/32/6147_2.png) [@HectroPrima](https://clarionhub.com/u/HectroPrima)\
**Post date:** [June 24, 2017, 12:50am UTC](https://clarionhub.com/t/reference-to-queue/1268/4 "2017-06-24T00:50:45Z")

</div>

I know perfectly well about the scope of variables 🙂  
Speech basically, about that that “the foul” reference by means of Clarion to not check up. And any attempt leads to GPF.  
It would be nice to have a function in Clarion or be able to handle such an exception.

---

<div class="post-metadata">

**Author:** ![HectroPrima](https://clarionhub.com/user_avatar/clarionhub.com/hectroprima/32/6147_2.png) [@HectroPrima](https://clarionhub.com/u/HectroPrima)\
**Post date:** [June 30, 2017, 7:19am UTC](https://clarionhub.com/t/reference-to-queue/1268/5 "2017-06-30T07:19:33Z")

</div>

Does any of the SV developers appear here?

---

<div class="post-metadata">

**Author:** ![brahn](https://clarionhub.com/user_avatar/clarionhub.com/brahn/32/756_2.png) [@brahn](https://clarionhub.com/u/brahn)\
**Post date:** [July 1, 2017, 2:17am UTC](https://clarionhub.com/t/reference-to-queue/1268/6 "2017-07-01T02:17:47Z")

</div>

@bob.ricketts is registered here but I don’t think he is around much. SV are generally only responsive via private contact or the official newsgroups.

On a side note, this was recently posted to the newsgroups:

> NEWD()  
> Versus keeping track of this stuff, sometimes it would be cool if we  
> could easily check to see if a reference’d object or variable was  
> declared or new’d.

> Is there anything that us mortals can do to detect that?

So far responses are kinda just jokes and H5 jibes though.

---

<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:** [July 1, 2017, 5:44pm UTC](https://clarionhub.com/t/reference-to-queue/1268/7 "2017-07-01T17:44:45Z")

</div>

Hi Brahn - I responded on the NG server with this:

Howdy Brahn -

That one’s a little different. He wants to know if the entity referred  
to in the reference actually exists.

```auto
  PROGRAM

  MAP
  END

QueueType Queue,TYPE
Yada1 String(10)
           END

rQ &QueueType
rQ2 &QueueType

  CODE

  rQ &= NEW QueueType
  rQ2 &= rQ
  Dispose(rQ)
  Message(Choose(NOT rQ &= NULL,'I think rQ still exists!',|
           'rQ is NULL'))
  Message(Choose(NOT rQ2 &= NULL,'I think the rQ2 still exists!',|
           'rQ2 is NULL'))

```

He wants to be able to verify rQ2, unless I misunderstood.
