Reference to queue

Tags: #<Tag:0x00007f0b7e39f180>

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

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

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)

I know perfectly well about the scope of variables :slight_smile:
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.

Does any of the SV developers appear here?

@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.

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.

  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.

1 Like