CallsciC.c File Reference

#include <windows.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include "../../../../../../modules/core/includes/machine.h"
#include "../../../../../../modules/core/includes/stack-c.h"
#include "../../../../../../modules/core/includes/CallScilab.h"

Include dependency graph for CallsciC.c:

Go to the source code of this file.

Defines

#define TRUE   1
#define FALSE   0

Functions

static int example1 (void)
static int example2 (void)
static int example3 (void)
int main (void)


Define Documentation

#define FALSE   0

Definition at line 18 of file CallsciC.c.

#define TRUE   1

Definition at line 17 of file CallsciC.c.


Function Documentation

static int example1 ( void   )  [static]

Definition at line 22 of file CallsciC.c.

References A, b, free(), GetMatrixptr, i, lp, m, malloc(), mb, n, nb, NULL, ReadMatrix, SendScilabJob(), and WriteMatrix.

Referenced by main().

00023 {
00024         static double A[]={1,2,3,4};  int mA=2,nA=2;
00025         static double b[]={4,5};  int mb=2,nb=1;
00026 
00027 
00028         /* Create Scilab matrices A and b */
00029         WriteMatrix("A", &mA, &nA, A);
00030         WriteMatrix("b", &mb, &nb, b);
00031 
00032         SendScilabJob("disp('A=');");
00033         SendScilabJob("disp(A);");
00034         SendScilabJob("disp('b=');");
00035         SendScilabJob("disp(b);");
00036         SendScilabJob("disp('x=A\\b');");
00037 
00038         if ( SendScilabJob("A,b,x=A\\b;") != 0) 
00039         {
00040                 fprintf(stdout,"Error occured during scilab execution (SendScilabJob)\n");
00041         }
00042         else 
00043         {
00044                 double *cxtmp=NULL;
00045                 int m,n,lp,i;
00046 
00047                 /* Get m and n */
00048                 GetMatrixptr("x", &m, &n, &lp);
00049 
00050                 cxtmp=(double*)malloc((m*n)*sizeof(double));
00051 
00052                 ReadMatrix("x", &m, &n, cxtmp);
00053 
00054                 for(i=0;i<m*n;i++)
00055                 {
00056                         fprintf(stdout,"x[%d] = %5.2f\n",i,cxtmp[i]);
00057                 }
00058 
00059                 if (cxtmp) 
00060                 {
00061                         free(cxtmp);
00062                         cxtmp=NULL;
00063                 }
00064         }
00065         return 0;
00066 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int example2 ( void   )  [static]

Definition at line 68 of file CallsciC.c.

References ScilabDoOneEvent(), ScilabHaveAGraph(), and SendScilabJob().

Referenced by main().

00069 {
00070         SendScilabJob("plot3d();");
00071         printf("\nClose Graphical Windows to close this example.\n");
00072         while( ScilabHaveAGraph() )
00073         {
00074                 ScilabDoOneEvent();
00075                 Sleep(1);
00076         }
00077         return 1; 
00078 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int example3 ( void   )  [static]

Definition at line 80 of file CallsciC.c.

References code, free(), GetLastJob(), i, lastjob, malloc(), NULL, and SendScilabJobs().

Referenced by main().

00081 {
00082         int code=0;
00083 
00084         char **JOBS=NULL;
00085         const int SizeJOBS=6;
00086         int i=0;
00087 
00088         JOBS=(char**)malloc(sizeof(char**)*SizeJOBS);
00089 
00090         for (i=0;i<SizeJOBS;i++)
00091         {
00092                 JOBS[i]=(char*)malloc(sizeof(char*)*1024);
00093         }
00094 
00095         strcpy(JOBS[0],"A=1 ..");
00096         strcpy(JOBS[1],"+3;");
00097         strcpy(JOBS[2],"B = 8;");
00098         /* strcpy(JOBS[2],"b = V_NOT_EXIST;"); */
00099         strcpy(JOBS[3],"+3;");
00100         strcpy(JOBS[4],"disp('C=');");
00101         strcpy(JOBS[5],"C=A+B;disp(C);"); /* C = 12 */
00102 
00103         code=SendScilabJobs(JOBS,SizeJOBS);
00104 
00105         if (code)
00106         {
00107                 char lastjob[4096]; // bsiz in scilab 4096 max
00108                 if (GetLastJob(lastjob,4096))
00109                 {
00110                         printf("Error %s\n",lastjob);
00111                 }
00112         }
00113 
00114         for (i=0;i<SizeJOBS;i++)
00115         {
00116                 if (JOBS[i]) {free(JOBS[i]);JOBS[i]=NULL;}
00117         }
00118         return 1;
00119 }

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( void   ) 

Definition at line 121 of file CallsciC.c.

References example1(), example2(), example3(), FALSE, NULL, StartScilab(), and TerminateScilab().

00123 {
00124         if ( StartScilab(NULL,NULL,NULL) == FALSE ) printf("Error : StartScilab \n");
00125 
00126         printf("\nexample 1\n");
00127         example1();
00128         system("pause");
00129         printf("\nexample 2\n");
00130         example2();
00131         system("pause");
00132         printf("\nexample 3\n");
00133         example3();
00134         system("pause");
00135         
00136         if ( TerminateScilab(NULL) == FALSE ) printf("Error : TerminateScilab \n");
00137         return 0;
00138 }

Here is the call graph for this function:


Generated on Sun Mar 4 15:12:02 2007 for Scilab [trunk] by  doxygen 1.5.1