Focal Point
Maintain and List Boxes

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8831059972

April 10, 2008, 02:02 PM
Kelly Badger
Maintain and List Boxes
Hello, everyone. I'm just starting to get my feet wet with Maintain and have numerous questions. So far, this forum has been able to answer many -- thank you all!

I have come across something I'm trying to accomplish that should surely be quite simple, but I've yet to find the solution.

I've got a table with around 400 records that I'm using to populate a series of nested list boxes. For example: In ListBox1 when you click on one of the three "Error Types", it then populates ListBox2 with the "Error ID" from the table that relates to the ListBox1 selection. Then when a result in ListBox2 is selected, I load the corresponding "Error Description" records into ListBox3. This process repeats until the user is able to finally drill down to a unique "Error Root Cause" in ListBox4. (Hopefully that made sense). I'm currently populating my stacks with WF procedures and the "EXEC procedure INTO stack" command.

What I'm looking to do is prior to loading these stacks with the data from the source table, I'd like to first load a record into the stack that reads "---" so it'll appear at the top of List Boxes by default indicating to the user to select their choice. Wihtout this "dummy" entry, by default the first record in the stack is highlighted and may cause some confusion to the user as they didn't select it.

I know I can add the "---" entries to the source database but I'd like to stay away from that as it would require additional table maintenance. I also think I could add the "---" to the .fex that's generating the results but, to me, it makes more sense to put it in the actual Maintain procedure.

Any help/hints would be appreciated.

Thanks,
Kelly


Kelly
WF 7.6.6, Win 2K3 SP2, Tomcat
April 10, 2008, 03:05 PM
Maintain Wizard
Hi Kelly
This is very easy to do. What you want to do is start populating the stack at row 2 instead of row 1. However, there is an issue with the code, so we have to be a little creative. Here is the code:

INFER FIELDS INTO ERRORTYPESTK1 -* Real Stack
INFER FIELDS INTO ERRORTYPESTK2 -* Temp Stack
STACK CLEAR ERRORTYPESTK1 ERRORTYPESTK2 -* clear the stacks
EXEC TABLE INTO ERRORTYPESTK2 -* Get the data
STACK COPY FROM ERRORTYPESTK2 INTO ERRORTYPESTK1(2) -* Copy the data from temp stack into row 2 of real stack
COMPUTE ERRORTYPESTK1(1).FIELD1 = '---'; -* Compute place holder

That's is. Load all the data into a temp stack and then copy it into the real stack starting at row 2. Then you can compute anything you want into row 1 of the real stack. The only thing you can't do it load the data directly from the EXEC into stk(2). That would be the easiest way, but it blows up. Sorry. I hope this helps.

Mark
April 10, 2008, 04:17 PM
Dave Ayers
Kelly,

Here is another way to do it if you don't want to have duplicate stacks:

Add an item to the top of a stack:

-** Increment the stack item count/
Compute stkExample.Foccount = stkExample.Foccount + 1 ;

-** Shift all the existing items down one, to make room for the new item
Repeat (stkExample.Foccount - 1) Cnt = stkExample.Foccount;
Compute stkExample(Cnt).Fieldname = stkExample(Cnt-1).Fieldname
Endrepeat Cnt=Cnt-1;

-** Setup default field value for the new item
Compute stkExample(1).Fieldname = 'Whatever' ;


I have a number of stack manipulation code examples Here for my reference but anyone else can use them too


Regards,
Dave

http://www.daveayers.com

WebFocus/Maintain 7.6.4-8
on Win2000 and 2003 Server
April 10, 2008, 07:49 PM
Alan B
Or, as a 3rd way:

In the exec procedure, e.g. carstack, use rank:
TABLE FILE CAR
RANKED BY COUNTRY
ON TABLE PCHOLD
END

then in the maintain:

.
.
stack1.rank/i7;
stack1.country/a10;
.
.
EXEC carstack into Stack1;
x/i9=stack1.foccount+1
stack1(x).rank=0;
stack1(x).country='----------';
stack sort stack1 by rank;
.
.

then use country in a list box.
(always use the x computed value, not foccount+1 in its place, as reference to foccount increases its value)


Alan.
WF 7.705/8.007
April 14, 2008, 01:34 PM
Kelly Badger
Thank you all for the excellent suggestions. I've got it working perfectly.

Dave, that's great to see your personal site w/Maintain code. I've already bookmarked it.


Kelly
WF 7.6.6, Win 2K3 SP2, Tomcat