get resource Pt_ARG_USER_DATA

Hi,
To determine Radio button activities, i am reading Pt_ARG_USER_DATA
resource via PtGetResource API. (Pt_ARG_USER_DATA is selected with unique
values for radio button#1 is 1 and radio button #2 is 2)

Ex:
PtGetresource(ABW_TOGGLE_BUTTONS, Pt_ARG_USER_DATA, &i, 0);
With this i am getting CORE DUMP ERROR.

Can somebody help me?

Thanks,
Suresh.

Suresh Kumar wrote:

Hi,
To determine Radio button activities, i am reading Pt_ARG_USER_DATA
resource via PtGetResource API. (Pt_ARG_USER_DATA is selected with unique
values for radio button#1 is 1 and radio button #2 is 2)

Ex:
PtGetresource(ABW_TOGGLE_BUTTONS, Pt_ARG_USER_DATA, &i, 0);
With this i am getting CORE DUMP ERROR.

Can somebody help me?

Thanks,
Suresh.
\

I think you want something like this:

int i = 2;
PtSetresource(ABW_TOGGLE_BUTTONS, Pt_ARG_USER_DATA, &i, sizeof(int));
PtGetresource(ABW_TOGGLE_BUTTONS, Pt_ARG_USER_DATA, &i, sizeof(int));

I have not tested this, I could be talking rubbish.

Cheers

Garry

Suresh Kumar <skavula@nordson.com> wrote:

Hi,
To determine Radio button activities, i am reading Pt_ARG_USER_DATA
resource via PtGetResource API. (Pt_ARG_USER_DATA is selected with unique
values for radio button#1 is 1 and radio button #2 is 2)

Ex:
PtGetresource(ABW_TOGGLE_BUTTONS, Pt_ARG_USER_DATA, &i, 0);
With this i am getting CORE DUMP ERROR.

Can somebody help me?

How do you declare i? Pt_ARG_USER_DATA is an Alloc resource, so you need
to pass the address of a pointer to the correct type of data. For example,
if you’re storing an integer in this resource, you should declare i as:

int *i;

For more information, see the Manipulating Resources in Application Code
chapter of the Photon Programmer’s Guide.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Wojtek Lerch <Wojtek_L@yahoo.ca> wrote:

(Of course, since i is a pointer, it would also be a good idea to rename
it to something that doesn’t suggest that it’s an integer… > :slight_smile:

FORTRAN has scarred innumerable programmers – even ones that never
learned it. :slight_smile:


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Steve Reid wrote:

Suresh Kumar <> skavula@nordson.com> > wrote:
To determine Radio button activities, i am reading Pt_ARG_USER_DATA
resource via PtGetResource API. (Pt_ARG_USER_DATA is selected with unique
values for radio button#1 is 1 and radio button #2 is 2)


Ex:
PtGetresource(ABW_TOGGLE_BUTTONS, Pt_ARG_USER_DATA, &i, 0);
With this i am getting CORE DUMP ERROR.


How do you declare i? Pt_ARG_USER_DATA is an Alloc resource, so you need
to pass the address of a pointer to the correct type of data. For example,
if you’re storing an integer in this resource, you should declare i as:

int *i;

It might also be worth mentioning that if you’re setting up the user
data in PhAB, PhAB stores it in the widget as a string rather than an
int. In other words, you need to declare your i as “char *i” (or, if
you’re as pedantic as I am, as “const char *i”), and after getting the
resource, test the value by comparing strings, i.e. either

if ( ! strcmp( i, “1” ) ) …

or, if you know that all those strings are only one character long,

if ( i[0] == ‘1’ ) …

(Of course, since i is a pointer, it would also be a good idea to rename
it to something that doesn’t suggest that it’s an integer… :slight_smile:

Hi,
I tested by declaring i as a int * and char *, even though i am getting
Core Dump error.
I am reading like this:

Test1:
int *i;
PtGetresource(ABW_TOGGLE_BUTTONS, Pt_ARG_USER_DATA, &i, sizeof(int));

Test2:
char *i;
PtGetresource(ABW_TOGGLE_BUTTONS, Pt_ARG_USER_DATA, &i, sizeof(char));

Can any one help me ?

Thanks,
With Best Regards,
Suresh.
“Suresh Kumar” <skavula@nordson.com> wrote in message
news:ce25g9$ne5$1@inn.qnx.com

Hi,
To determine Radio button activities, i am reading Pt_ARG_USER_DATA
resource via PtGetResource API. (Pt_ARG_USER_DATA is selected with unique
values for radio button#1 is 1 and radio button #2 is 2)

Ex:
PtGetresource(ABW_TOGGLE_BUTTONS, Pt_ARG_USER_DATA, &i, 0);
With this i am getting CORE DUMP ERROR.

Can somebody help me?

Thanks,
Suresh.

Suresh Kumar wrote:

Can any one help me ?

How you should get the resource depends on how you set it. So far, you
have not mentioned how you’re setting it. If you’re setting it from
your code rather than by hand in PhAB, a code sample might make things
clearer.

Hi Lerch,

Thanks for your Reply, I am setting Pt_ARG_USER_DATA from PhAB not
from code, But i want to get this data from code.

Thanks,
Suresh.


“Wojtek Lerch” <Wojtek_L@yahoo.ca> wrote in message
news:ce5l8d$eiv$1@inn.qnx.com

Suresh Kumar wrote:
Can any one help me ?

How you should get the resource depends on how you set it. So far, you
have not mentioned how you’re setting it. If you’re setting it from
your code rather than by hand in PhAB, a code sample might make things
clearer.

Suresh Kumar wrote:

Thanks for your Reply, I am setting Pt_ARG_USER_DATA from PhAB not
from code, But i want to get this data from code.

I just attached the following callback to a button in a PhAB
application, and it displayed the button’s user data in the PtNotice box
without crashing:

int
cb( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{

char *p;
PtGetResource( widget, Pt_ARG_USER_DATA, &p, 0 );
PtNotice( NULL, NULL, “User Data”, NULL, p, NULL, “OK”, NULL, 0 );

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}