Command PV CELLS TO ARRAY

4D View

PV CELLS TO ARRAY

version 6.8


PV CELLS TO ARRAY (area; direction; column; row; array; number)

ParameterTypeDescription
areaLongint4D View area
directionInteger0 = Row; 1 = Column
columnLongintStart column number
rowLongintStart row number
arrayArrayArray name
numberLongintNumber of cells to be used

Description

The PV CELLS TO ARRAY command fills the array with the cell content specified by direction, column, row and number.

direction specifies whether the PV CELLS TO ARRAY command must execute a copy of continuous cells in the horizontal (0) or vertical (1) direction, starting with the cell set by column and row.

Note: Using the direction parameter is different from the direction parameter in the PV GOTO NEXT CELL and PV GET NEXT FREE CELL commands, where the direction can be in any direction. For PV CELLS TO ARRAY, the direction is either to the right (0 = row), or toward the bottom (1=column).

Example

Take, for example, a 4D View area included in the input screen of the client table: this included area, containing 10 rows maximum, will serve to enter or modify client contacts. The entry area is composed of 10 cells disposed in columns starting from the current cell:

   ARRAY STRING(255;ContactsTab;0)  `Contact name array
   C_LONGINT($Column;$Row)  `Coordinates of starting cell

   PV GET CURRENT CELL (Area;$Column;$Row)

      `10 rows maximum from the current cell toward the bottom
   PV CELLS TO ARRAY (Area;1;$Column;$Row;ContactsTab;10)

   If (Size of array(ContactsTab)#0)  `Was anything recovered?      
      RELATE MANY([Clients]Code)  `Get linked records
      DELETE SELECTION([Contacts])  `Purge existing ones
         `Update contacts (new, modified or deleted)
      ARRAY TO SELECTION(ContactsTab;[Contacts]ContactName)  `Create contacts
      APPLY TO SELECTION([Contacts];[Contacts]CodeClient:=[Clients]Code)  `To keep the relation
      QUERY SELECTION([Contacts];[Contacts]ContactName="")  `Purge empty contacts
      DELETE SELECTION([Contacts]) 
   End if 

See Also

PV ARRAY TO CELLS, PV FIELD TO CELLS.