add example with LabWindow
Allan CORNET [Tue, 2 Dec 2008 14:00:11 +0000 (15:00 +0100)]
scilab/modules/core/examples/call_scilab/c/LabWindow/CallsciC.c [new file with mode: 0644]
scilab/modules/core/examples/call_scilab/c/LabWindow/example.prj [new file with mode: 0644]
scilab/modules/core/examples/call_scilab/c/LabWindow/readme.txt [new file with mode: 0644]

diff --git a/scilab/modules/core/examples/call_scilab/c/LabWindow/CallsciC.c b/scilab/modules/core/examples/call_scilab/c/LabWindow/CallsciC.c
new file mode 100644 (file)
index 0000000..d810872
--- /dev/null
@@ -0,0 +1,154 @@
+/* Allan CORNET */
+/* Scilab, INRIA 2004 */
+/* Only For Windows */
+/*--------------------------------------------------------------------------*/
+#pragma comment(lib, "../../../../../../bin/libScilab.lib")
+#pragma comment(lib, "../../../../../../bin/MALLOC.lib")
+/*--------------------------------------------------------------------------*/
+#include <stdlib.h> 
+#include <stdio.h> 
+#include <string.h>
+#include "CallScilab.h"
+#include "stack-c.h"
+/*--------------------------------------------------------------------------*/
+/* See SCI/modules/core/includes/CallScilab.h */
+/*--------------------------------------------------------------------------*/
+static int example1(void)
+{
+       static double A[]={1,2,3,4};  int mA=2,nA=2;
+       static double b[]={4,5};  int mb=2,nb=1;
+
+
+       /* Create Scilab matrices A and b */
+       WriteMatrix("A", &mA, &nA, A);
+       WriteMatrix("b", &mb, &nb, b);
+
+       SendScilabJob("disp('A=');");
+       SendScilabJob("disp(A);");
+       SendScilabJob("disp('b=');");
+       SendScilabJob("disp(b);");
+       SendScilabJob("disp('x=A\\b');");
+
+       if ( SendScilabJob("A,b,x=A\\b;") != 0) 
+       {
+               fprintf(stdout,"Error occured during scilab execution (SendScilabJob)\n");
+       }
+       else 
+       {
+               double *cxtmp=NULL;
+               int m,n,lp,i;
+
+               /* Get m and n */
+               GetMatrixptr("x", &m, &n, &lp);
+
+               cxtmp=(double*)malloc((m*n)*sizeof(double));
+
+               ReadMatrix("x", &m, &n, cxtmp);
+
+               for(i=0;i<m*n;i++)
+               {
+                       fprintf(stdout,"x[%d] = %5.2f\n",i,cxtmp[i]);
+               }
+
+               if (cxtmp) 
+               {
+                       free(cxtmp);
+                       cxtmp=NULL;
+               }
+       }
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int example2(void)
+{
+       int code=0;
+
+       char **JOBS = NULL;
+       const int SizeJOBS = 5;
+       int i=0;
+       int m = 0, n = 0;
+       double *cxtmp = NULL;
+
+       JOBS=(char**)malloc(sizeof(char**)*SizeJOBS);
+
+       for (i=0;i<SizeJOBS;i++)
+       {
+               JOBS[i]=(char*)malloc(sizeof(char*)*1024);
+       }
+
+       strcpy(JOBS[0],"A=1 ..");
+       strcpy(JOBS[1],"+3;");
+       strcpy(JOBS[2],"B = 8;");
+       strcpy(JOBS[3],"+3;");
+    strcpy(JOBS[4],"C=A+B;"); /* C = 12 */
+
+       
+       for(i=0;i<SizeJOBS;i++)
+       {
+               printf("JOBS[%d] = %s\n",i,JOBS[i]);
+       }
+       
+       code=SendScilabJobs(JOBS,SizeJOBS);
+
+       if (code)
+       {
+               char lastjob[4096]; // bsiz in scilab 4096 max
+               if (GetLastJob(lastjob,4096))
+               {
+                       printf("Error %s\n",lastjob);
+               }
+       }
+       
+       m = 1; n = 1;
+       cxtmp = (double*)malloc((m*n)*sizeof(double));
+
+       ReadMatrix("C", &m, &n, cxtmp);
+
+       printf("Result :\n");
+       for(i=0;i<m*n;i++)
+       {
+               fprintf(stdout,"C[%d] = %5.2f\n",i,cxtmp[i]);
+       }
+
+       for (i=0;i<SizeJOBS;i++)
+       {
+               if (JOBS[i]) {free(JOBS[i]);JOBS[i]=NULL;}
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+static int example3(void)
+{
+       SendScilabJob("plot3d();quit;");
+       printf("\nClose Graphical Windows to close this example.\n");
+       while( ScilabHaveAGraph() )
+       {
+               ScilabDoOneEvent();
+       }
+       return 1; 
+}
+/*--------------------------------------------------------------------------*/
+int main(void)
+/* int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow) */
+{
+       if ( StartScilab(NULL,NULL,NULL) == FALSE ) printf("Error : StartScilab\n");
+       printf("\nexample 1\n");
+       example1();
+       printf("\npress return\n");
+       getchar();
+       
+       printf("\nexample 2\n");
+       example2();
+       printf("\npress return\n");
+       getchar();
+       
+       printf("\nexample 3\n");
+       example3();
+       printf("\npress return\n");
+       getchar();
+
+       
+       if ( TerminateScilab(NULL) == FALSE ) printf("Error : TerminateScilab\n");
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/core/examples/call_scilab/c/LabWindow/example.prj b/scilab/modules/core/examples/call_scilab/c/LabWindow/example.prj
new file mode 100644 (file)
index 0000000..296910a
--- /dev/null
@@ -0,0 +1,137 @@
+[Project Header]
+Version = 850
+Pathname Line0001 = "/d/GIT-scilab-master/scilab/scilab/modules/core/examples/call_scilab/c/LabWindow"
+Pathname Line0002 = "/example.prj"
+CVI Dir = "/c/program files (x86)/national instruments/cvi85"
+CVI Shared Dir = "/C/Program Files (x86)/National Instruments/Shared/CVI"
+CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI85"
+CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
+IVI Standard Root Dir = "/C/Program Files (x86)/IVI"
+VXIplug&play Framework Dir = "/c/vxipnp/winnt"
+Number of Files = 2
+Target Type = "Executable"
+Flags = 16
+
+[File 0001]
+File Type = "CSource"
+Res Id = 1
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "CallsciC.c"
+Path Line0001 = "/d/GIT-scilab-master/scilab/scilab/modules/core/examples/call_scilab/c/LabWindow"
+Path Line0002 = "/CallsciC.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+
+[File 0002]
+File Type = "Library"
+Res Id = 2
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "../../../../../../bin/LibScilab.lib"
+Path = "/d/GIT-scilab-master/scilab/scilab/bin/LibScilab.lib"
+Exclude = False
+Project Flags = 0
+Folder = "Not In A Folder"
+
+[Folders]
+Include Files Folder Not Added Yet = True
+User Interface Files Folder Not Added Yet = True
+Instrument Files Folder Not Added Yet = True
+Folder 0 = "Source Files"
+
+[Compiler Options]
+Default Calling Convention = "cdecl"
+Require Prototypes = True
+Require Return Values = True
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Unreferenced Identifiers Warning = False
+Enable Assignment In Conditional Warning = False
+O Option Compatible With 5.0 = False
+Uninitialized Locals Compile Warning = "Conservative"
+
+[Run Options]
+Stack Size = 250000
+Image Base Address = 4194304
+
+[Compiler Defines]
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
+
+[Include Paths]
+Include Path 1 Is Rel = False
+Include Path 1 = "/d/GIT-scilab-master/scilab/scilab/bin"
+Include Path 2 Is Rel = False
+Include Path 2 = "/d/GIT-scilab-master/scilab/scilab/modules/core/includes"
+Include Path 3 Is Rel = False
+Include Path 3 = "/d/GIT-scilab-master/scilab/scilab/modules/output_stream/includes"
+
+[Create Executable]
+Executable File_Debug Is Rel = True
+Executable File_Debug Rel To = "Project"
+Executable File_Debug Rel Path = "example_dbg.exe"
+Executable File_Debug Line0001 = "/d/GIT-scilab-master/scilab/scilab/modules/core/examples/call_scilab/c/LabWindow"
+Executable File_Debug Line0002 = "/example_dbg.exe"
+Executable File_Release Is Rel = True
+Executable File_Release Rel To = "Project"
+Executable File_Release Rel Path = "example.exe"
+Executable File_Release Line0001 = "/d/GIT-scilab-master/scilab/scilab/modules/core/examples/call_scilab/c/LabWindow"
+Executable File_Release Line0002 = "/example.exe"
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+DLL Exports = "Include File Symbols"
+DLL Import Library Choice = "Gen Lib For Current Mode"
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+Type Lib Guid = ""
+Runtime Support = "Full Runtime Support"
+Instrument Driver Support Only = False
+Embed Project .UIRs = False
+Generate Map File = False
+
+[External Compiler Support]
+UIR Callbacks File Option = 0
+Using LoadExternalModule = False
+Create Project Symbols File = True
+UIR Callbacks Obj File Is Rel = False
+UIR Callbacks Obj File = ""
+Project Symbols H File Is Rel = False
+Project Symbols H File = ""
+Project Symbols Obj File Is Rel = False
+Project Symbols Obj File = ""
+
+[ActiveX Server Options]
+Specification File Is Rel = False
+Specification File = ""
+Source File Is Rel = False
+Source File = ""
+Include File Is Rel = False
+Include File = ""
+IDL File Is Rel = False
+IDL File = ""
+Register ActiveX Server = False
+
+[Signing Info]
+Sign = False
+Sign Debug Build = False
+Store = ""
+Certificate = ""
+Timestamp URL = ""
+URL = ""
+
+[Manifest Info]
+Embed = False
+
+[tpcSection]
+tpcEnabled = 0
+tpcOverrideEnvironment = 0
+
diff --git a/scilab/modules/core/examples/call_scilab/c/LabWindow/readme.txt b/scilab/modules/core/examples/call_scilab/c/LabWindow/readme.txt
new file mode 100644 (file)
index 0000000..a7fa0c1
--- /dev/null
@@ -0,0 +1,9 @@
+launch example.prj with LabWindow CVI (checked with 8.5.0 (279))
+modify paths to find scilab libraries
+defines PATH
+set PATH=%PATH%;"c:\Program files\scilab-5.1\bin"
+build example with LabWindow CVI
+launch executable (example_debug.exe or example.exe)
+
+Allan CORNET
+DIGITEO 2008
\ No newline at end of file