# Import-/Export-Facility

## ZAG Buffer Functions

### Management of object buffers

DataView offered a buffer for each object (widget, mask, field...) in which object-specific information can be stored by the respective application.

To use this buffer with different applications (userexits) at the same time the following functions are available in order to store several information parallel in a buffer with self-defined keys:

- zag_set_buf_elm
  (cp_buffer,cp_key,cp_text)
  Inserts an element (text) under the key specified into the buffer string.
- zag_get_buf_elm
  (cp_buffer,cp_key,cp_text)
  Reads out the element for the key specified from the buffer string transferred.
  Example:
  Insert text into widget buffer.

      cp_buffer = wdg_ret_buf(wdg);
      cp_new_buf = zag_set_buf_elm (cp_buffer,"BSP_ELM1","This
      E1");
      wdg_set_buf (wdg,cp_new_buf);

  Example:
  Determine text for key from widget buffer:

      cp_buffer = wdg_ret_buf (wdg);
      if (zag_get_buf_elm(cp_buffer,"BSP_ELM1", ca_result) == 0)
      printf ("Contents element 1 = %s\n",ca_result);

### Setting an element

- char *zag_set_buf_elm
  (char *cp_buf, char *cp_key, char *cp_text)
  Input:

  cp_buf |
  | Old buffer string [or NULL]
  cp_key |  | User defined key

  Output:

  cp_text |
  | Text (value) to be set for this key

  Return-Code:
  Pointer to new buffer string (internal static memory!)
  Description:
  Adds the given key and its text (value) to the (old) buffer string and returns a pointer to the new buffer string.
  Remarks:
  The returned pointer may not be modified or freed! If necessary this pointer must be copied, since its value will only be kept until one of the function 'zag_cnv_arg', 'zag_set_buf_elm', 'zag_del_buf_elm'... is called.

### Reading an element

- int zag_get_buf_elm
  (char *cp_buf, char *cp_key, char *cp_text)
  Input:

  cp_buf |
  | Old buffer string [or NULL]
  cp_key |  | User defined key

  Output:

  cp_text |
  | Text (value) for this key

  Return-Code:

  0 |
       =
  | Key could not been found in buffer string.
  1 |
       =
  | Key does not exist in buffer string or buffer string is NULL (empty).

  Description:
  This function gets the text (value) for the given key from the buffer string.
  Remarks:
  The calling function has to provide memory for the output argument 'cp_text' !