Problem w/ PtGetResource for PtNumericInteger

Hello,

I have two PtNumericInteger widgets on my GUI. When widget 1 is changed, I want widget 2 to be loaded with the same value. The problem is that widget 2 (range ± 2147483648) is always loaded with a really large value = 134626656, instead of the value of widget 1 (with value range 1 to 6). When I load a fixed value into widget 2 it works, so I’m assuming that I am not using PtGetResource() properly.

Please help. Thanks.


int EdtWidget1_onChange(PtWidget_t*widget, ApInfo_t *apinfo, PtCallbackInfo_t *coinfo)
{
int iTemp1, iTemp2;

PtGetResource(ABW_EDT_WIDGET1, Pt_ARG_NUMERIC_VALUE, &iTemp1,0);

iTemp2 = iTemp1;

PtSetResource(ABW_EDIT_WIDGET2, Pt_ARG_NUMERIC_VALUE,iTemp2,0);

return(Pt_Continue);
}

Carefully read the documentation on PtGetResource. If you can’t find what’s wrong, read it again ;-) If you still can find it, post again.

I would like to give some hint cuz I know it can be frustrating when you are reading the documentation.
PtGetResource can only be used with pointer, the third argument must be a pointer type.

jinma, you made it way too easy now ;-))) In the PtGetResource doc, there is a big yellow icon and the text beside it says “Because PtGetResource() returns a pointer”.

Also the page says “This macro sets a pointer to a resource value within the specified widget”.

Then value:
The address of a pointer …

I mean how much clearer can it get ;-)

Jinma, I answer lots of question around here, and it’s just recently that I realize that in order to really help people you have to help them be autonomous, to create some skills at finding information that is in some cases is really obvious.

  • Mario

sorry~ I know… but it seemed like “foozy man” was very new to PhAB and I thought he could get a break this time ~
I was once like him too and getting good help from this website made me love QNX.

No need to be sorry. I’m just giving my opinion on this, you are free to do what every you want with it.

I’m having a good though for the doc people. I think they are doing a great job. Sometimes yes it’s hard to find specific detail in all the available information. But in some case it’s really obvious, which is why I prefer to point to the documention, a tribute to the doc team at QSS ;-)

  • Cheers

Thanks, Mario!

Thanks to everyone for their help. In fact, I found an example with PtGetResources() from this website, and gave up on PtGetResource() for awhile after reading mario’s email. Now, I see where I went wrong with PtGetResource(). I AM new to PhAB, and it does get confusing how to retrieve data from different types of widgets.

I prefer to use PtGetResource over PtGetResources, unless I have to modify tons of attributes.