![]() | Programming Guide | ![]() ![]() ![]() ![]() |
#include <smuprapi.h>int sm_prop_set_int(int obj_id, int prop, int val);int sm_prop_set_str(int obj_id, int prop, char *val);int sm_prop_set_dbl(int obj_id, int prop, double val);int sm_prop_set_x_int(int obj_id, int array_item, int prop, int val);int sm_prop_set_x_str(int obj_id, int array_item, int prop, char *val);int sm_prop_set_x_dbl(int obj_id, int array_item, int prop, double val);int sm_prop_set_m_int(int obj_id, int prop, int prop_item, int val);int sm_prop_set_m_str(int obj_id, int prop, int prop_item, char *val);int sm_prop_set_m_dbl(int obj_id, int prop, int prop_item, double val);
obj_id
- An integer handle that identifies the Panther object whose property you want to set, obtained through sm_prop_id. For application properties, supply
PR_APPLICATION
; for the current screen,PR_CURSCREEN
.array_item
- The widget occurrence or element whose value you want to set.
prop
- The property to set. Refer to Chapter 1, "Runtime Properties," in Quick Reference for a full list of property constants.
prop_item
- Specifies the item in a multi-item property whose value you want to set. For example, if
prop
is set toPR_CONTROL_STRING
, supply a logical key name to get that key's current control string assignment.val
- The value to set for the specified property or property item. The value's type—string, integer, or double—must be appropriate to the property itself. For a list of properties and their valid values, refer to Chapter 1, "Runtime Properties," in Quick Reference.
- · 0: Success.
- ·
PR_E_MALLOC
: Insufficient memory.- ·
PR_E_OBJID
: Object ID does not exist.- ·
PR_E_OBJECT
: Object does not exist.- ·
PR_E_ITEM
: Invalid occurrence or element.- ·
PR_E_PROP
: Invalid property.- ·
PR_E_PROP_ITEM
: Invalid property item.- ·
PR_E_PROP_VAL
: Invalid property value.- ·
PR_E_CONVERT
: Unable to perform conversion.- ·
PR_E_OBJ_TYPE
: Invalid object type.- ·
PR_E_RANGE
: Property value is out of range.- ·
PR_E_NO_SET
: Property cannot be set.- ·
PR_E_BEYOND_SCREEN
: Widget extends beyond screen.- ·
PR_E_WW_SCROLLING
: Word wrap must be scrolling.- ·
PR_E_NO_SYNC
: Arrays cannot be synchronized.- ·
PR_E_TOO_BIG
: Widget too large for screen.- ·
PR_E_ERROR
: Failed for another reason.- ·
PR_E_BAD_MASK
: Invalid edit mask or regular expression- ·
PR_E_NO_KEYSTRUCT
: Property requires previous execution ofSELECT
,NEW
,COPY
, orCOPY_FOR_UPDATE
command.
sm_prop_set
has three basic variants:sm_prop_set_str
,sm_prop_set_int
, andsm_prop_set_dbl
, which set string, integer, and double properties, respectively. For example,sm_prop_set_str
sets string properties such astitle
, whilesm_prop_set_int
sets integer properties such asmax_occurrences
.
- To set the properties of an array's elements, obtain a handle by supplying sm_prop_id with a widget identifier that has the format
widget-spec
[[]]
.- To set the properties of an array's occurrences, obtain a handle by supplying sm_prop_id with a widget identifier that has the format
widget-spec
[]
.For example, this call to
sm_prop_id
gets a handle to the properties ofcust_id's
elements:int elem_h;
elem_h = sm_prop_id("cust_id[[]]");Alternatively, this call gets a handle to the properties of
cust_id
's occurrences:int occ_h;
occ_h = sm_prop_id("cust_id[]");Given these two handles, you can use
sm_prop_get_x_int
to set the foreground color of eithercust_id
's first element or first occurrence as follows:/*set the first element's foreground color */
sm_prop_set_x int(elem_h, 1, PR_FG_COLOR_NUM, MAGENTA);/*set the first occurrence's foreground color */
sm_prop_set_x_int(occ_h, 1,PR_FG_COLOR_NUM, MAGENTA);Note: To set properties on the entire array, use a handle obtained by supplying sm_prop_id with a widget string identifier that contains no subscript.
sm_prop_set_m_
prop-type
sets one of the values in a multi-item property such asPR_DROP_DOWN_DATA
for an option menu, orPR_CONTROL_STRING
for a screen. For example, this code callssm_prop_set_m_str
to set the data for an item in option menuflavors
:/* replace current item with contents of "substitute" */
char cur_item[256], new_item[256];
char *option_txt[256];
int ct, f_id, err;
f_id = sm_prop_id("flavors");
/*get substitute data*/
sm_n_getfield("substitute", new_item);
/*get selection data*/
sm_n_getfield("flavors", cur_item);
/* get offset of current selection */
for (ct = 1; ; ct++)
{
option_txt = sm_prop_get_m_str(f_id,
PR_DROP_DOWN_DATA, ct)
if (!option_txt)
{
err = PR_E_ERROR;
break;
}
if (strcmp(option_txt, cur_item) == 0)
{
err = sm_prop_set_m_str(f_id,
PR_DROP_DOWN_DATA, ct, new_item);
break;
}
}
sm_prop_error, sm_prop_id, sm_prop_set
![]()
![]()
![]()
![]()