3.65 DM_SetValue
This function enables you to change attributes of DM objects. For information on the attributes permitted for the relevant object type, please refer to the “Object Reference”.
DM_Boolean DML_default DM_EXPORT DM_SetValue
(
DM_ID object,
DM_Attribute attr,
DM_UInt index,
DM_Value *data,
DM_Options options
)
Parameters
-> DM_ID objectID
Describes the object the attribute of which you want to change.
-> DM_Attribute attr
Describes the attribute to be changed. All valid attributes are defined in IDMuser.h.
-> DM_UInt index
This parameter is only analyzed for vector attributes of objects and describes the index of the searched sub-object (e.g. text in listbox).
-> DM_Value*data
In this parameter the value to be accepted by the attribute is to be transferred. You have to take care, however, to assign the correct element in this union. For information on the data type of the individual attributes, please refer to the “Attribute Reference”
-> DM_Options options
Using this parameter you can control whether DM is to trigger the rule processing by setting the attribute successfully.
Option |
Meaning |
---|---|
This option means that the function call is not to trigger any internal events. If this flag is set, you can achieve a better performance in case that a lot of attribute changes have been made by the application. |
|
This option means that the function call is to trigger internal events. Then rules are triggered which have been defined for this object and which react to the changing of the specified attribute. |
|
This option is valid for the attribute AT_options (object canvas) on Motif. It describes a canvas which can have child objects. |
|
Valid on Motif with attribute AT_options. It describes a canvas which is not to have a focus border. |
|
The specified string is to be translated in the currently used language. This is of course only possible if the text already exists internally and if also a translation exists for it. |
Return Value
TRUE |
The attribute has been set successfully. |
FALSE |
The attribute could not be set. |
Example
Application-callback function checking whether an input string corresponds to an existing file.
DM_Boolean DML_default DM_CALLBACK CheckFilename __1(
(DM_CallBackArgs *, data))
{
DM_Value value; /* structure for DM_SetValue */
FILE *fptr; /* file pointer */
DM_ID id; /* Identifier of object */
/* get the current content */
if (DM_GetValue(data->object, AT_content, 0, &value,
DMF_GetLocalString))
/* check the datatype */
if(value.type == DT_string)
{
/* try to open the file */
if(!((fptr = fopen(value.value.string, "r"))))
{
/*
* the file cannot be opened for reading.
* activate the edittext again
*/
value.type = DT_boolean;
value.value.boolean = TRUE;
DM_SetValue(data->object, AT_active, 0, &value,
DMF_Inhibit);
/*
* The file cannot be read. So don't continue
* processing with the rules
*/
return (FALSE);
}
else
fclose(fptr);
/*
* the file could be opened. enable the other objects
*/
value.type = DT_boolean;
value.value.boolean = TRUE;
/* Get the id of the edittext "Actives" */
if ((id = DM_PathToID(0, "Actives")))
/* Change the object to sensitive */
DM_SetValue(id, AT_sensitive, 0, &value,
DMF_ShipEvent);
/*
* the last parameter must be ShipEvent,
* because a rule should be triggered
*/
/*
* Everything is ok. So let the rule process normally
*/
return(TRUE);
}
/* Too many errors don't continue the rule processing */
return (FALSE);
}
See Also
Built-in function setvalue() in manual “Rule Language”