Skip navigation.
Home
The QNX Community Portal

View topic - how to send double to Pt_ARG_TEXT_STRING

how to send double to Pt_ARG_TEXT_STRING

Isn't the name clear?

how to send double to Pt_ARG_TEXT_STRING

Postby dunno98 » Sat Apr 05, 2008 10:26 am

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: Select all
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
dunno98
New Member
 
Posts: 5
Joined: Sat Apr 05, 2008 10:15 am

RE: how to send double to Pt_ARG_TEXT_STRING

Postby dunno98 » Sat Apr 05, 2008 10:43 am

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
dunno98
New Member
 
Posts: 5
Joined: Sat Apr 05, 2008 10:15 am

RE: how to send double to Pt_ARG_TEXT_STRING

Postby maschoen » Sat Apr 05, 2008 6:03 pm

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.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

RE: how to send double to Pt_ARG_TEXT_STRING

Postby mario » Tue Apr 08, 2008 8:40 pm

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?
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

RE: how to send double to Pt_ARG_TEXT_STRING

Postby martinj999 » Fri Apr 25, 2008 8:15 am

For the conversion in sprintf I would use 'lf' (LF) if the variable is defined as double, at waht point does it crash?
martinj999
New Member
 
Posts: 4
Joined: Thu Jan 11, 2007 9:45 am
Location: UK


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 2 guests