4D v15

List box, Creating columns with dynamic variables

Home

 
4D v15
List box, Creating columns with dynamic variables

List box, Creating columns with dynamic variables  


 

 

Originally introduced in 4D v14 R3

A new feature in 4D allows you to add or insert new columns dynamically at runtime. With this new feature, 4D automatically handles the required variable definitions (column, footer, and header).

Consequently, three 4D commands have been updated:

  • LISTBOX INSERT COLUMN
  • LISTBOX INSERT COLUMN FORMULA
  • LISTBOX DUPLICATE COLUMN

The syntax for these commands has been updated to handle dynamic variable creation.

 

LISTBOX INSERT COLUMN ( {* ;} object ; colPosition ; colName ; colVariable ; headerName ; headerVar {; footerName ; footerVar} )
LISTBOX INSERT COLUMN FORMULA ( {* ;} object ; colPosition ; colName ; formula ; dataType ; headerName ; headerVar {; footerName ; footerVar} )
LISTBOX DUPLICATE COLUMN ( {* ;} object ; colPosition; colName ; colVariable ; headerName ; headerVar {; footerName ; footerVar} )

ParameterType   Description    
...
colVariableArray, Field, Variable, Nil pointer->Column array name or field or variable    
headerVarInteger variable or Nil pointer->Column header variable
...
footerVarVariable or Nil pointer->Column footer variable

 

These commands now accept a Nil pointer (->[]) as a value for the colVariable (when applicable), headerVar and footerVar parameters. In this case, 4D will create the required variables dynamically when the commands are executed (see the "Dynamic variables" section in the 4D Language manual for more information).

Note that header and footer variables are always created with a specific type (respectively, long integer and text). However, the column variable cannot be typed at creation because the listbox accepts different types of arrays for this variable (text array, integer array, etc.) so you must set the type of the array manually. For example:

 C_POINTER($NilPtr)
 LISTBOX INSERT COLUMN(*;"MyListBox";1;"MyNewColumn";$NilPtr;"MyNewHeader";$NilPtr)
 ColPtr:=OBJECT Get pointer(Object named;"MyNewColumn")
 ARRAY TEXT(ColPtr->;0) // Replace 0 by a positive value if you want to preallocate elements in the array

It is important to do this typing before using commands like LISTBOX INSERT ROWS to insert new elements in the array. Alternatively, it is possible to use APPEND TO ARRAY both to type the array and start inserting elements at the same time.

 
PROPERTIES 

Product: 4D
Theme: Language

 
HISTORY 

 
ARTICLE USAGE

4D v15 - Upgrade (standard edition) ( 4D v15)