Typically, 4D View Pro requires that you identify the cell being worked with and where data will be entered (the active cell). You may also need to select some cells and then perform an action, such as formatting or entering values in them. 4D v17 R5 provides a new set of commands to help you manage both the active cell and cell selections.
HDI: New commands to manage cells
To set and get the active cell or selection in your document:
- VP Get active cell
- VP Get selection
- VP SET ACTIVE CELL
- VP SET SELECTION
- VP ADD SELECTION
- VP RESET SELECTION
To view a cell in specific position (e.g., bottom right) of your 4D View Pro area, you can use:
New commands in action
You can get the range corresponding to the active cell with this command line:
$activeCell:=VP Get active cell ("ViewProArea")
The same logic applies to retrieve a current selection:
$currentSelection:=VP Get selection ("ViewProArea")
Setting your active cell is just as easy, simply pass new cell coordinates as parameter:
$activeCell:=VP Cell ("ViewProArea";5;6)
VP SET ACTIVE CELL ($activeCell)
And to set a new selection, pass a range of cells (adjoining or detached) as parameter :
$currentSelection:=VP Combine ranges (VP Cells ("ViewProArea";3;2;1;4);VP Cells ("ViewProArea";5;7;1;4))
VP SET SELECTION ($currentSelection)
Manage the View position of your cell
To view a cell in the center of your 4D View Pro area, you can use the following line of code:
$displayCell:=VP Cell ("ViewProArea1";50;50)
VP SHOW CELL ($displayCell;vk position center;vk position center)
The location of the cell won’t change, but the view of the cell will be repositioned horizontally and vertically so that the cell will be displayed in the center (if possible).