list_mod

Updates, inserts, or deletes an item (including image (bitmap) for buttons or graphics lists) in a list.

Available in:

Apps (win) Apps (char) Reportwriter RPC Standalone PL
X X X X X

Syntax

void list_mod(list-name,action[,data-col,...])
list          list-name
int           action
expr          data-col

Description

list-name specifies list to modify.

action specifies modification type:
  • 0 --- at current item.
  • < 0 --- before current item.
  • > 0 --- after current item.

data-col (optional) specifies the contents action modified.

If no data-col is specified for 0 action deletes the current item and moves the current item pointer forward, if possible. Otherwise, 0 action updates the current item with the value(s).

If no data-col is specified for either < 0 or > 0 actions, the function inserts a row of NULLs for the current item.

Notes

For inserts, the current item pointer is set to the new item and its status is set to item_insert. For updates, the item status is set to item_update. If the list is generated by a query and if the list is the window list and list_mod() updates the current item, the original value is stored if this has not already been done. lock_row() uses the stored version to compare to the current database value to determine if the row has already been modified. See the lock_row() function for details. list_mod() is not allowed for lists in shared memory or if the list has multiple references (for example, two or more list variables point to the same list). If the list is generated by a query, is a window list, and list_mod() updates the current item, it also stores the original value (creating a ``shadow row''). lock_row() uses the stored version to compare to the current database value to determine if the row has already been modified. See lock_row() for details. list_mod() is not allowed for lists in shared memory or lists with multiple references (for example, two or more list variables point to the same list).

Example

Creates a list with parm.0 columns and inserts a row of NULL columns:

{list LL;                   /* The list  */
char def[160];              /* list_open define string */
int  i;                     /* Loop variable */
for(i=parm.0,def="";i;i--)  /* Through the columns */
  def = def ^^ "10";        /* Display width of column */
LL = list_open(def,0);      /* Create the list */
list_mod(LL,1);             /* Insert one row of NULL columns */
return(list_close(LL));}    /* That's it, folks */