# How to extract read and set values from a scalar attribute

Intended audience: developers, Programming language: c++

The following example will show how you can extract the read and set values from a scalar attribute. In the example, the attribute is a Tango::DevDouble.

     1Tango::DevVarDoubleArray * attr_val;
     2Tango::DevDouble read_value, set_value;
     3try {
     4    Tango::DeviceAttribute dev_attr =  tg_device_proxy->read_attribute("attr_name");
     5    dev_attr >> attr_val;
     6    read_value = (*attr_val)[0];
     7    set_value = (*attr_val)[1];
     8    delete attr_val;
     9}
    10catch(Tango::DevFailed &e){
    11    Tango::Except::print_exception(e);
    12    throw;
    13}

Note

The operator ** >>** will allocate the memory for the Tango::DevVarDoubleArray but the programmer should free this memory when the work is done with this variable.