| Author |
Message |
|
|
Post subject: how to send double to Pt_ARG_TEXT_STRING
Posted: Apr 05, 2008 - 10:26 AM
|
|
New Member
Joined: Apr 05, 2008
Posts: 5
|
|
Dear all,
I am new to qnx so kindly pardon me for my silly qns.
I am trying to display a value to a label using the following method
Code:
sprintf(cs, "%2.1f",s[i]);
sprintf(cd, "%2.1f",d[i]);
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);\
but is seems to crash the system
but when i used a static string like
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,"TEST", 0);
it seems to be ok.
It seems that i can use sprintf to pass the variable over.
Can anyhow help me out???
thanks in advance |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: how to send double to Pt_ARG_TEXT_STRING
Posted: Apr 05, 2008 - 10:43 AM
|
|
New Member
Joined: Apr 05, 2008
Posts: 5
|
|
it seems that it is not due to sprintf but when i insert a loop into it
i am really puzzle why a loop will cause a crash
for (i=1;i<15;i++){
sprintf(cs, "%2.1f",s[i]);
sprintf(cd, "%2.1f",d[i]);
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);
}
error is:
Process 446480 (AntiB_gNiNo_NB1207392159576) terminated SIGSEGV code=1 fltno=11 ip=0117e154 mapaddr=00101154. ref=00000014 |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: how to send double to Pt_ARG_TEXT_STRING
Posted: Apr 05, 2008 - 06:03 PM
|
|
QNX Master
Joined: Jun 25, 2003
Posts: 1078
|
|
| While this doesn't explain your problem, you might want to note that if your code was working, the first 14 time though the loop would accomplish nothing visible. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: how to send double to Pt_ARG_TEXT_STRING
Posted: Apr 08, 2008 - 08:40 PM
|
|
QNX Master
Joined: Sep 01, 2002
Posts: 2849
|
|
| To add to Mitch's comment, I find the i=1 odd typicaly it would be 0. Also how have you defined the cs and cd variables? |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: how to send double to Pt_ARG_TEXT_STRING
Posted: Apr 25, 2008 - 08:15 AM
|
|
New Member
Joined: Jan 11, 2007
Posts: 4
Location: UK
|
|
| For the conversion in sprintf I would use 'lf' (LF) if the variable is defined as double, at waht point does it crash? |
|
|
| |
|
|
|
 |
|
|