# Filtering a manually created queue

**URL:** <https://clarionhub.com/t/filtering-a-manually-created-queue/5351>\
**Category:** questions\
**Tags:** vlb\
**Created:** [August 15, 2022, 6:58pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351 "2022-08-15T18:58:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbdullahAkilah](https://clarionhub.com/user_avatar/clarionhub.com/abdullahakilah/32/4818_2.png) [@AbdullahAkilah](https://clarionhub.com/u/AbdullahAkilah)\
**Post date:** [August 15, 2022, 6:58pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/1 "2022-08-15T18:58:49Z")

</div>

So I have 1 queue with approx 25K records in it that’s built from a number of different sources. Now I need to filter the queue, to hide/show entire rows at runtime.  
Since this is all hand code and not based on any file definition/dictionary/view the only way I can think of to do that is using a VLBproc, but if I do that I’m not sure how I make the list not show the record at all?  
Or am I heading down the wrong path here?

---

<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:** [August 15, 2022, 7:01pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/2 "2022-08-15T19:01:52Z")

</div>

Your life will be a lot simpler if you just maintain a 2nd queue and display that. Whatever passes the filter goes into q #2.

Or just create a queue of pointers. Then use that for the get() in the vlb

---

<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:** [August 15, 2022, 7:49pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/3 "2022-08-15T19:49:13Z")

</div>

I agree with Jeff. Without using VLB, the list will always show all rows in the underlying queue.  
If performance allows it, I’d use two queues. One with everything and one on the list control that has the filtered rows.  
If performance won’t allow that, then I think the only route is to use VLB.

---

<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:** [August 15, 2022, 8:01pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/4 "2022-08-15T20:01:06Z")

</div>

Might building a Memory table instead of a queue be possible? Using a browse queue or any queue to hold filtered records would then be easy.

---

<div class="post-metadata">

**Author:** ![AbdullahAkilah](https://clarionhub.com/user_avatar/clarionhub.com/abdullahakilah/32/4818_2.png) [@AbdullahAkilah](https://clarionhub.com/u/AbdullahAkilah)\
**Post date:** [August 15, 2022, 8:17pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/5 "2022-08-15T20:17:46Z")

</div>

Well 2 queue’s is quicker for me to code, so that’s what I’m going with. Thanks!

---

<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:** [August 15, 2022, 10:41pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/6 "2022-08-15T22:41:57Z")

</div>

I agree the 2 Queues is the way to go.

IIRC there was a Clarion Mag article on filtering Queues by using a Tree control in the LIST to hide records. The records to be filtered out where assigned to Level 2. The records to show were Level -1, the negative folding the branch closed so level 2 did not show. The expand boxes have to be hidden and code to prevent expanding. There was not really a tree, its just use to hide records.

Clarion Mag is hard to search so I did not put much effort into finding it

---

<div class="post-metadata">

**Author:** ![vitesse](https://clarionhub.com/user_avatar/clarionhub.com/vitesse/32/837_2.png) [@vitesse](https://clarionhub.com/u/vitesse)\
**Post date:** [August 15, 2022, 11:06pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/7 "2022-08-15T23:06:25Z")

</div>

> [@CarlBarnes](#):
>
> Clarion Mag is hard to search so I did not put much effort into finding it

Hi Carl

possibly this:

Filtering Hand Coded Lists Using The TREE Attribute  
By S Jayashankar  
Posted April 25 2011

cheers

Geoff R

---

<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:** [August 15, 2022, 11:34pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/8 "2022-08-15T23:34:46Z")

</div>

So a 2nd queue is simple enough, but the VLB isn’t that hard. Just add “Ordinal Long” to the queue. Then in the VLB, instead of get(Q, row), you’d do a q.ordinal = row; get(q, q.ordinal)

Either way you still loop over the Q, evaluate the filter and either copy to the displayQ or set/clear the ordinal

---

<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:** [August 16, 2022, 12:56am UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/9 "2022-08-16T00:56:46Z")

</div>

Meanwhile, she’s already done, kicking it on the beach. 🙂

---

<div class="post-metadata">

**Author:** ![Julian](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@Julian](https://clarionhub.com/u/Julian)\
**Post date:** [August 16, 2022, 8:14am UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/10 "2022-08-16T08:14:22Z")

</div>

Here is the afore mentioned tree level technique you can use to selectively display entries from a single queue, just ensure that one-based tree is disabled.

The following example shows that when a queue entry has dwLevel = -1, any entry that follows it that has an ABS(dwLevel) greater than 1 (ie: where -1 normally indicates the collapsed branch) will not show. In the example, “Line 3” and “Line 4” do not appear.

So conditionally hiding queue entries can be achieved by careful control of the dwLevel field.

```
ListTest PROCEDURE

myQ Queue 
MainText String(64)
dwLevel LONG
              .

Window WINDOW('Caption'),AT(,,230,201),GRAY,FONT('Microsoft Sans Serif',8)
                 BUTTON('Close'),AT(166,178,42,14),USE(?CancelButton),STD(STD:Close)
                 LIST,AT(25,26,182,148),USE(?LIST1),FONT('Segoe UI',10),FROM(myQ),FORMAT('20L(2)|MT(BI)~Main Te' & |
                    'xt~@s64@')
              END

   CODE
  myQ.MainText = 'Line 1'
  myQ.dwLevel = 0
  Add(myQ)
  
  myQ.MainText = 'Line 2'
  myQ.dwLevel = -1
  Add(myQ)
  
  myQ.MainText = 'Line 3'
  myQ.dwLevel = -2
  Add(myQ)

  myQ.MainText = 'Line 4'
  myQ.dwLevel = 2
  Add(myQ)
           
  myQ.MainText = 'Line 5'
  myQ.dwLevel = 1
  Add(myQ)
  
  !SORT(myQ,myQ.dwLevel)
  
  Open(Window)
  ACCEPT
  .
  Close(Window)

```

Julian

---

<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:** [August 16, 2022, 6:51pm UTC](https://clarionhub.com/t/filtering-a-manually-created-queue/5351/11 "2022-08-16T18:51:13Z")

</div>

I think I did try this once but IIRC gave up. It complicates sorting as you must keep the Levels “correct”. One simple thing the Level 2 rows need to be -2 so they appear after -1 when Sort(Q,Level)

I also think the Proportional Thumb (PROP:PropVScroll) does not work well with Tree Lists.

I attached the article, thanks Geoff!

[cmag-2011-04.pdf](https://clarionhub.com/uploads/short-url/8qLjfoKFfcUU0Q4aykwUfLjsGIq.pdf) (2.1 MB)

I think this page lists all the CMag articles:

> **[View Source](https://clarionmag.jira.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=404637)**
