pb whith PtNumericFloat

I edite the gcc_nto*/Makefile
and added “-Bstatic -l ph -Bdynamic” to the link lines ( LDFLAGS=… and
SDFLAGS=… ), but it seems I get another pb whith the PtNumericFloat.

Here is my code :

/* Y o u r D e s c r i p t i o n /
/
AppBuilder Photon Code Lib /
/
Version 2.01 */

/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/* Local headers */
#include “ablibs.h”
#include “abimport.h”
#include “proto.h”

PtWidget_tlink_instance;
PtWidget_t
Nfich;
PtWidget_tg[3];
float gain[3];
FILE
file;
FILE
aff;
char*nom;


int
gains_acquis( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )

{
int l=0;

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

link_instance = ApGetInstance(widget);
Nfich = ApGetWidgetPtr(link_instance,ABN_gains_nom);
PtGetResource(Nfich, Pt_ARG_TEXT_STRING, &nom,0);
file = fopen(nom,“r+”);
fseek(file,47*sizeof(float),SEEK_SET);

g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_kp);
g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_kd);
g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_ga);
//ABN_gains_kp and so are PtNumericFloat

l=0;

aff=fopen(“affich.txt”,“w”);

for(l=0;l<3;l++)
{
PtGetResource(g[l],Pt_ARG_NUMERIC_VALUE,&gain[l],0);
fwrite(gain[l],sizeof(float),1,file);
fprintf(aff,"%f \n",*gain[l]);
}

fclose(aff);
fclose(file);

return( Pt_CONTINUE );

}



But when I open affich.txt, I only obtain
0.0000
0.0000
0.0000
whatever I type in the widgets when running the application.

Then I tried something :


/* Y o u r D e s c r i p t i o n /
/
AppBuilder Photon Code Lib /
/
Version 2.01 */

/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/* Local headers */
#include “ablibs.h”
#include “abimport.h”
#include “proto.h”

PtWidget_tlink_instance;
PtWidget_t
Nfich;
PtWidget_tg[1];
int gain[1];
FILE
file;
FILE
aff;
char*nom;


int
gains_acquis( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )

{
int l=0;

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

link_instance = ApGetInstance(widget);
Nfich = ApGetWidgetPtr(link_instance,ABN_gains_nom);
PtGetResource(Nfich, Pt_ARG_TEXT_STRING, &nom,0);
file = fopen(nom,“r+”);
fseek(file,47*sizeof(int),SEEK_SET);

g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_test);
// ABN_gains_test is a PtNumric Integer

l=0;

aff=fopen(“affich.txt”,“w”);

for(l=0;l<1;l++)
{
PtGetResource(g[l],Pt_ARG_NUMERIC_VALUE,&gain[l],0);
fwrite(gain[l],sizeof(int),1,file);
fprintf(aff,"%d \n",*gain[l]);
}

fclose(aff);
fclose(file);

return( Pt_CONTINUE );

}



I just added a PtNumericInteger in the window, and changed the code to write
this number instead of the three previious ones. Then I obtain an integer
equal to the one I type when running the application.
I don’t really need the .txt file, but I’m afraid that the other file
(fwrite(gain[l],sizeof(int),1,file)) won’t be written correctly. Is there
another thing to do so that PtNumericFloat would be accepted, or is there a
mistake in my code (sometimes I’m quite lost whith the format in functions)
?

Hello,

I think that PtNumericFloat widget work with double type ( see help )
Change your line float *gain[3] to double *gain[3]. I think it would to
work.
best regards
Marian.

guillaume wrote:

I edite the gcc_nto*/Makefile
and added “-Bstatic -l ph -Bdynamic” to the link lines ( LDFLAGS=… and
SDFLAGS=… ), but it seems I get another pb whith the PtNumericFloat.

Here is my code :

/* Y o u r D e s c r i p t i o n /
/
AppBuilder Photon Code Lib /
/
Version 2.01 */

/* Standard headers */
#include <stdio.h
#include <stdlib.h
#include <unistd.h
#include <string.h

/* Local headers */
#include “ablibs.h”
#include “abimport.h”
#include “proto.h”

PtWidget_tlink_instance;
PtWidget_t
Nfich;
PtWidget_tg[3];
double gain[3];
float gain[3];
FILE
file;
FILE
aff;
char
nom;


int
gains_acquis( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )

{
int l=0;

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

link_instance = ApGetInstance(widget);
Nfich = ApGetWidgetPtr(link_instance,ABN_gains_nom);
PtGetResource(Nfich, Pt_ARG_TEXT_STRING, &nom,0);
file = fopen(nom,“r+”);
fseek(file,47*sizeof(float),SEEK_SET);

g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_kp);
g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_kd);
g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_ga);
//ABN_gains_kp and so are PtNumericFloat

l=0;

aff=fopen(“affich.txt”,“w”);

for(l=0;l<3;l++)
{
PtGetResource(g[l],Pt_ARG_NUMERIC_VALUE,&gain[l],0);
fwrite(gain[l],sizeof(float),1,file);
fprintf(aff,"%f \n",*gain[l]);
}

fclose(aff);
fclose(file);

return( Pt_CONTINUE );

}



But when I open affich.txt, I only obtain
0.0000
0.0000
0.0000
whatever I type in the widgets when running the application.

Then I tried something :


/* Y o u r D e s c r i p t i o n /
/
AppBuilder Photon Code Lib /
/
Version 2.01 */

/* Standard headers */
#include <stdio.h
#include <stdlib.h
#include <unistd.h
#include <string.h

/* Local headers */
#include “ablibs.h”
#include “abimport.h”
#include “proto.h”

PtWidget_tlink_instance;
PtWidget_t
Nfich;
PtWidget_tg[1];
int gain[1];
FILE
file;
FILE
aff;
char*nom;


int
gains_acquis( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )

{
int l=0;

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

link_instance = ApGetInstance(widget);
Nfich = ApGetWidgetPtr(link_instance,ABN_gains_nom);
PtGetResource(Nfich, Pt_ARG_TEXT_STRING, &nom,0);
file = fopen(nom,“r+”);
fseek(file,47*sizeof(int),SEEK_SET);

g[l++] = ApGetWidgetPtr(link_instance,ABN_gains_test);
// ABN_gains_test is a PtNumric Integer

l=0;

aff=fopen(“affich.txt”,“w”);

for(l=0;l<1;l++)
{
PtGetResource(g[l],Pt_ARG_NUMERIC_VALUE,&gain[l],0);
fwrite(gain[l],sizeof(int),1,file);
fprintf(aff,"%d \n",*gain[l]);
}

fclose(aff);
fclose(file);

return( Pt_CONTINUE );

}



I just added a PtNumericInteger in the window, and changed the code to write
this number instead of the three previious ones. Then I obtain an integer
equal to the one I type when running the application.
I don’t really need the .txt file, but I’m afraid that the other file
(fwrite(gain[l],sizeof(int),1,file)) won’t be written correctly. Is there
another thing to do so that PtNumericFloat would be accepted, or is there a
mistake in my code (sometimes I’m quite lost whith the format in functions)
?