Lee,
I've settled on a 3 step methodology that works like this (which I was
tweaking just the other day):
1) get the column var pointers from the Listbox get arrays command (wrapped
in
Listbox_get_colVarArray
).
2) declare the variable type of those columns.
3) then populate the arrays.
And here's those steps applied to a listbox populated with dynamic column
vars:
// get pointers to the arrays in the listbox
ARRAY POINTER($aPtr;0)
Listbox_get_colVarArray ("itemPriceLB";->$aPtr)
ARRAY TEXT($aPtr{1}->;0)
ARRAY TEXT($aPtr{2}->;0)
ARRAY REAL($aPtr{3}->;0)
ARRAY REAL($aPtr{4}->;0)
ARRAY LONGINT($aPtr{5}->;0)
Case of
: (Records in selection([Catalog_Items_curPrice])=0)
$errMsg:="No item prices found."
Else // load the listbox
SELECTION TO ARRAY([Catalog_Items_curPrice]vendorName;$aPtr{1}->)
SELECTION TO ARRAY([Catalog_Items_curPrice]unit;$aPtr{2}->)
SELECTION TO ARRAY([Catalog_Items_curPrice]price;$aPtr{3}->)
SELECTION TO ARRAY([Catalog_Items_curPrice]cost;$aPtr{4}->)
SELECTION TO ARRAY([Catalog_Items_curPrice]ID;$aPtr{5}->)
End case
You can get along in a lot of cases without declaring the arrays after the
listbox exists - until it mysteriously stops working. To paraphrase the
great developer Jack Sparrow, "those listbox dynamic variable types aren't
really types - they're more like guidelines." Actually declaring them takes
away any ambiguity. Note - I've never tried changing the type from what's
in the listbox to something else. No idea what that would do.
I find using the array of pointers more reliable than using Object get
pointer. No idea if it's an actual quantitative difference or my loosey
goosey programming style but I rarely have problems when I use the pointers
LISTBOX GET ARRAYS returns. Using the same approach you outlined just
didn't always work for me either.
You could throw in a step to check the size of the pointer array to make
sure you have all the variables you think you should.
On Fri, Jan 27, 2017 at 1:20 PM, Lee Hinde <[email protected]> wrote:
> Thanks Paul. In this case all the arrays are of equal length and all have
> data.
>
> The array returned by LISTBOX GET ARRAYS shows the expected results.
>
>
> On Fri, Jan 27, 2017 at 1:13 PM, Paul Ringsmuth <[email protected]>
> wrote:
>
> > I was just reading about list boxes today. If any of the columns have no
> > data, you will get a selection of no records.
> >
> > The number of rows shown will equal the shortest row of data in any
> column.
> >
> > Paul Ringsmuth
> > 515 Aberdeen Dr
> > Waite Park, MN 56387
> > 320-223-2747
> > [email protected]
> >
> >
> > > On Jan 27, 2017, at 3:07 PM, Lee Hinde <[email protected]> wrote:
> > >
> > > I’m trying to populate a listbox.
> > >
> > > After building a bunch of generically named arrays, I pass them all in.
> > >
> > > I’m getting headers, but no data.
> > >
> > > The list box get arrays command at the bottom reflects what I intend to
> > happen, but the data isn’t showing up
> > >
> > > Something simple, I assume, that you all figured out years ago.
> > >
> > > For ($prop_index;1;$property_count)
> > > C_TEXT($col_name)
> > > $col_name:="$array_"+String($prop_index)
> > > $get_pointer:=Get pointer($col_name)
> > >
> > > $col_header_name:="$header_text_"+String($prop_index)
> > > $get_header_ptr:=Get pointer($col_header_name)
> > >
> > > LISTBOX INSERT COLUMN(*;$list_box_name;$prop_
> > index;$col_name;$get_pointer->;$col_header_name;$get_header_ptr->)
> > > OBJECT SET TITLE($get_header_ptr->;$lb_
> > property_names{$prop_index})
> > >
> > > End for
> > >
> > > $count:=LISTBOX Get number of columns(*;$list_box_name)
> > > LISTBOX GET ARRAYS(*;$list_box_name;arrColNames;arrHeaderNames;
> > arrColVars;arrHeaderVars;arrColsVisible;arrStyles)
> > >
> >
> >
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ: http://lists.4d.com/faqnug.html
> Archive: http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
>
--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************