06-06-2016 03:19 AM
hello evrybody 🙂
i have same function and i don't know how can i use it in the interface LabWindows/CVI :
void saisir(struct Atelier *A,int Na) ; float Tind(struct Atelier *A,int NA) ; void affiche(struct Atelier *A,int Na) ; void ecrirefichier(struct Atelier *A,int Na) ;
my header file
#ifndef _header_H_ #define _header_H_ struct Employer { char *nom ; int NPF ; char IndiceP ; float IndP ; }; struct Atelier { char *NAF ; char *NRA ; float TInd ; struct Employer *EMP ; int NE ; }; void saisir(struct Atelier *A,int Na) ; float Tind(struct Atelier *A,int NA) ; void affiche(struct Atelier *A,int Na) ; void ecrirefichier(struct Atelier *A,int Na) ; #endif
06-06-2016 03:46 AM
Hello,
the short answer is "simply call the functions in control callbacks"
Seriously speaking, this is a **Very** basic question that makes me think you are very new to CVI. If this is your situation, you should spend some time reading a few resources on CVI: open CVI and if the welcome page does not show select Help >> Welcome page... menu item; in the window that shows this way, select "Getting started with LabWindows/CVI" and read the document linked to have an overview of the IDE and the facilities it offers to you.
After stidying that document you could execut New >> Project from template in the welcome screen and choose "User interface application" among the templates offered: you'll have a generic framework where you can start adding controls and functions to build up your application.
06-06-2016 03:52 AM
i do it but 😞
06-06-2016 03:58 AM
I see.
Would you mind posting your project here so that we can speak about some concrete situation instead of speculating in theory? Please tell us also the version of CVI you are using.
06-06-2016 04:06 AM
06-06-2016 04:30 AM - edited 06-06-2016 04:48 AM
"Posting the project" means post UIR and code files so that we can see which control is used and how, how functions / variables are defined and passed to functions, which libraries are loaded...
If you do not want / you are not permitted to post actual code, you could create a sample project that shows the problem and post that one here.
06-06-2016 04:48 AM
thank you
that what i'm do
i create a button and i write the name of my function in the callback
the prototype of the function :
void saisir(struct Atelier *A,int Na)
06-06-2016 04:54 AM
Ok, even if you have not posted your actual code, we can see the problem.
You cannot directly use your function as the button function: controls require a special function prototype; CVI IDE can create that for you. Inside that function, you can add your code and call your function.
It seems complicated but it will be clear once you read the documents I listed in my first post: that tutorial will guide you through the creation of a user interface and the related code.
06-06-2016 04:59 AM
my actuel Code
project.c
#include <cvirte.h> #include <userint.h> #include "projet.h" #include <stdio.h> #include <stdlib.h> #include<string.h> static int panelHandle; void saisir(Atelier *A,int Na) { int i ,j,taux=0 ; char aide[100] ; char intro[100] ; char intro2[100] ; for(i=0;i<Na;i++) { (A+i)->TInd=0 ; } for(i=0;i<Na;i++) { printf("-->Donner le nom d'Atlier n=%d \n",i+1); scanf("%s",aide); (A+i)->NAF=malloc(strlen(aide)+1); strcpy((A+i)->NAF,aide) ; printf("-->Donner du Responsable d'Atlier n=%d \n",i+1); scanf("%s",intro) ; (A+i)->NRA=malloc(strlen(intro)+1); strcpy((A+i)->NRA,intro) ; printf("-->Donner le Nombre d'Employer pour l'Ateier n=%d \n",i+1); scanf("%d",&(A+i)->NE); if(!((A+i)->EMP=malloc(((A+i)->NE)*sizeof(Employer)))) exit(-1); for(j=0;j<(A+i)->NE;j++) { printf("-->Donner le nom d'Employer n=%d \n",j+1); gets(intro2) ; gets(intro2) ; (A+i)->EMP[j].nom=malloc(strlen(intro2)+1); strcpy((A+i)->EMP[j].nom,intro2) ; printf("-->Donner le NPF d'Employer n=%d \n",j+1); scanf("%d",&(A+i)->EMP[j].NPF) ; printf("-->Donner l'indiceP d'Employer n=%d \n",j+1); scanf("%c",&(A+i)->EMP[j].IndiceP) ; scanf("%c",&(A+i)->EMP[j].IndiceP) ; if ((A+i)->EMP[j].IndiceP =='A') taux=20 ; else if ((A+i)->EMP[j].IndiceP =='B') taux=10 ; else taux=5 ; (A+i)->EMP[j].IndP=taux*((A+i)->EMP[j].NPF) ; (A+i)->TInd += ((A+i)->EMP[j].IndP) ; } } } float Tind(Atelier *A,int NA) { float Total=0 ; int i ; for(i=0;i<NA;i++) { Total += ((A+i)->TInd) ; } return Total ; } void affiche(Atelier *A,int Na) { int i,j ; float TotalID ; TotalID=Tind(A,Na) ; printf("\n"); printf("--------------------------------------------------------------------------------\n"); printf("FICHE DE GESTION DES INDEMNITES DES EMPLOYES MOTOPROD (par journee)\n"); printf("--------------------------------------------------------------------------------\n"); for(i=0;i<Na;i++) { printf("Nom Atelier de Fabrication %d=%s | Nom Responsable Atelier %d=%s \n",i+1,(A+i)->NAF,i+1,(A+i)->NRA); printf(" Nom\tNPF\tIndiceP\tIndP\n"); for(j=0;j<(A+i)->NE;j++) { printf(" %s\t%d\t%c\t%.2f\n",(A+i)->EMP[j].nom,(A+i)->EMP[j].NPF,(A+i)->EMP[j].IndiceP,(A+i)->EMP[j].IndP); } printf("--------------------------------------------------------------------------------\n"); printf(" Total Indemnite=%.2f\n",(A+i)->TInd) ; printf("--------------------------------------------------------------------------------\n"); } printf("Totaux des indemnites des employes du Groupe MotoProd pendant la journee=%.2f\n",TotalID) ; printf("--------------------------------------------------------------------------------"); } void ecrirefichier(Atelier *A,int Na) { int i,j ; float TotalID=0; FILE *EMPLOYESMOTOPROD=NULL ; TotalID=Tind(A,Na) ; EMPLOYESMOTOPROD=fopen("employesmotoprod.txt","w") ; if(EMPLOYESMOTOPROD !=NULL) { printf("le fichier a etait bien creer"); fprintf(EMPLOYESMOTOPROD,"--------------------------------------------------------------------------------\n"); fprintf(EMPLOYESMOTOPROD,"FICHE DE GESTION DES INDEMNITES DES EMPLOYES MOTOPROD (par journee)\n\n"); fprintf(EMPLOYESMOTOPROD,"--------------------------------------------------------------------------------\n"); for(i=0;i<Na;i++) { fprintf(EMPLOYESMOTOPROD,"Nom Atelier de Fabrication %d=%s | Nom Responsable Atelier %d=%s \n",i+1,(A+i)->NAF,i+1,(A+i)->NRA) ; fprintf(EMPLOYESMOTOPROD," Nom\tNPF\tIndiceP\tIndP\n") ; for(j=0;j<(A+i)->NE;j++) { fprintf(EMPLOYESMOTOPROD," %s\t%d\t%c\t%.2f\n",(A+i)->EMP[j].nom,(A+i)->EMP[j].NPF,(A+i)->EMP[j].IndiceP,(A+i)->EMP[j].IndP) ; } fprintf(EMPLOYESMOTOPROD,"--------------------------------------------------------------------------------\n"); fprintf(EMPLOYESMOTOPROD," Total Indemnite=%.2f\n",(A+i)->TInd) ; fprintf(EMPLOYESMOTOPROD,"--------------------------------------------------------------------------------\n"); } fprintf(EMPLOYESMOTOPROD,"Totaux des indemnites des employes du Groupe MotoProd pendant la journee=%.2f\n",TotalID) ; fprintf(EMPLOYESMOTOPROD,"--------------------------------------------------------------------------------\n"); fclose(EMPLOYESMOTOPROD) ; } else printf("le fichier n'est pas creer"); } int main (int argc, char *argv[]) { if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if ((panelHandle = LoadPanel (0, "projet.uir", PANEL)) < 0) return -1; DisplayPanel (panelHandle); RunUserInterface (); DiscardPanel (panelHandle); return 0; } int CVICALLBACK QuitCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: QuitUserInterface (0); break; } return 0; }
project.h
/**************************************************************************/
/* LabWindows/CVI User Interface Resource (UIR) Include File */
/* */
/* WARNING: Do not add to, delete from, or otherwise modify the contents */
/* of this include file. */
/**************************************************************************/
#include <userint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Panels and Controls: */
#define PANEL 1
#define PANEL_QUITBUTTON 2 /* control type: command, callback function: QuitCallback */
#define PANEL_COMMANDBUTTON 3 /* control type: command, callback function: (none) */
/* Control Arrays: */
/* (no control arrays in the resource file) */
/* Menu Bars, Menus, and Menu Items: */
/* (no menu bars in the resource file) */
/* Callback Prototypes: */
int CVICALLBACK QuitCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
#ifdef __cplusplus
}
#endif
06-06-2016 05:14 AM
You seriously should read that tutorial...