next up previous contents
Next: Deleting attributes Up: Attributes Previous: Reading attributes   Contents

Writing attributes

Attributes are written using idba_critica, which can be used after an idba_dammelo, after an idba_prendilo or at any time using a stored data id. These three case differ on how to communicate to idba_critica what is the data about which to write attributes.

When used after idba_dammelo, idba_critica can refer directly to the last data retrieved:

c     ...setup a query...
      call idba_voglioquesto(handle, count)
      do while (count.gt.0)
        call idba_dammelo(handle, param)
c       ...process data...

c       Set the attributes
        call idba_seti(handle, "*B33007", 75)
        call idba_seti(handle, "*B33006", 42)
        call idba_critica(handle)

        count = count - 1
      enddo

After an idba_prendilo instead, since idba_prendilo can write more than one data at a time, we need to tell idba_critica which of them we are referring to:

c     Insert wind speed and temperature
      call idba_setr(handle, "B11002", 1.8)
      call idba_setr(handle, "B12001", 22)
      call idba_prendilo(handle)

c     Set the attributes
      call idba_seti(handle, "*B33007", 75)

c     Use "*var_related" to indicate which of the two variables we are annotating
      call idba_setc(handle, "*var_related", "B11002")

      call idba_critica(handle)

idba_critica can also be called at any time using a previously stored data it:

c     ...perform a query with idba\_voglioquesto...
      do while (count.gt.0)
        call idba_dammelo(handle, param)
c       ...process data...

c       This variable is interesting: save the context ID
c       to refer to it later
        call idba_enqi(handle, "context_id", saved_id)
        
        count = count - 1
      enddo

c     ...some time later...

c     Insert attributes about that interesting variable
      call idba_seti(handle, "*B33007", 75)
      call idba_seti(handle, "*B33006", 42)
      
c     Select the variable using its context id
c     and variable code
      call idba_seti(handle, "*context_id", saved_id)
      call idba_seti(handle, "*var_related", "B11001")
      call idba_critica(handle)

This code introduces a new function:

idba_critica
Set one or more attributes about a variable.

The variable can be identified directly by using idba_seti(handle, "*context_id", id) and idba_seti(handle, "*var_related", name). These parameters are automatically set by the idba_dammelo and idba_prendilo action routines.

The attributes and values are set as input to idba_critica using the idba_set* functions with an asterisk in front of the variable name.

idba_critica will work in different ways according to the attributes opening mode of the database:

"read"
attributes cannot be modified in any way.
"add"
attributes can can be added to the database, but existing attributes cannot be modified.
"rewrite"
attributes can be added, and existing attributes can be overwritten.


next up previous contents
Next: Deleting attributes Up: Attributes Previous: Reading attributes   Contents
root 2007-06-20