diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/call_scilab/examples | |
download | scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2 scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip |
CMSCOPE changed
Diffstat (limited to 'modules/call_scilab/examples')
70 files changed, 5600 insertions, 0 deletions
diff --git a/modules/call_scilab/examples/basicExamples/.deps/call_scilab_c_DisableInteractiveMode-DisableInteractiveMode.Po b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_c_DisableInteractiveMode-DisableInteractiveMode.Po new file mode 100755 index 000000000..9ce06a81e --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_c_DisableInteractiveMode-DisableInteractiveMode.Po @@ -0,0 +1 @@ +# dummy diff --git a/modules/call_scilab/examples/basicExamples/.deps/call_scilab_c_getlastjob-GetLastJob.Po b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_c_getlastjob-GetLastJob.Po new file mode 100755 index 000000000..9ce06a81e --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_c_getlastjob-GetLastJob.Po @@ -0,0 +1 @@ +# dummy diff --git a/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwriteboolean-readwriteboolean.Po b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwriteboolean-readwriteboolean.Po new file mode 100755 index 000000000..9ce06a81e --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwriteboolean-readwriteboolean.Po @@ -0,0 +1 @@ +# dummy diff --git a/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwritecomplexmatrix-readwritecomplexmatrix.Po b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwritecomplexmatrix-readwritecomplexmatrix.Po new file mode 100755 index 000000000..9ce06a81e --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwritecomplexmatrix-readwritecomplexmatrix.Po @@ -0,0 +1 @@ +# dummy diff --git a/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwritematrix-readwritematrix.Po b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwritematrix-readwritematrix.Po new file mode 100755 index 000000000..9ce06a81e --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwritematrix-readwritematrix.Po @@ -0,0 +1 @@ +# dummy diff --git a/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwritestring-readwritestring.Po b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwritestring-readwritestring.Po new file mode 100755 index 000000000..9ce06a81e --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/.deps/call_scilab_readwritestring-readwritestring.Po @@ -0,0 +1 @@ +# dummy diff --git a/modules/call_scilab/examples/basicExamples/DisableInteractiveMode.c b/modules/call_scilab/examples/basicExamples/DisableInteractiveMode.c new file mode 100755 index 000000000..81d4f422f --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/DisableInteractiveMode.c @@ -0,0 +1,45 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2009 - Sylvestre LEDRU + * + * This file is released under the 3-clause BSD license. See COPYING-BSD. + * + */ +#include <stdio.h> +#include <string.h> + +#include "call_scilab.h" /* Provide functions to call Scilab engine */ + +/*------------------------------------------------------------*/ +int main(void) +{ +#ifdef _MSC_VER + if ( StartScilab(NULL, NULL, NULL) == FALSE ) +#else + if ( StartScilab(getenv("SCI"), NULL, NULL) == FALSE ) +#endif + { + fprintf(stderr, "Error while calling StartScilab\n"); + return -1; + } + + DisableInteractiveMode(); + int code = SendScilabJob("plot3d()"); /* This will failed since plot3d is + among the disable features*/ + if (code != 0) + { + char lastjob[4096]; + if (GetLastJob(lastjob, 4096)) + { + printf("Failed command: %s\n", lastjob); + } + } + + if ( TerminateScilab(NULL) == FALSE ) + { + fprintf(stderr, "Error while calling TerminateScilab\n"); + return -2; + } + return 0; +} +/*------------------------------------------------------------*/ diff --git a/modules/call_scilab/examples/basicExamples/GetLastJob.c b/modules/call_scilab/examples/basicExamples/GetLastJob.c new file mode 100755 index 000000000..4db3c746d --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/GetLastJob.c @@ -0,0 +1,44 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2009 - Sylvestre LEDRU + * + * This file is released under the 3-clause BSD license. See COPYING-BSD. + * + */ +#include <stdio.h> +#include <string.h> + +#include "call_scilab.h" /* Provide functions to call Scilab engine */ + +/*------------------------------------------------------------*/ +int main(void) +{ +#ifdef _MSC_VER + if ( StartScilab(NULL, NULL, NULL) == FALSE ) +#else + if ( StartScilab(getenv("SCI"), NULL, NULL) == FALSE ) +#endif + { + fprintf(stderr, "Error while calling StartScilab\n"); + return -1; + } + + + int code = SendScilabJob("failedMyCurrentJob=%pi*3/0"); + if (code != 0) + { + char lastjob[4096]; + if (GetLastJob(lastjob, 4096)) + { + printf("Failed command: %s\n", lastjob); + } + } + + if ( TerminateScilab(NULL) == FALSE ) + { + fprintf(stderr, "Error while calling TerminateScilab\n"); + return -2; + } + return 0; +} +/*------------------------------------------------------------*/ diff --git a/modules/call_scilab/examples/basicExamples/readwriteboolean.c b/modules/call_scilab/examples/basicExamples/readwriteboolean.c new file mode 100755 index 000000000..0f095711d --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwriteboolean.c @@ -0,0 +1,182 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2009 - Sylvestre LEDRU + * + * This file is released under the 3-clause BSD license. See COPYING-BSD. + * + * This example shows how to read / write a matrix of boolean from Scilab + * engine + * + * This example works from Scilab 5.2 + * but the previous way of doing is also described as comment + */ +#include <math.h> +#include <stdio.h> +#include <stdlib.h> /* malloc */ +#include "api_scilab.h" +#include "call_scilab.h" /* Provide functions to call Scilab engine */ + +/*------------------------------------------------------------*/ +int main(void) +{ +#ifdef _MSC_VER + if ( StartScilab(NULL, NULL, 0) == FALSE ) +#else + if ( StartScilab(getenv("SCI"), NULL, 0) == FALSE ) +#endif + { + fprintf(stderr, "Error while calling StartScilab\n"); + return -1; + } + + /******************************** WRITE ****************************/ + + /* + * Write a line matrix of boolean into Scilab + * A=[ T F F T ]; + */ + { + int A[] = {1, 0, 0, 1}; /* Declare the matrix */ + /* NOTE that it is an array of int and not an array of double */ + int rowA = 1, colA = 4; /* Size of the matrix */ + char variableName[] = "A"; + SciErr sciErr; + + /* + Write it into Scilab's memory + */ + sciErr = createNamedMatrixOfBoolean(pvApiCtx, variableName, rowA, colA, A); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + printf("Display from Scilab of A:\n"); + SendScilabJob("disp(A);"); /* Display A */ + } + + /* + * Write a matrix into Scilab + * B=[F F T F; + * F F F T ] + * Note that it is done column by column + */ + { + int B[] = {0, 0, 0, 0, 1, 0, 0, 1}; /* Declare the matrix */ + int rowB = 2, colB = 4; /* Size of the matrix */ + char variableNameB[] = "B"; + SciErr sciErr; + + /* Write it into Scilab's memory */ + sciErr = createNamedMatrixOfBoolean(pvApiCtx, variableNameB, rowB, colB, B); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + + printf("\n"); + printf("Display from Scilab of B:\n"); + SendScilabJob("disp(B);"); /* Display B */ + } + + /******************************** READ ****************************/ + + /* Load the previously set variable A */ + { + int rowA_ = 0, colA_ = 0, lp = 0; + int i = 0; + int *matrixOfBoolean = NULL; /* Int instead of double */ + + char variableToBeRetrieved[] = "A"; + SciErr sciErr; + + /* First, retrieve the size of the matrix */ + sciErr = readNamedMatrixOfBoolean(pvApiCtx, variableToBeRetrieved, &rowA_, &colA_, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfBoolean = (int*)malloc((rowA_ * colA_) * sizeof(int)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfBoolean(pvApiCtx, variableToBeRetrieved, &rowA_, &colA_, matrixOfBoolean); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + printf("\n"); + printf("Display from A (size: %d, %d):\n", rowA_, colA_); + for (i = 0; i < rowA_ * colA_; i++) + { + fprintf(stdout, "A[%d] = %d\n", i, matrixOfBoolean[i]); + } + + if (matrixOfBoolean) + { + free(matrixOfBoolean); + matrixOfBoolean = NULL; + } + } + + /* Load the previously set variable B */ + { + int rowB_ = 0, colB_ = 0, lp_ = 0; + int i = 0, j = 0; + int *matrixOfBooleanB = NULL; /* Int instead of double */ + + char variableToBeRetrievedB[] = "B"; + SciErr sciErr; + + /* First, retrieve the size of the matrix */ + sciErr = readNamedMatrixOfBoolean(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, NULL); + + /* Alloc the memory */ + matrixOfBooleanB = (int*)malloc((rowB_ * colB_) * sizeof(int)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfBoolean(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, matrixOfBooleanB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + printf("\n"); + printf("Display from B raw (size: %d, %d):\n", rowB_, colB_); + for (i = 0; i < rowB_ * colB_; i++) + { + /* Display the raw matrix */ + fprintf(stdout, "B[%d] = %d\n", i, matrixOfBooleanB[i]); + } + + printf("\n"); + printf("Display from B formated (size: %d, %d):\n", rowB_, colB_); + for (j = 0 ; j < rowB_ ; j++) + { + for (i = 0 ; i < colB_ ; i++) + { + /* Display the formated matrix ... the way the user + * expect */ + printf("%d ", matrixOfBooleanB[i * rowB_ + j]); + } + printf("\n"); /* New row of the matrix */ + } + + if (matrixOfBooleanB) + { + free(matrixOfBooleanB); + matrixOfBooleanB = NULL; + } + } + + + if ( TerminateScilab(NULL) == FALSE ) + { + fprintf(stderr, "Error while calling TerminateScilab\n"); + return -2; + } + return 0; +} diff --git a/modules/call_scilab/examples/basicExamples/readwriteboolean_vc/readwriteboolean.sln b/modules/call_scilab/examples/basicExamples/readwriteboolean_vc/readwriteboolean.sln new file mode 100755 index 000000000..0cd4d2562 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwriteboolean_vc/readwriteboolean.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "readwriteboolean", "readwriteboolean.vcxproj", "{B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}.Debug|Win32.ActiveCfg = Debug|Win32 + {B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}.Debug|Win32.Build.0 = Debug|Win32 + {B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}.Debug|x64.ActiveCfg = Debug|x64 + {B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}.Debug|x64.Build.0 = Debug|x64 + {B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}.Release|Win32.ActiveCfg = Release|Win32 + {B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}.Release|Win32.Build.0 = Release|Win32 + {B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}.Release|x64.ActiveCfg = Release|x64 + {B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/modules/call_scilab/examples/basicExamples/readwriteboolean_vc/readwriteboolean.vcxproj b/modules/call_scilab/examples/basicExamples/readwriteboolean_vc/readwriteboolean.vcxproj new file mode 100755 index 000000000..df1b13651 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwriteboolean_vc/readwriteboolean.vcxproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{B6DB2C8F-6D2C-4F78-BC21-3692D9A0C7F7}</ProjectGuid> + <RootNamespace>readwriteboolean</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.31118.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwriteboolean.exe</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)readwriteboolean.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> +<TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwriteboolean.exe</OutputFile> + <IgnoreSpecificDefaultLibraries>libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)readwriteboolean.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> +<TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwriteboolean.exe</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> +<TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwriteboolean.exe</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> +<TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\readwriteboolean.c" /> + </ItemGroup> + <ItemGroup> + <Library Include="..\..\..\..\..\bin\api_scilab.lib" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/basicExamples/readwriteboolean_vc/readwriteboolean.vcxproj.filters b/modules/call_scilab/examples/basicExamples/readwriteboolean_vc/readwriteboolean.vcxproj.filters new file mode 100755 index 000000000..6e3654a13 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwriteboolean_vc/readwriteboolean.vcxproj.filters @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\readwriteboolean.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <Library Include="..\..\..\..\..\bin\api_scilab.lib" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix.c b/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix.c new file mode 100755 index 000000000..569b6c52a --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix.c @@ -0,0 +1,217 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2009 - Sylvestre LEDRU + * + * This file is released under the 3-clause BSD license. See COPYING-BSD. + * + * This example shows how to read / write a matrix of complex from Scilab + * engine + */ +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "api_scilab.h" +#include "call_scilab.h" /* Provide functions to call Scilab engine */ +/*------------------------------------------------------------*/ +int main(void) +{ +#ifdef _MSC_VER + if ( StartScilab(NULL, NULL, 0) == FALSE ) +#else + if ( StartScilab(getenv("SCI"), NULL, 0) == FALSE ) +#endif + { + fprintf(stderr, "Error while calling StartScilab\n"); + return -1; + } + + /******************************** WRITE ****************************/ + /* + * Write a line complex matrix into Scilab + * A=[ 1+%i 3 3+7*%i 2-2*%i ]; + */ + { + /* Declare the complex matrix */ + double A[] = {1, 3, 3, 2}; + double A_img[] = {1, 0, 7, -2}; + + int rowA = 1, colA = 4; /* Size of the complex matrix + * (note that colA = sizeof(A)/2 + */ + char variableName[] = "A"; + SciErr sciErr; + + /* Write it into Scilab's memory */ + sciErr = createNamedComplexMatrixOfDouble(pvApiCtx, variableName, rowA, colA, A, A_img); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + printf("Display from Scilab of A:\n"); + SendScilabJob("disp(A);"); /* Display A */ + } + + /* + * Write a matrix into Scilab + * B=[1+%i 4-%i 2+1/2*%i 3; + * 3 9 8+42*%i 2 ] + * Note that it is done column by column + */ + { + + double B[] = {1, 3, 4, 9, 2, 8, 3, 2}; + double B_img[] = {1, 0.233, -1, -0.2, 0.5, 42, -23, 123}; /* Declare the matrix */ + + int rowB = 2, colB = 4; /* Size of the matrix */ + char variableNameB[] = "B"; + SciErr sciErr; + + /* Write it into Scilab's memory */ + sciErr = createNamedComplexMatrixOfDouble(pvApiCtx, variableNameB, rowB, colB, B, B_img); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + printf("\n"); + printf("Display from Scilab of B:\n"); + SendScilabJob("disp(B);"); /* Display B */ + } + + + /******************************** READ ****************************/ + + /* Load the previously set variable A */ + { + int rowA_ = 0, colA_ = 0, lp = 0; + int i = 0, j = 0; + double *matrixOfComplex = NULL; + double *matrixOfComplex_img = NULL; + + char variableToBeRetrieved[] = "A"; + SciErr sciErr; + + /* First, retrieve the size of the matrix */ + sciErr = readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrieved, &rowA_, &colA_, NULL, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfComplex = (double*)malloc((rowA_ * colA_ * 2) * sizeof(double)); + matrixOfComplex_img = (double*)malloc((rowA_ * colA_ * 2) * sizeof(double)); + + /* Load the matrix */ + sciErr = readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrieved, &rowA_, &colA_, matrixOfComplex, matrixOfComplex_img); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + + printf("\n"); + printf("Display raw A (size: %d, %d):\n", rowA_, colA_); + for (i = 0; i < rowA_ * colA_ * 2; i++) /* *2 is because complex part is store + * at the end + */ + { + fprintf(stdout, "A[%d] = %5.2f\n", i, matrixOfComplex[i]); + } + + printf("\n"); + printf("Display formated A (size: %d, %d):\n", rowA_, colA_); + for (i = 0; i < rowA_ * colA_; i++) + { + fprintf(stdout, "%5.2f + %5.2f.i ", matrixOfComplex[i], matrixOfComplex[i + colA_]); + } + printf("\n"); + + if (matrixOfComplex) + { + free(matrixOfComplex); + matrixOfComplex = NULL; + } + } + + /* Load the previously set variable B */ + { + int rowB_ = 0, colB_ = 0, lp_ = 0; + int i = 0, j = 0; + + double *matrixOfComplexB = NULL; + double *matrixOfComplexB_img = NULL; + char variableToBeRetrievedB[] = "B"; + SciErr sciErr; + /* First, retrieve the size of the matrix */ + + sciErr = readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, NULL, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + + /* Alloc the memory */ + matrixOfComplexB = (double*)malloc((rowB_ * colB_) * sizeof(double)); + matrixOfComplexB_img = (double*)malloc((rowB_ * colB_) * sizeof(double)); + + /* Load the matrix */ + sciErr = readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, matrixOfComplexB, matrixOfComplexB_img); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + + printf("\n"); + printf("Display from B raw - real part (size: %d, %d):\n", rowB_, colB_); + for (i = 0; i < rowB_ * colB_; i++) /* *2 is because complex part is store + * at the end + */ + { + /* Display the raw matrix */ + fprintf(stdout, "B[%d] = %5.2f\n", i, matrixOfComplexB[i]); + } + printf("Display from B raw - imaginary part (size: %d, %d):\n", rowB_, colB_); + for (i = 0; i < rowB_ * colB_; i++) /* *2 is because complex part is store + * at the end + */ + { + /* Display the raw matrix */ + fprintf(stdout, "B[%d] = %5.2f\n", i, matrixOfComplexB_img[i]); + } + + printf("\n"); + printf("Display from B formated (size: %d, %d):\n", rowB_, colB_); + for (j = 0 ; j < rowB_ ; j++) + { + for (i = 0 ; i < colB_ ; i++) + { + /* Display the formated matrix ... the way the user + * expect */ + printf("%5.2f + %5.2f.i ", matrixOfComplexB[i * rowB_ + j], matrixOfComplexB_img[i * rowB_ + j]); + } + printf("\n"); /* New row of the matrix */ + } + + if (matrixOfComplexB) + { + free(matrixOfComplexB); + matrixOfComplexB = NULL; + } + if (matrixOfComplexB_img) + { + free(matrixOfComplexB_img); + matrixOfComplexB_img = NULL; + } + } + + if ( TerminateScilab(NULL) == FALSE ) + { + fprintf(stderr, "Error while calling TerminateScilab\n"); + return -2; + } + return 0; +} diff --git a/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix_vc/readwritecomplexmatrix.sln b/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix_vc/readwritecomplexmatrix.sln new file mode 100755 index 000000000..22af0684e --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix_vc/readwritecomplexmatrix.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "readwritecomplexmatrix", "readwritecomplexmatrix.vcxproj", "{A82BBD7C-42F0-449E-BD28-58F3784543F9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A82BBD7C-42F0-449E-BD28-58F3784543F9}.Debug|Win32.ActiveCfg = Debug|Win32 + {A82BBD7C-42F0-449E-BD28-58F3784543F9}.Debug|Win32.Build.0 = Debug|Win32 + {A82BBD7C-42F0-449E-BD28-58F3784543F9}.Debug|x64.ActiveCfg = Debug|x64 + {A82BBD7C-42F0-449E-BD28-58F3784543F9}.Debug|x64.Build.0 = Debug|x64 + {A82BBD7C-42F0-449E-BD28-58F3784543F9}.Release|Win32.ActiveCfg = Release|Win32 + {A82BBD7C-42F0-449E-BD28-58F3784543F9}.Release|Win32.Build.0 = Release|Win32 + {A82BBD7C-42F0-449E-BD28-58F3784543F9}.Release|x64.ActiveCfg = Release|x64 + {A82BBD7C-42F0-449E-BD28-58F3784543F9}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix_vc/readwritecomplexmatrix.vcxproj b/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix_vc/readwritecomplexmatrix.vcxproj new file mode 100755 index 000000000..0080d168b --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix_vc/readwritecomplexmatrix.vcxproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{A82BBD7C-42F0-449E-BD28-58F3784543F9}</ProjectGuid> + <RootNamespace>readwritecomplexmatrix</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.31118.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritecomplexmatrix.exe</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)readwritecomplexmatrix.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> +<TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritecomplexmatrix.exe</OutputFile> + <IgnoreSpecificDefaultLibraries>libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)readwritecomplexmatrix.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> +<TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritecomplexmatrix.exe</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> +<TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritecomplexmatrix.exe</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> +<TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\readwritecomplexmatrix.c" /> + </ItemGroup> + <ItemGroup> + <Library Include="..\..\..\..\..\bin\api_scilab.lib" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix_vc/readwritecomplexmatrix.vcxproj.filters b/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix_vc/readwritecomplexmatrix.vcxproj.filters new file mode 100755 index 000000000..c8f5cc926 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix_vc/readwritecomplexmatrix.vcxproj.filters @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\readwritecomplexmatrix.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <Library Include="..\..\..\..\..\bin\api_scilab.lib" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/basicExamples/readwritematrix.c b/modules/call_scilab/examples/basicExamples/readwritematrix.c new file mode 100755 index 000000000..7d965eea8 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritematrix.c @@ -0,0 +1,186 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2009 - Sylvestre LEDRU + * + * This file is released under the 3-clause BSD license. See COPYING-BSD. + * + * This example shows how to read / write a matrix from Scilab engine + * + * This example works from Scilab 5.2 + * but the previous way of doing is also described as comment + */ +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include "api_scilab.h" +#include "call_scilab.h" /* Provide functions to call Scilab engine */ + +/*------------------------------------------------------------*/ +int main(void) +{ +#ifdef _MSC_VER + if ( StartScilab(NULL, NULL, 0) == FALSE ) +#else + if ( StartScilab(getenv("SCI"), NULL, 0) == FALSE ) +#endif + { + fprintf(stderr, "Error while calling StartScilab\n"); + return -1; + } + + /******************************** WRITE ****************************/ + + /* + * Write a line matrix into Scilab + * A=[ 1 3 3 2 ]; + */ + { + double A[] = {1, 3, 3, 2}; /* Declare the matrix */ + int rowA = 1, colA = 4; /* Size of the matrix */ + char variableName[] = "A"; + SciErr sciErr; + + /* + * Write it into Scilab's memory + */ + sciErr = createNamedMatrixOfDouble(pvApiCtx, variableName, rowA, colA, A); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + printf("Display from Scilab of A:\n"); + SendScilabJob("disp(A);"); /* Display A */ + } + + /* + * Write a matrix into Scilab + * B=[1 4 2 3; + * 3 9 8 2 ] + * Note that it is done column by column + */ + { + double B[] = {1, 3, 4, 9, 2, 8, 3, 2}; /* Declare the matrix */ + int rowB = 2, colB = 4; /* Size of the matrix */ + char variableNameB[] = "B"; + SciErr sciErr; + + /* + * Write it into Scilab's memory + */ + sciErr = createNamedMatrixOfDouble(pvApiCtx, variableNameB, rowB, colB, B); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + printf("\n"); + printf("Display from Scilab of B:\n"); + SendScilabJob("disp(B);"); /* Display B */ + } + + /******************************** READ ****************************/ + + /* Load the previously set variable A */ + { + int rowA_ = 0, colA_ = 0, lp = 0; + int i = 0, j = 0; + double *matrixOfDouble = NULL; + + char variableToBeRetrieved[] = "A"; + SciErr sciErr; + + /* First, retrieve the size of the matrix */ + sciErr = readNamedMatrixOfDouble(pvApiCtx, variableToBeRetrieved, &rowA_, &colA_, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfDouble = (double*)malloc((rowA_ * colA_) * sizeof(double)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfDouble(pvApiCtx, variableToBeRetrieved, &rowA_, &colA_, matrixOfDouble); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + printf("\n"); + printf("Display from A (size: %d, %d):\n", rowA_, colA_); + for (i = 0; i < rowA_ * colA_; i++) + { + fprintf(stdout, "A[%d] = %5.2f\n", i, matrixOfDouble[i]); + } + + if (matrixOfDouble) + { + free(matrixOfDouble); + matrixOfDouble = NULL; + } + } + + + /* Load the previously set variable B */ + { + int rowB_ = 0, colB_ = 0, lp_ = 0; + double *matrixOfDoubleB = NULL; + int i = 0, j = 0; + + char variableToBeRetrievedB[] = "B"; + SciErr sciErr; + + /* First, retrieve the size of the matrix */ + sciErr = readNamedMatrixOfDouble(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfDoubleB = (double*)malloc((rowB_ * colB_) * sizeof(double)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfDouble(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, matrixOfDoubleB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + printf("\n"); + printf("Display from B raw (size: %d, %d):\n", rowB_, colB_); + for (i = 0; i < rowB_ * colB_; i++) + { + /* Display the raw matrix */ + fprintf(stdout, "B[%d] = %5.2f\n", i, matrixOfDoubleB[i]); + } + + printf("\n"); + printf("Display from B formated (size: %d, %d):\n", rowB_, colB_); + for (j = 0 ; j < rowB_ ; j++) + { + for (i = 0 ; i < colB_ ; i++) + { + /* Display the formated matrix ... the way the user + * expect */ + printf("%5.2f ", matrixOfDoubleB[i * rowB_ + j]); + } + printf("\n"); /* New row of the matrix */ + } + + if (matrixOfDoubleB) + { + free(matrixOfDoubleB); + matrixOfDoubleB = NULL; + } + } + + + if ( TerminateScilab(NULL) == FALSE ) + { + fprintf(stderr, "Error while calling TerminateScilab\n"); + return -2; + } + return 0; +} diff --git a/modules/call_scilab/examples/basicExamples/readwritestring.c b/modules/call_scilab/examples/basicExamples/readwritestring.c new file mode 100755 index 000000000..8b2933851 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritestring.c @@ -0,0 +1,218 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2009 - Sylvestre Ledru + * + * This file is released under the 3-clause BSD license. See COPYING-BSD. + * + * This example shows how to read / write a matrix of string from Scilab engine + */ +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "api_scilab.h" +#include "call_scilab.h" /* Provide functions to call Scilab engine */ + +/*------------------------------------------------------------*/ +int main(void) +{ +#ifdef _MSC_VER + if ( StartScilab(NULL, NULL, 0) == FALSE ) +#else + if ( StartScilab(getenv("SCI"), NULL, 0) == FALSE ) +#endif + { + fprintf(stderr, "Error while calling StartScilab\n"); + return -1; + } + + /******************************** WRITE ****************************/ + + /* + * Write a single string into Scilab + * A="my Message"; + */ + { + SciErr sciErr; + + int row = 2, col = 1; /* Size of the matrix */ + /* Declare the string */ + char **myMatrixOfString = (char**)malloc(sizeof(char*) * row * col); + char variableName[] = "A"; + myMatrixOfString[0] = "my Message"; + myMatrixOfString[1] = "on two lines"; + + /* Write it into Scilab's memory */ + sciErr = createNamedMatrixOfString(pvApiCtx, variableName, row, col, myMatrixOfString); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + printf("Display from Scilab of A:\n"); + SendScilabJob("disp(A);"); /* Display A */ + } + + { + /* + * Write a matrix into Scilab + * B=['My' 'Great' ; + * 'String' ';)' ] + * Note that it is done column by column + */ + int row = 2, col = 2; /* Size of the matrix */ + /* Declare the string */ + char **myMatrixOfStringB = (char**)malloc(sizeof(char*) * row * col); + char variableNameB[] = "B"; + SciErr sciErr; + + printf("\n"); + + myMatrixOfStringB[0] = "My"; + myMatrixOfStringB[1] = "String"; + myMatrixOfStringB[2] = "Great"; + myMatrixOfStringB[3] = ";)"; + + sciErr = createNamedMatrixOfString(pvApiCtx, variableNameB, row, col, myMatrixOfStringB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + + printf("\n"); + printf("Display from Scilab of B:\n"); + SendScilabJob("disp(B);"); /* Display B */ + } + /******************************** READ ****************************/ + + /* Load the previously set variable A */ + { + + char variableToBeRetrieved[] = "A"; + int iRows = 0; + int iCols = 0; + int i, j; + int* piAddr = NULL; + int* piLen = NULL; + char** pstData = NULL; + SciErr sciErr; + + //first call to retrieve dimensions + sciErr = readNamedMatrixOfString(pvApiCtx, variableToBeRetrieved, &iRows, &iCols, NULL, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + piLen = (int*)malloc(sizeof(int) * iRows * iCols); + //second call to retrieve length of each string + sciErr = readNamedMatrixOfString(pvApiCtx, variableToBeRetrieved, &iRows, &iCols, piLen, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + pstData = (char**)malloc(sizeof(char*) * iRows * iCols); + for (i = 0 ; i < iRows * iCols ; i++) + { + pstData[i] = (char*)malloc(sizeof(char) * (piLen[i] + 1));//+ 1 for null termination + } + //third call to retrieve data + sciErr = readNamedMatrixOfString(pvApiCtx, variableToBeRetrieved, &iRows, &iCols, piLen, pstData); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + + printf("\n"); + printf("Load and display of A:\n"); + for (j = 0 ; j < iCols ; j++) + { + for (i = 0 ; i < iRows ; i++) + { + /* Display the formated matrix with same scilab indice */ + printf("[%d,%d] = %s\n", j + 1, i + 1, pstData[j * iRows + i]); + } + } + + printf("\n"); + free(piLen); + for (i = 0 ; i < iRows * iCols ; i++) + { + free(pstData[i]); + } + free(pstData); + + } + + + /* Load an element of the previously set variable B */ + { + + char variableToBeRetrieved[] = "B"; + int iRows = 0; + int iCols = 0; + int i, j; + int* piAddr = NULL; + int* piLen = NULL; + char** pstData = NULL; + SciErr sciErr; + + //first call to retrieve dimensions + sciErr = readNamedMatrixOfString(pvApiCtx, variableToBeRetrieved, &iRows, &iCols, NULL, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + piLen = (int*)malloc(sizeof(int) * iRows * iCols); + //second call to retrieve length of each string + sciErr = readNamedMatrixOfString(pvApiCtx, variableToBeRetrieved, &iRows, &iCols, piLen, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + pstData = (char**)malloc(sizeof(char*) * iRows * iCols); + for (i = 0 ; i < iRows * iCols ; i++) + { + pstData[i] = (char*)malloc(sizeof(char) * (piLen[i] + 1));//+ 1 for null termination + } + //third call to retrieve data + sciErr = readNamedMatrixOfString(pvApiCtx, variableToBeRetrieved, &iRows, &iCols, piLen, pstData); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + + printf("\n"); + printf("Load and display of B:\n"); + for (j = 0 ; j < iCols ; j++) + { + for (i = 0 ; i < iRows ; i++) + { + /* Display the formated matrix with same scilab indice */ + printf("[%d,%d] = %s\n", j + 1, i + 1, pstData[j * iRows + i]); + } + } + + printf("\n"); + free(piLen); + for (i = 0 ; i < iRows * iCols ; i++) + { + free(pstData[i]); + } + free(pstData); + + } + + if ( TerminateScilab(NULL) == FALSE ) + { + fprintf(stderr, "Error while calling TerminateScilab\n"); + return -2; + } + return 0; +} diff --git a/modules/call_scilab/examples/basicExamples/readwritewmatrix_vc/readwritematrix.sln b/modules/call_scilab/examples/basicExamples/readwritewmatrix_vc/readwritematrix.sln new file mode 100755 index 000000000..1222f1ffb --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritewmatrix_vc/readwritematrix.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "readwritematrix", "readwritematrix.vcxproj", "{1BCA5407-8617-4797-8412-8B76C4359144}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1BCA5407-8617-4797-8412-8B76C4359144}.Debug|Win32.ActiveCfg = Debug|Win32 + {1BCA5407-8617-4797-8412-8B76C4359144}.Debug|Win32.Build.0 = Debug|Win32 + {1BCA5407-8617-4797-8412-8B76C4359144}.Debug|x64.ActiveCfg = Debug|x64 + {1BCA5407-8617-4797-8412-8B76C4359144}.Debug|x64.Build.0 = Debug|x64 + {1BCA5407-8617-4797-8412-8B76C4359144}.Release|Win32.ActiveCfg = Release|Win32 + {1BCA5407-8617-4797-8412-8B76C4359144}.Release|Win32.Build.0 = Release|Win32 + {1BCA5407-8617-4797-8412-8B76C4359144}.Release|x64.ActiveCfg = Release|x64 + {1BCA5407-8617-4797-8412-8B76C4359144}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/modules/call_scilab/examples/basicExamples/readwritewmatrix_vc/readwritematrix.vcxproj b/modules/call_scilab/examples/basicExamples/readwritewmatrix_vc/readwritematrix.vcxproj new file mode 100755 index 000000000..eaaf6bde9 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritewmatrix_vc/readwritematrix.vcxproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{1BCA5407-8617-4797-8412-8B76C4359144}</ProjectGuid> + <RootNamespace>readwritematrix</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.31118.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritematrix.exe</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)readwritematrix.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> +<TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritematrix.exe</OutputFile> + <IgnoreSpecificDefaultLibraries>libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)readwritematrix.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> +<TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritematrix.exe</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> +<TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritematrix.exe</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> +<TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\readwritematrix.c" /> + </ItemGroup> + <ItemGroup> + <Library Include="..\..\..\..\..\bin\api_scilab.lib" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/basicExamples/readwritewmatrix_vc/readwritematrix.vcxproj.filters b/modules/call_scilab/examples/basicExamples/readwritewmatrix_vc/readwritematrix.vcxproj.filters new file mode 100755 index 000000000..f7b8e640b --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritewmatrix_vc/readwritematrix.vcxproj.filters @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\readwritematrix.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <Library Include="..\..\..\..\..\bin\api_scilab.lib" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/basicExamples/readwritewtring_vc/readwritestring.sln b/modules/call_scilab/examples/basicExamples/readwritewtring_vc/readwritestring.sln new file mode 100755 index 000000000..beb639297 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritewtring_vc/readwritestring.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "readwritestring", "readwritestring.vcxproj", "{39D444F3-1750-4E98-B345-7EBDC1D2E080}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {39D444F3-1750-4E98-B345-7EBDC1D2E080}.Debug|Win32.ActiveCfg = Debug|Win32 + {39D444F3-1750-4E98-B345-7EBDC1D2E080}.Debug|Win32.Build.0 = Debug|Win32 + {39D444F3-1750-4E98-B345-7EBDC1D2E080}.Debug|x64.ActiveCfg = Debug|x64 + {39D444F3-1750-4E98-B345-7EBDC1D2E080}.Debug|x64.Build.0 = Debug|x64 + {39D444F3-1750-4E98-B345-7EBDC1D2E080}.Release|Win32.ActiveCfg = Release|Win32 + {39D444F3-1750-4E98-B345-7EBDC1D2E080}.Release|Win32.Build.0 = Release|Win32 + {39D444F3-1750-4E98-B345-7EBDC1D2E080}.Release|x64.ActiveCfg = Release|x64 + {39D444F3-1750-4E98-B345-7EBDC1D2E080}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/modules/call_scilab/examples/basicExamples/readwritewtring_vc/readwritestring.vcxproj b/modules/call_scilab/examples/basicExamples/readwritewtring_vc/readwritestring.vcxproj new file mode 100755 index 000000000..dcfa87560 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritewtring_vc/readwritestring.vcxproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{39D444F3-1750-4E98-B345-7EBDC1D2E080}</ProjectGuid> + <RootNamespace>readwritestring</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.31118.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritestring.exe</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)readwritestring.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> +<TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritestring.exe</OutputFile> + <IgnoreSpecificDefaultLibraries>libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)readwritestring.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> +<TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritestring.exe</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> +<TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>../../../../core/includes;../../../includes;../../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <ObjectFileName>$(Configuration)/</ObjectFileName> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalDependencies>../../../../../bin/core.lib;../../../../../bin/call_scilab.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>../../../../../bin/readwritestring.exe</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> +<TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\readwritestring.c" /> + </ItemGroup> + <ItemGroup> + <Library Include="..\..\..\..\..\bin\api_scilab.lib" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/basicExamples/readwritewtring_vc/readwritestring.vcxproj.filters b/modules/call_scilab/examples/basicExamples/readwritewtring_vc/readwritestring.vcxproj.filters new file mode 100755 index 000000000..10172dc45 --- /dev/null +++ b/modules/call_scilab/examples/basicExamples/readwritewtring_vc/readwritestring.vcxproj.filters @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\readwritestring.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <Library Include="..\..\..\..\..\bin\api_scilab.lib" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/call_scilab/NET/C#/DotNetScilab.sln b/modules/call_scilab/examples/call_scilab/NET/C#/DotNetScilab.sln new file mode 100755 index 000000000..e1b1cb83b --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/C#/DotNetScilab.sln @@ -0,0 +1,46 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetScilab", "dotnetsci\DotNetScilab.csproj", "{C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs_example", "cs_example\cs_example.csproj", "{10B5A5BF-3204-4B47-91C0-7FA614EFA94A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Debug|x64.ActiveCfg = Debug|x64 + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Debug|x64.Build.0 = Debug|x64 + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Debug|x86.ActiveCfg = Debug|x86 + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Debug|x86.Build.0 = Debug|x86 + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Release|Any CPU.Build.0 = Release|Any CPU + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Release|x64.ActiveCfg = Release|x64 + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Release|x64.Build.0 = Release|x64 + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Release|x86.ActiveCfg = Release|x86 + {C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}.Release|x86.Build.0 = Release|x86 + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Debug|x64.ActiveCfg = Debug|x64 + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Debug|x64.Build.0 = Debug|x64 + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Debug|x86.ActiveCfg = Debug|x86 + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Debug|x86.Build.0 = Debug|x86 + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Release|Any CPU.Build.0 = Release|Any CPU + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Release|x64.ActiveCfg = Release|x64 + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Release|x64.Build.0 = Release|x64 + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Release|x86.ActiveCfg = Release|x86 + {10B5A5BF-3204-4B47-91C0-7FA614EFA94A}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/modules/call_scilab/examples/call_scilab/NET/C#/cs_example/Properties/AssemblyInfo.cs b/modules/call_scilab/examples/call_scilab/NET/C#/cs_example/Properties/AssemblyInfo.cs new file mode 100755 index 000000000..61c6d3312 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/C#/cs_example/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("example")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Scilab - DIGITEO")] +[assembly: AssemblyProduct("example")] +[assembly: AssemblyCopyright("Copyright © Scilab 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("17e29de2-0c66-420c-931c-662ab2883fb8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/modules/call_scilab/examples/call_scilab/NET/C#/cs_example/cs_example.cs b/modules/call_scilab/examples/call_scilab/NET/C#/cs_example/cs_example.cs new file mode 100755 index 000000000..ce4500736 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/C#/cs_example/cs_example.cs @@ -0,0 +1,294 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2009 - DIGITEO - Allan CORNET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +//============================================================================= +using System; +using System.Collections.Generic; +using System.Text; +using DotNetScilab; +//============================================================================= +namespace example +{ + class cs_example + { + //============================================================================= + /* + * A small example to call scilab from C# + * read & write matrix of double, string, boolean, int(32) + */ + static void example_readwriteMatrixOfDouble(Scilab _objScilab) + { + //============================================================================= + // Send a command to scilab + // Here , we want to display SCI variable + _objScilab.SendScilabJob("disp(\'SCI = \');"); + _objScilab.SendScilabJob("disp(SCI);"); + //============================================================================= + double[] A = new double[] { 1, 2, 3, 4, 5, 6 }; + int mA = 2, nA = 3; + + // Write a matrix of double named in scilab + _objScilab.createNamedMatrixOfDouble("A", mA, nA, A); + + // display matrix of double by scilab + _objScilab.SendScilabJob("disp(\'A =\');"); + _objScilab.SendScilabJob("disp(A);"); + //============================================================================= + if (_objScilab.getNamedVarType("A") == (int)DotNetScilab.ScilabType.sci_matrix) + { + Console.WriteLine("A is a matrix of double"); + } + //============================================================================= + _objScilab.SendScilabJob("B = A + 1;"); + + // get dimensions of a named matrix of double + int[] DimB = _objScilab.getNamedVarDimension("B"); + + // get named matrix of double + double[] B = _objScilab.readNamedMatrixOfDouble("B"); + + // display matrix of double from C# + Console.WriteLine(""); + Console.WriteLine("(C#) B ="); + for (int i = 0; i < DimB[0]; i++) + { + for (int j = 0; j < DimB[1]; j++) + { + Console.Write(B[j * DimB[0] + i] + " "); + } + + Console.WriteLine(""); + } + + // display matrix of double by scilab + _objScilab.SendScilabJob("disp(\'B =\');"); + _objScilab.SendScilabJob("disp(B);"); + //============================================================================= + } + //============================================================================= + static void example_readwriteMatrixOfString(Scilab _objScilab) + { + //============================================================================= + string[] strA = new string[] { "Scilab", "The", "open", + "source", "for", "numerical", + "computation" , ":", ")"}; + int mstrA = 3, nstrA = 3; + + // Write a matrix of string named in scilab + _objScilab.createNamedMatrixOfString("string_A", mstrA, nstrA, strA); + + // display matrix of string by scilab + _objScilab.SendScilabJob("disp(\'string_A =\');"); + _objScilab.SendScilabJob("disp(string_A);"); + //============================================================================= + if (_objScilab.getNamedVarType("string_A") == (int)DotNetScilab.ScilabType.sci_strings) + { + Console.WriteLine("string_A is a matrix of strings"); + } + //============================================================================= + _objScilab.SendScilabJob("string_B = convstr(string_A,\'u\');"); + + // get dimensions of a named matrix of string + int[] DimstrB = _objScilab.getNamedVarDimension("string_B"); + + // get named matrix of string + string[] strB = _objScilab.readNamedMatrixOfString("string_B"); + + Console.WriteLine(""); + Console.WriteLine("(C#) strB ="); + for (int i = 0; i < DimstrB[0]; i++) + { + for (int j = 0; j < DimstrB[1]; j++) + { + Console.Write(strB[j * DimstrB[0] + i] + " "); + } + + Console.WriteLine(""); + } + + // display matrix of string by scilab + _objScilab.SendScilabJob("disp(\'string_B =\');"); + _objScilab.SendScilabJob("disp(string_B);"); + //============================================================================= + } + //============================================================================= + static void example_readwriteMatrixOfBoolean(Scilab _objScilab) + { + //============================================================================= + Boolean[] bA = new Boolean[] { false, true, false, + true, false, true}; + int mbA = 2, nbA = 3; + + // Write a matrix of string named in scilab + _objScilab.createNamedMatrixOfBoolean("boolean_A", mbA, nbA, bA); + + // display matrix of string by scilab + _objScilab.SendScilabJob("disp(\'boolean_A =\');"); + _objScilab.SendScilabJob("disp(boolean_A);"); + //============================================================================= + // check if av + if (_objScilab.existNamedVariable("boolean_A") == true) + { + Console.WriteLine("boolean_A exists in scilab"); + } + + if (_objScilab.existNamedVariable("boolean_B") == false) + { + Console.WriteLine("boolean_B does not exist in scilab"); + } + //============================================================================= + if (_objScilab.getNamedVarType("boolean_A") == (int)DotNetScilab.ScilabType.sci_boolean) + { + Console.WriteLine("boolean_A is a matrix of boolean"); + } + //============================================================================= + _objScilab.SendScilabJob("boolean_B = ~boolean_A;"); + // get dimensions of a named matrix of boolean + int[] DimbB = _objScilab.getNamedVarDimension("boolean_B"); + + // get named matrix of boolean + Boolean[] bB = _objScilab.getNamedMatrixOfBoolean("boolean_B"); + + Console.WriteLine(""); + Console.WriteLine("(C#) bB ="); + for (int i = 0; i < DimbB[0]; i++) + { + for (int j = 0; j < DimbB[1]; j++) + { + Console.Write(bB[j * DimbB[0] + i] + " "); + } + + Console.WriteLine(""); + } + + // display matrix of string by scilab + _objScilab.SendScilabJob("disp(\'boolean_B =\');"); + _objScilab.SendScilabJob("disp(boolean_B);"); + //============================================================================= + } + //============================================================================= + static void example_doplot3d(Scilab _objScilab) + { + _objScilab.SendScilabJob("plot3d()"); + while (_objScilab.HaveAGraph()) + { + _objScilab.doEvent(); + } + } + //============================================================================= + static void example_readwriteMatrixOfInt(Scilab _objScilab) + { + //============================================================================= + int[] A = new int[] { 1, 2, 3, 4, 5, 6 }; + int mA = 2, nA = 3; + + // Write a matrix of double named in scilab + _objScilab.createNamedMatrixOfInt32("int32_A", mA, nA, A); + + // display matrix of double by scilab + _objScilab.SendScilabJob("disp(\'int32_A =\');"); + _objScilab.SendScilabJob("disp(int32_A);"); + //============================================================================= + if (_objScilab.getNamedVarType("int32_A") == (int)DotNetScilab.ScilabType.sci_ints) + { + Console.WriteLine("int32_A is a matrix of int(32)"); + } + //============================================================================= + _objScilab.SendScilabJob("int32_B = int32_A + 1;"); + + // get dimensions of a named matrix of double + int[] DimB = _objScilab.getNamedVarDimension("int32_B"); + + // get named matrix of double + int[] B = _objScilab.readNamedMatrixOfInt32("int32_B"); + + // display matrix of double from C# + Console.WriteLine(""); + Console.WriteLine("(C#) int32_B ="); + for (int i = 0; i < DimB[0]; i++) + { + for (int j = 0; j < DimB[1]; j++) + { + Console.Write(B[j * DimB[0] + i] + " "); + } + + Console.WriteLine(""); + } + + // display matrix of double by scilab + _objScilab.SendScilabJob("disp(\'int32_B =\');"); + _objScilab.SendScilabJob("disp(int32_B);"); + //============================================================================= + } + //============================================================================= + static void example_readwriteComplexMatrixOfDouble(Scilab _objScilab) + { + //============================================================================= + double[] realPartA = new double[] { 1, 2, 3, 4, 5, 6 }; + double[] imagPartA = new double[] { 6, 5, 4, 3, 2, 1 }; + int mA = 2, nA = 3; + + // Write a matrix of double named in scilab + _objScilab.createNamedComplexMatrixOfDouble("cplx_A", mA, nA, realPartA, imagPartA); + + // display matrix of double by scilab + _objScilab.SendScilabJob("disp(\'cplx_A =\');"); + _objScilab.SendScilabJob("disp(cplx_A);"); + //============================================================================= + _objScilab.SendScilabJob("cplx_B = cplx_A * 2;"); + + // get dimensions of a named matrix of double + int[] DimB = _objScilab.getNamedVarDimension("cplx_B"); + + // get named matrix of double + double[] realPartB = _objScilab.readNamedComplexMatrixOfDoubleRealPart("cplx_B"); + double[] imagPartB = _objScilab.readNamedComplexMatrixOfDoubleImgPart("cplx_B"); + + // display matrix of double from C# + Console.WriteLine(""); + Console.WriteLine("(C#) cplx_B ="); + for (int i = 0; i < DimB[0]; i++) + { + for (int j = 0; j < DimB[1]; j++) + { + Console.Write(realPartB[j * DimB[0] + i] + " + i *" + imagPartB[j * DimB[0] + i] + " "); + } + + Console.WriteLine(""); + } + + // display matrix of double by scilab + _objScilab.SendScilabJob("disp(\'cplx_B =\');"); + _objScilab.SendScilabJob("disp(cplx_B);"); + //============================================================================= + } + //============================================================================= + static void Main(string[] args) + { + // start scilab engine with graphics + Scilab m_oSCilab = new Scilab(true); + + example_readwriteMatrixOfDouble(m_oSCilab); + + example_readwriteMatrixOfString(m_oSCilab); + + example_readwriteMatrixOfBoolean(m_oSCilab); + + example_readwriteMatrixOfInt(m_oSCilab); + + example_readwriteComplexMatrixOfDouble(m_oSCilab); + + example_doplot3d(m_oSCilab); + } + //============================================================================= + } +} +//============================================================================= diff --git a/modules/call_scilab/examples/call_scilab/NET/C#/cs_example/cs_example.csproj b/modules/call_scilab/examples/call_scilab/NET/C#/cs_example/cs_example.csproj new file mode 100755 index 000000000..da98bff20 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/C#/cs_example/cs_example.csproj @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{10B5A5BF-3204-4B47-91C0-7FA614EFA94A}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>cs_example</RootNamespace> + <AssemblyName>cs_example</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <FileUpgradeFlags> + </FileUpgradeFlags> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <OldToolsVersion>3.5</OldToolsVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="cs_example.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\dotnetsci\DotNetScilab.csproj"> + <Project>{C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}</Project> + <Name>DotNetScilab</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/DotNetScilab.csproj b/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/DotNetScilab.csproj new file mode 100755 index 000000000..a19ba51ea --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/DotNetScilab.csproj @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{C3F0C7DC-82AD-405B-990A-BF2C5B7F46FF}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>DotNetScilab</RootNamespace> + <AssemblyName>DotNet-Component-Scilab</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <FileUpgradeFlags> + </FileUpgradeFlags> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <OldToolsVersion>3.5</OldToolsVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <RegisterForComInterop>false</RegisterForComInterop> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <RegisterForComInterop>false</RegisterForComInterop> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <RegisterForComInterop>false</RegisterForComInterop> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <RegisterForComInterop>false</RegisterForComInterop> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <RegisterForComInterop>false</RegisterForComInterop> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <OutputPath>..\..\..\..\..\..\..\bin\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <RegisterForComInterop>false</RegisterForComInterop> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Scilab.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Scilab_cs_wrapper.cs" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/Properties/AssemblyInfo.cs b/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/Properties/AssemblyInfo.cs new file mode 100755 index 000000000..bcbbd59a6 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("dotnetsci")] +[assembly: AssemblyDescription(".NET Component for Scilab 5.x")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Scilab - DIGITEO")] +[assembly: AssemblyProduct("dotnetsci")] +[assembly: AssemblyCopyright("Copyright © Scilab 2009")] +[assembly: AssemblyTrademark("Allan CORNET")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ef7effe8-4440-47b7-b579-433dc94cc859")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/Scilab.cs b/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/Scilab.cs new file mode 100755 index 000000000..6b76897a8 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/Scilab.cs @@ -0,0 +1,515 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2009 - DIGITEO - Allan CORNET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +//============================================================================= +/* Please notice that it is only a example and not a full C# wrapper */ +//============================================================================= +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using System.Threading; +//============================================================================= +namespace DotNetScilab +{ + /* Scilab Types */ + public enum ScilabType + { + sci_matrix = 1, + sci_poly = 2, + sci_boolean = 4, + sci_sparse = 5, + sci_boolean_sparse = 6, + sci_matlab_sparse = 7, + sci_ints = 8, + sci_handles = 9, + sci_strings = 10, + sci_u_function = 11, + sci_c_function = 13, + sci_lib = 14, + sci_list = 15, + sci_tlist = 16, + sci_mlist = 17, + sci_pointer = 128, + sci_implicit_poly = 129, + sci_intrinsic_function = 130 + }; + + public sealed class Scilab + { + //============================================================================= + static Scilab instance = null; + static readonly object padlock = new object(); + private Boolean withGraphics = false; + //============================================================================= + /// <summary> + /// Constructor, initialize scilab engine. + /// </summary> + public Scilab() + { + // Disable TCL/TK and Java graphic interfaces + Scilab_cs_wrapper.DisableInteractiveMode(); + withGraphics = false; + + // start Scilab engine configurated without java + Scilab_cs_wrapper.StartScilab(null, null, null); + } + //============================================================================= + public Scilab(Boolean _bWithGraphics) + { + // Disable TCL/TK and Java graphic interfaces + if (_bWithGraphics == false) + { + Scilab_cs_wrapper.DisableInteractiveMode(); + withGraphics = false; + } + else + { + withGraphics = true; + } + + // start Scilab engine + Scilab_cs_wrapper.StartScilab(null, null, null); + } + //============================================================================= + /// <summary> + /// Singleton + /// Only one instance of Scilab can be launch + /// thread safe + /// </summary> + public static Scilab Instance + { + get + { + lock (padlock) + { + if (instance == null) + { + instance = new Scilab(); + } + return instance; + } + } + } + //============================================================================= + /// <summary> + /// Destructor + /// </summary> + ~Scilab() + { + // freed by O.S + //Scilab_cs_wrapper.TerminateScilab(null); + } + //============================================================================= + /// <summary> + /// Send a job to scilab + /// </summary> + /// <param name="command">command to send to scilab</param> + /// <returns>error code operation, 0 : OK</returns> + public int SendScilabJob(string command) + { + return Scilab_cs_wrapper.SendScilabJob(command); + } + //============================================================================= + /// <summary> + /// get last error code + /// </summary> + /// <returns>last error code</returns> + public int GetLastErrorCode() + { + return Scilab_cs_wrapper.GetLastErrorCode(); + } + //============================================================================= + /// <summary> + /// Write a named matrix of double in Scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <param name="iRows"> Number of row</param> + /// <param name="iCols"> Number of column</param> + /// <param name="matrixDouble"> pointer on data</param> + /// <returns> if the operation successes (0) or not ( !0 )</returns> + public int createNamedMatrixOfDouble(string matrixName, int iRows, int iCols, double[] matrixDouble) + { + System.IntPtr ptrEmpty = new System.IntPtr(); + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.createNamedMatrixOfDouble(ptrEmpty, matrixName, iRows, iCols, matrixDouble); + return SciErr.iErr; + } + //============================================================================= + /// <summary> + /// Write a named matrix of string in scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <param name="iRows"> Number of row</param> + /// <param name="iCols"> Number of column</param> + /// <param name="matrixDouble"> pointer on data</param> + /// <returns> if the operation successes (0) or not ( !0 )</returns> + public int createNamedMatrixOfString(string matrixName, int iRows, int iCols, string[] matrixString) + { + System.IntPtr ptrEmpty = new System.IntPtr(); + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.createNamedMatrixOfString(ptrEmpty, matrixName, iRows, iCols, matrixString); + return SciErr.iErr; + } + //============================================================================= + /// <summary> + /// Write a named matrix of boolean in Scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <param name="iRows"> Number of row</param> + /// <param name="iCols"> Number of column</param> + /// <param name="matrixBoolean"> pointer on data</param> + /// <returns> if the operation successes (0) or not ( !0 )</returns> + public int createNamedMatrixOfBoolean(string matrixName, int iRows, int iCols, Boolean[] matrixBoolean) + { + int[] matrixInt = new int[matrixBoolean.Length]; + for (int i = 0; i < matrixBoolean.Length; i++) + { + if (matrixBoolean[i] == true) + { + matrixInt[i] = 1; + } + else + { + matrixInt[i] = 0; + } + } + System.IntPtr ptrEmpty = new System.IntPtr(); + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.createNamedMatrixOfBoolean(ptrEmpty, matrixName, iRows, iCols, matrixInt); + return SciErr.iErr; + } + //============================================================================= + /// <summary> + /// Write a named matrix of int(32) in Scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <param name="iRows"> Number of row</param> + /// <param name="iCols"> Number of column</param> + /// <param name="matrixInt"> pointer on data</param> + public int createNamedMatrixOfInt32(string matrixName, int iRows, int iCols, int[] matrixInt) + { + System.IntPtr ptrEmpty = new System.IntPtr(); + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.createNamedMatrixOfInteger32(ptrEmpty, matrixName, iRows, iCols, matrixInt); + return SciErr.iErr; + } + //============================================================================= + /// <summary> + /// Write a named matrix of complex double in Scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <param name="iRows">Number of row</param> + /// <param name="iCols">Number of column</param> + /// <param name="matrixRealPart">real part</param> + /// <param name="matrixImagPart">imag part</param> + /// <returns></returns> + public int createNamedComplexMatrixOfDouble(string matrixName, + int iRows, int iCols, + double[] matrixRealPart, + double[] matrixImagPart) + { + System.IntPtr ptrEmpty = new System.IntPtr(); + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.createNamedComplexMatrixOfDouble(ptrEmpty, matrixName, + iRows, iCols, + matrixRealPart, + matrixImagPart); + return SciErr.iErr; + } + //============================================================================= + /// <summary> + /// Read a named matrix of double from Scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <returns>a matrix of double from scilab. If Variable name does not exist returns null</returns> + public unsafe double[] readNamedMatrixOfDouble(string matrixName) + { + int iRows = 0; + int iCols = 0; + + System.IntPtr ptrEmpty = new System.IntPtr(); + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedMatrixOfDouble(ptrEmpty, matrixName, &iRows, &iCols, null); + + if (iRows * iCols > 0) + { + double[] matrixDouble = new double[iRows * iCols]; + + // get values in matrixDouble + SciErr = Scilab_cs_wrapper.readNamedMatrixOfDouble(ptrEmpty, matrixName, &iRows, &iCols, matrixDouble); + if (SciErr.iErr != 0) return null; + return matrixDouble; + } + return null; + } + //============================================================================= + /// <summary> + /// Get dimensions of a named matrix in scilab + /// </summary> + /// <returns>a int array. + /// if variable name does not exist dimensions are null </returns> + public unsafe int[] getNamedVarDimension(string matrixName) + { + int[] iDim = null; + int iRows = 0; + int iCols = 0; + + System.IntPtr ptrEmpty = new System.IntPtr(); + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.getNamedVarDimension(ptrEmpty, matrixName, &iRows, &iCols); + if (SciErr.iErr == 0) + { + iDim = new int[2]; + iDim[0] = iRows; + iDim[1] = iCols; + } + return iDim; + } + //============================================================================= + /// <summary> + /// Read a named matrix of string from scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <returns>a matrix of string from scilab. If Variable name does not exist returns null</returns> + public unsafe string[] readNamedMatrixOfString(string matrixName) + { + string[] matrixString = null; + + int[] iDim = getNamedVarDimension(matrixName); + + if (iDim != null) + { + int iRows = iDim[0]; + int iCols = iDim[1]; + + // we allocate lengthmatrixString + int[] lengthmatrixString = new int[iRows * iCols]; + + System.IntPtr ptrEmpty = new System.IntPtr(); + + // we get length of strings + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedMatrixOfString(ptrEmpty, matrixName, + &iRows, &iCols, + lengthmatrixString, null); + + // we allocate each string + matrixString = new string[iRows * iCols]; + for (int i = 0; i < iRows * iCols; i++) + { + matrixString[i] = new string(' ', lengthmatrixString[i]); + } + + // we get strings from scilab + SciErr = Scilab_cs_wrapper.readNamedMatrixOfString(ptrEmpty, matrixName, + &iRows, &iCols, + lengthmatrixString, + matrixString); + } + return matrixString; + } + //============================================================================= + /// <summary> + /// Read a named matrix of boolean from Scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <returns>a matrix of boolean from scilab. If Variable name does not exist returns null</returns> + public unsafe Boolean[] getNamedMatrixOfBoolean(string matrixName) + { + Boolean[] matrixBoolean = null; + int[] iDim = getNamedVarDimension(matrixName); + + if (iDim != null) + { + int iRows = iDim[0]; + int iCols = iDim[1]; + int[] matrixInt = new int[iRows * iCols]; + + System.IntPtr ptrEmpty = new System.IntPtr(); + + // get values in matrixDouble + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedMatrixOfBoolean(ptrEmpty, matrixName, + &iRows, &iCols, + matrixInt); + + if (matrixInt != null) + { + matrixBoolean = new Boolean[iRows * iCols]; + for (int i = 0; i < iRows * iCols; i++) + { + if (matrixInt[i] == 1) + { + matrixBoolean[i] = true; + } + else + { + matrixBoolean[i] = false; + } + } + } + } + return matrixBoolean; + } + //============================================================================= + /// <summary> + /// Read a named matrix of complex double in Scilab (Real part) + /// </summary> + /// <param name="matrixName">variable name</param> + /// <returns> real part. If Variable name does not exist returns null</returns> + public unsafe double[] readNamedComplexMatrixOfDoubleRealPart(string matrixName) + { + double[] dRealPart = null; + int[] iDim = getNamedVarDimension(matrixName); + if (iDim != null) + { + int iRows = iDim[0]; + int iCols = iDim[1]; + + double[] dImagPart = new double[iRows * iCols]; + dRealPart = new double[iRows * iCols]; + + System.IntPtr ptrEmpty = new System.IntPtr(); + + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedComplexMatrixOfDouble(ptrEmpty, matrixName, + &iRows, &iCols, + dRealPart, + dImagPart); + } + return dRealPart; + } + //============================================================================= + /// <summary> + /// Read a named matrix of complex double in Scilab (Imag part) + /// </summary> + /// <param name="matrixName">variable name</param> + /// <returns> img part. If Variable name does not exist returns null</returns> + public unsafe double[] readNamedComplexMatrixOfDoubleImgPart(string matrixName) + { + double[] dImagPart = null; + int[] iDim = getNamedVarDimension(matrixName); + if (iDim != null) + { + int iRows = iDim[0]; + int iCols = iDim[1]; + + double[] dRealPart = new double[iRows * iCols]; + dImagPart = new double[iRows * iCols]; + + System.IntPtr ptrEmpty = new System.IntPtr(); + + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedComplexMatrixOfDouble(ptrEmpty, matrixName, + &iRows, &iCols, + dRealPart, + dImagPart); + } + return dImagPart; + } + //============================================================================= + /// <summary> + /// Read a named matrix of int(32) in Scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <returns>a matrix of int(32) from scilab. If Variable name does not exist returns null</returns> + public unsafe int[] readNamedMatrixOfInt32(string matrixName) + { + int[] matrixInt = null; + int[] iDim = getNamedVarDimension(matrixName); + if (iDim != null) + { + int iRows = iDim[0]; + int iCols = iDim[1]; + + // we allocate matrixInt array + matrixInt = new int[iRows * iCols]; + + System.IntPtr ptrEmpty = new System.IntPtr(); + + // get values in matrixInt + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedMatrixOfInteger32(ptrEmpty, matrixName, &iRows, &iCols, matrixInt); + } + return matrixInt; + } + //============================================================================= + /// <summary> + /// get scilab type of named matrix + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <returns>scilab type (see enum ScilabType)</returns> + public unsafe int getNamedVarType(string matrixName) + { + int iType = 0; + System.IntPtr ptrEmpty = new System.IntPtr(); + + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.getNamedVarType(ptrEmpty, matrixName, &iType); + if (SciErr.iErr == 0) return iType; + return 0; + } + //============================================================================= + /// <summary> + /// Detect if a variable name exists in Scilab + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <returns> true if exists</returns> + public unsafe Boolean existNamedVariable(string matrixName) + { + int* piAdress = null; + System.IntPtr ptrEmpty = new System.IntPtr(); + + Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.getVarAddressFromName(ptrEmpty, matrixName, &piAdress); + if (SciErr.iErr == 0) return true; + return false; + } + //============================================================================= + /// <summary> + /// Execute a scilab script .sce + /// </summary> + /// <param name="scriptFilename">the path to the .sce file</param> + /// <returns>error code operation, 0 : OK</returns> + public int execScilabScript(String scriptFilename) + { + return Scilab_cs_wrapper.SendScilabJob("exec('" + scriptFilename + "');"); + } + //============================================================================= + /// <summary> + /// Detect if a Scilab graphic window is opened + /// </summary> + /// <returns>true or false</returns> + public Boolean HaveAGraph() + { + if (withGraphics) + { + int ierr = Scilab_cs_wrapper.sciHasFigures(); + if (ierr == 1) return true; + } + return false; + } + //============================================================================= + /// <summary> + /// do a scilab event + /// parser need to run to do a event + /// </summary> + /// <returns>error code operation, 0 : OK</returns> + public int doEvent() + { + // do a pause (we do not want 100% CPU used) + // ugly but it works ... + Thread.Sleep(1); + // do a loop of parser + return SendScilabJob(""); + } + //============================================================================= + /// <summary> + /// get scilab type of named matrix + /// </summary> + /// <param name="matrixName"> variable name</param> + /// <returns>scilab type (see enum ScilabType)</returns> + public int isNamedVarComplex(string matrixName) + { + System.IntPtr ptrEmpty = new System.IntPtr(); + return Scilab_cs_wrapper.isNamedVarComplex(ptrEmpty, matrixName); + } + //============================================================================= + } +} +//============================================================================= diff --git a/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/Scilab_cs_wrapper.cs b/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/Scilab_cs_wrapper.cs new file mode 100755 index 000000000..f006195d3 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci/Scilab_cs_wrapper.cs @@ -0,0 +1,233 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2009 - DIGITEO - Allan CORNET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +//============================================================================= +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +//============================================================================= +namespace DotNetScilab +{ + class Scilab_cs_wrapper + { + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public unsafe struct api_Ctx + { + public String pstName; /**< Function name */ + } + //============================================================================= + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public unsafe struct api_Err + { + public int iErr; + public int iMsgCount; + public fixed int pstructMsg[5]; + } + //============================================================================= + private const string CALL_SCILAB_DLL = "call_scilab.dll"; + private const string API_SCILAB_DLL = "api_scilab.dll"; + private const string GRAPHICS_DLL = "graphics.dll"; + private const string OUTPUT_STREAM_DLL = "scioutput_stream.dll"; + //============================================================================= + /// <summary> + /// import SendScilabJob from C (see call_scilab.h) + /// </summary> + [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)] + public static extern int SendScilabJob([In]String job); + //============================================================================= + /// <summary> + /// import StartScilab from C (see call_scilab.h) + /// </summary> + [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)] + public static extern int StartScilab([In] String SCIpath, + [In] String ScilabStartup, + [In] Int32[] Stacksize); + //============================================================================= + /// <summary> + /// import TerminateScilab from C (see call_scilab.h) + /// </summary> + [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)] + public static extern int TerminateScilab([In] String ScilabQuit); + //============================================================================= + /// <summary> + /// import DisableInteractiveMode from C (see call_scilab.h) + /// </summary> + [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)] + public static extern void DisableInteractiveMode(); + //============================================================================= + /// <summary> + /// import createNamedMatrixOfString from C (see api_string.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public static extern api_Err createNamedMatrixOfString([In]IntPtr pvApiCtx, [In] String _pstName, + [In] int _iRows, [In] int _iCols, + [In] String[] _pstStrings); + //============================================================================= + /// <summary> + /// import createNamedMatrixOfWideString from C (see api_string.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Unicode)] + public static extern api_Err createNamedMatrixOfWideString([In]IntPtr pvApiCtx, + [In] String _pstName, + [In] int _iRows, [In] int _iCols, + [In] String[] _pstStrings); + //============================================================================= + /// <summary> + /// import createNamedMatrixOfDouble from C (see api_double.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Struct)] + public static extern api_Err createNamedMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName, + [In] int _iRows, [In] int _iCols, + [In] double[] _pdblReal); + + + //============================================================================= + /// <summary> + /// import createNamedMatrixOfBoolean from C (see api_boolean.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public static extern api_Err createNamedMatrixOfBoolean([In]IntPtr pvApiCtx, [In] String _pstName, + [In] int _iRows, [In] int _iCols, + [In] int[] _piBool); + //============================================================================= + /// <summary> + /// import createNamedMatrixOfInteger32 from C (see api_int.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err createNamedMatrixOfInteger32([In]IntPtr pvApiCtx, [In] String _pstName, + [In] int _iRows, [In] int _iCols, + [In] int[] _piData); + //============================================================================= + /// <summary> + /// import createNamedComplexMatrixOfDouble from C (see api_double.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err createNamedComplexMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName, + [In] int _iRows, [In] int _iCols, + [In] double[] _pdblReal, + [In] double[] _pdblImg); + //============================================================================= + /// <summary> + /// import readNamedMatrixOfString from C (see api_string.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err readNamedMatrixOfString([In]IntPtr pvApiCtx, [In] String _pstName, + [Out] Int32* _piRows, [Out] Int32* _piCols, + [In, Out] int[] _piLength, + [In, Out] String[] _pstStrings); + //============================================================================= + /// <summary> + /// import readNamedMatrixOfWideString from C (see api_string.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Unicode)] + public unsafe static extern api_Err readNamedMatrixOfWideString([In]IntPtr pvApiCtx, [In] String _pstName, + [Out] Int32* _piRows, [Out] Int32* _piCols, + [In, Out] int[] _piLength, + [In, Out] String[] _pstStrings); + //============================================================================= + /// <summary> + /// import readNamedMatrixOfDouble from C (see api_double.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err readNamedMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName, + [Out] Int32* _piRows, [Out] Int32* _piCols, + [In, Out] Double[] _pdblReal); + //============================================================================= + /// <summary> + /// import readNamedMatrixOfBoolean from C (see api_boolean.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err readNamedMatrixOfBoolean([In]IntPtr pvApiCtx, [In] String _pstName, + [Out] Int32* _piRows, [Out] Int32* _piCols, + [In, Out] int[] _piBool); + //============================================================================= + /// <summary> + /// import readNamedMatrixOfInteger32 from C (see api_int.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err readNamedMatrixOfInteger32([In]IntPtr pvApiCtx, [In] String _pstName, + [Out] Int32* _piRows, [Out] Int32* _piCols, + [In, Out] int[] _piData); + + //============================================================================= + /// <summary> + /// import readNamedComplexMatrixOfDouble from C (see api_double.h) + /// </summary> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err readNamedComplexMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName, + [Out] Int32* _piRows, [Out] Int32* _piCols, + [In, Out] double[] _pdblReal, + [In, Out] double[] _pdblImg); + //============================================================================= + /// <summary> + /// get Variable Adress in scilab stack from name + /// used for getNamedMatrixType (internal) + /// </summary> + /// <param name="_pstName">variable name</param> + /// <param name="_piAddress"> stack address</param> + /// <returns>1 if ok</returns> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err getVarAddressFromName([In]IntPtr pvApiCtx, [In] String _pstName, + [Out] Int32** _piAddress); + //============================================================================= + /// <summary> + /// get Variable type in scilab stack from name + /// </summary> + /// <param name="_pstName">variable name</param> + /// <returns>type or -1</returns> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err getNamedVarType([In]IntPtr pvApiCtx, [In] String _pstName, [Out]Int32* _piType); + //============================================================================= + /// <summary> + /// get variable type with adress in scilab stack + /// used for getNamedMatrixType (internal) + /// </summary> + /// <param name="_piAddress"> stack address</param> + /// <returns>scilab type, 0 fails</returns> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err getVarType([In]IntPtr pvApiCtx, [In] Int32* _piAddress, [Out]Int32* _piType); + //============================================================================= + /// <summary> + /// Detect if a Scilab graphic window is opened + /// </summary> + /// <returns>0 (FALSE) or 1 (TRUE)</returns> + [DllImport(GRAPHICS_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern int sciHasFigures(); + //============================================================================= + /// <summary> + /// get last error code + /// </summary> + /// <returns>last error code</returns> + [DllImport(OUTPUT_STREAM_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern int GetLastErrorCode(); + //============================================================================= + /// <summary> + /// Get variable dimension + /// </summary> + /// import getNamedVarDimension from C (see api_common.h) + /// <returns>int last error code</returns> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern api_Err getNamedVarDimension([In]IntPtr pvApiCtx, [In] String _pstName, + [Out] Int32* _piRows, [Out] Int32* _piCols); + //============================================================================= + /// <summary> + /// Get named complex information + /// </summary> + /// import isNamedVarComplex from C (see api_common.h) + /// <returns>int if complex 1 otherwise 0</returns> + [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)] + public unsafe static extern int isNamedVarComplex([In]IntPtr pvApiCtx, [In] String _pstName); + //============================================================================= + + } +} +//============================================================================= diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Application.Designer.vb b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Application.Designer.vb new file mode 100755 index 000000000..8ef00a8db --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' <auto-generated> +' This code was generated by a tool. +' Runtime Version:4.0.30319.208 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' </auto-generated> +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Application.myapp b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Application.myapp new file mode 100755 index 000000000..e62f1a533 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Application.myapp @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <MySubMain>false</MySubMain> + <SingleInstance>false</SingleInstance> + <ShutdownMode>0</ShutdownMode> + <EnableVisualStyles>true</EnableVisualStyles> + <AuthenticationMode>0</AuthenticationMode> + <ApplicationType>2</ApplicationType> + <SaveMySettingsOnExit>true</SaveMySettingsOnExit> +</MyApplicationData> diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/AssemblyInfo.vb b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/AssemblyInfo.vb new file mode 100755 index 000000000..363694a55 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Les informations générales relatives à un assembly dépendent de +' l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +' associées à un assembly. + +' Vérifiez les valeurs des attributs de l'assembly + +<Assembly: AssemblyTitle("VB_example")> +<Assembly: AssemblyDescription("")> +<Assembly: AssemblyCompany("Aucune")> +<Assembly: AssemblyProduct("VB_example")> +<Assembly: AssemblyCopyright("Copyright © Aucune 2009")> +<Assembly: AssemblyTrademark("")> + +<Assembly: ComVisible(False)> + +'Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM +<Assembly: Guid("c5cbb040-95cd-4b10-aa88-811a05739d54")> + +' Les informations de version pour un assembly se composent des quatre valeurs suivantes : +' +' Version principale +' Version secondaire +' Numéro de build +' Révision +' +' Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +' en utilisant '*', comme indiqué ci-dessous : +' <Assembly: AssemblyVersion("1.0.*")> + +<Assembly: AssemblyVersion("1.0.0.0")> +<Assembly: AssemblyFileVersion("1.0.0.0")> diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Resources.Designer.vb b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Resources.Designer.vb new file mode 100755 index 000000000..85ae5c940 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' <auto-generated> +' This code was generated by a tool. +' Runtime Version:4.0.30319.208 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' </auto-generated> +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + '''<summary> + ''' A strongly-typed resource class, for looking up localized strings, etc. + '''</summary> + <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _ + Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ + Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ + Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + '''<summary> + ''' Returns the cached ResourceManager instance used by this class. + '''</summary> + <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VB_example.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + '''<summary> + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + '''</summary> + <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Resources.resx b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Resources.resx new file mode 100755 index 000000000..af7dbebba --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Resources.resx @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Settings.Designer.vb b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Settings.Designer.vb new file mode 100755 index 000000000..c0a5ffc1a --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' <auto-generated> +' This code was generated by a tool. +' Runtime Version:4.0.30319.208 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' </auto-generated> +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ + Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0"), _ + Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + <Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _ + Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ + Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _ + Friend Module MySettingsProperty + + <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _ + Friend ReadOnly Property Settings() As Global.VB_example.My.MySettings + Get + Return Global.VB_example.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Settings.settings b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Settings.settings new file mode 100755 index 000000000..85b890b3c --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/My_Project/Settings.settings @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile> diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/VB.NET.sln b/modules/call_scilab/examples/call_scilab/NET/VB.NET/VB.NET.sln new file mode 100755 index 000000000..c174ee266 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/VB.NET.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VB.NET", "VB.NET.vbproj", "{D5A143CB-C54C-42C2-B1DD-9B614054D81A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Debug|x64.ActiveCfg = Debug|x64 + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Debug|x64.Build.0 = Debug|x64 + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Debug|x86.ActiveCfg = Debug|x86 + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Debug|x86.Build.0 = Debug|x86 + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Release|Any CPU.Build.0 = Release|Any CPU + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Release|x64.ActiveCfg = Release|x64 + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Release|x64.Build.0 = Release|x64 + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Release|x86.ActiveCfg = Release|x86 + {D5A143CB-C54C-42C2-B1DD-9B614054D81A}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/VB.NET.vbproj b/modules/call_scilab/examples/call_scilab/NET/VB.NET/VB.NET.vbproj new file mode 100755 index 000000000..18bf22a6e --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/VB.NET.vbproj @@ -0,0 +1,210 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{D5A143CB-C54C-42C2-B1DD-9B614054D81A}</ProjectGuid> + <OutputType>Exe</OutputType> + <StartupObject>VB_example.vb_example</StartupObject> + <RootNamespace>VB_example</RootNamespace> + <AssemblyName>VB.NET</AssemblyName> + <FileAlignment>512</FileAlignment> + <MyType>Console</MyType> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <OptionExplicit>On</OptionExplicit> + <OptionCompare>Binary</OptionCompare> + <OptionStrict>Off</OptionStrict> + <OptionInfer>On</OptionInfer> + <IsWebBootstrapper>false</IsWebBootstrapper> + <PublishUrl>C:\bin\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>1</ApplicationRevision> + <ApplicationVersion>1.0.0.1</ApplicationVersion> + <UseApplicationTrust>false</UseApplicationTrust> + <PublishWizardCompleted>true</PublishWizardCompleted> + <BootstrapperEnabled>true</BootstrapperEnabled> + <FileUpgradeFlags> + </FileUpgradeFlags> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <OldToolsVersion>3.5</OldToolsVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <DefineDebug>true</DefineDebug> + <DefineTrace>true</DefineTrace> + <OutputPath>..\..\..\..\..\..\bin\</OutputPath> + <DocumentationFile>VB.NET.xml</DocumentationFile> + <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355</NoWarn> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <DefineDebug>false</DefineDebug> + <DefineTrace>true</DefineTrace> + <Optimize>true</Optimize> + <OutputPath>..\..\..\..\..\..\bin\</OutputPath> + <DocumentationFile>VB.NET.xml</DocumentationFile> + <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355</NoWarn> + <UseVSHostingProcess>false</UseVSHostingProcess> + <PlatformTarget>x86</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> + <DebugSymbols>true</DebugSymbols> + <DefineDebug>true</DefineDebug> + <DefineTrace>true</DefineTrace> + <OutputPath>..\..\..\..\..\..\bin\</OutputPath> + <DocumentationFile>VB.NET.xml</DocumentationFile> + <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355</NoWarn> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> + <DefineTrace>true</DefineTrace> + <OutputPath>..\..\..\..\..\..\bin\</OutputPath> + <DocumentationFile>VB.NET.xml</DocumentationFile> + <Optimize>true</Optimize> + <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355</NoWarn> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <DefineDebug>true</DefineDebug> + <DefineTrace>true</DefineTrace> + <OutputPath>..\..\..\..\..\..\bin\</OutputPath> + <DocumentationFile>VB.NET.xml</DocumentationFile> + <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355</NoWarn> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <DefineTrace>true</DefineTrace> + <OutputPath>..\..\..\..\..\..\bin\</OutputPath> + <DocumentationFile>VB.NET.xml</DocumentationFile> + <Optimize>true</Optimize> + <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355</NoWarn> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <ItemGroup> + <Reference Include="DotNet-Component-Scilab, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86"> + <HintPath>..\..\..\..\..\..\bin\DotNet-Component-Scilab.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Deployment" /> + <Reference Include="System.Xml" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + </ItemGroup> + <ItemGroup> + <Import Include="Microsoft.VisualBasic" /> + <Import Include="System" /> + <Import Include="System.Collections" /> + <Import Include="System.Collections.Generic" /> + <Import Include="System.Data" /> + <Import Include="System.Diagnostics" /> + <Import Include="System.Linq" /> + <Import Include="System.Xml.Linq" /> + </ItemGroup> + <ItemGroup> + <Compile Include="vb_example.vb" /> + <Compile Include="My_Project\AssemblyInfo.vb" /> + <Compile Include="My_Project\Application.Designer.vb"> + <AutoGen>True</AutoGen> + <DependentUpon>Application.myapp</DependentUpon> + </Compile> + <Compile Include="My_Project\Resources.Designer.vb"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="My_Project\Settings.Designer.vb"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="My_Project\Resources.resx"> + <Generator>VbMyResourcesResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.vb</LastGenOutput> + <CustomToolNamespace>My.Resources</CustomToolNamespace> + <SubType>Designer</SubType> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <None Include="My_Project\Application.myapp"> + <Generator>MyApplicationCodeGenerator</Generator> + <LastGenOutput>Application.Designer.vb</LastGenOutput> + </None> + <None Include="My_Project\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <CustomToolNamespace>My</CustomToolNamespace> + <LastGenOutput>Settings.Designer.vb</LastGenOutput> + </None> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework Client Profile</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 2.0 %28x86%29</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.0 %28x86%29</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> + <Visible>False</Visible> + <ProductName>Windows Installer 3.1</ProductName> + <Install>true</Install> + </BootstrapperPackage> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/call_scilab/NET/VB.NET/vb_example.vb b/modules/call_scilab/examples/call_scilab/NET/VB.NET/vb_example.vb new file mode 100755 index 000000000..fcdb1989a --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/VB.NET/vb_example.vb @@ -0,0 +1,71 @@ +' +' * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +' * Copyright (C) 2009 - DIGITEO - Allan CORNET +' * +' * This file must be used under the terms of the CeCILL. +' * This source file is licensed as described in the file COPYING, which +' * you should have received as part of this distribution. The terms +' * are also available at +' * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +' * +'//============================================================================= + +' See SCI/modules/call_scilab/examples/NET/C# about scilab .NET Component +' You need to add Scilab (C#) .NET Component as reference +' easier way to test is to launch SCI/bin/VB.NET.exe +' or VB.NET.exe must known libscilab.dll library path + +Module vb_example + '//============================================================================= + Sub example() + Dim ObjScilab As New DotNetScilab.Scilab + + ' Send a command to scilab + ' Here , we want to display SCI variable + ObjScilab.SendScilabJob("disp('SCI = ');") + ObjScilab.SendScilabJob("disp(SCI)") + + Dim A() As Double = {1, 2, 3, 4, 5, 6} + Dim mA As Long = 2 + Dim nA As Long = 3 + + + ObjScilab.createNamedMatrixOfDouble("A", mA, nA, A) + ObjScilab.SendScilabJob("disp('A = ');") + ObjScilab.SendScilabJob("disp(A)") + + ObjScilab.SendScilabJob("A = A + 1;") + ObjScilab.SendScilabJob("disp('A modified = ');") + ObjScilab.SendScilabJob("disp(A)") + + Dim A_modified() As Double + A_modified = ObjScilab.readNamedMatrixOfDouble("A") + + Dim dimension_A_modified(2) As Integer + dimension_A_modified = ObjScilab.getNamedVarDimension("A") + + Console.WriteLine("") + Console.WriteLine("(C#) A modified =") + + Dim i As Integer = 0 + Dim j As Integer = 0 + Dim elem As Double = 0 + + For i = 0 To dimension_A_modified(0) - 1 + For j = 0 To dimension_A_modified(1) - 1 + + elem = A_modified(j * dimension_A_modified(0) + i) + Console.Write(elem.ToString + " ") + Next j + Console.WriteLine("") + Next i + + End Sub + '//============================================================================= + Sub Main() + example() + End Sub + '//============================================================================= +End Module +'//============================================================================= + diff --git a/modules/call_scilab/examples/call_scilab/NET/powershell/examples.ps b/modules/call_scilab/examples/call_scilab/NET/powershell/examples.ps new file mode 100755 index 000000000..fa74e3a9b --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/powershell/examples.ps @@ -0,0 +1,46 @@ +#------------------------------------------------------------------------------ +# Allan CORNET - DIGITEO - 2009 +# This file is released under the 3-clause BSD license. See COPYING-BSD. +#------------------------------------------------------------------------------ +# set PATH and SCI/bin +$Scilab_bin_directory = "C:\Program Files\scilab-5.2\bin" +$Env:PATH = $Env:PATH + ";" + $Scilab_bin_directory +#------------------------------------------------------------------------------ +# load dll C# component +$Fullpath ="$Scilab_bin_directory\DotNet-Component-Scilab.dll" +[System.Reflection.Assembly]::LoadFile($Fullpath) +#------------------------------------------------------------------------------ +# create a scilab object +$objScilab = new-object dotnetscilab.Scilab +#------------------------------------------------------------------------------ +# send a command to scilab +$r = $objScilab.SendScilabJob("disp('Hello')") +#------------------------------------------------------------------------------ +# read a variable (double) from scilab +$r = $objScilab.SendScilabJob("A=ones(5,10)") +$objScilab.SendScilabJob("disp(A)") +$objScilab.readNamedMatrixOfDouble('A') +$dimA = $objScilab.getNamedVarDimension('A') +#------------------------------------------------------------------------------ +# read a variable (string) from scilab +$objScilab.SendScilabJob("strA = 'test'") +$objScilab.readNamedMatrixOfString('strA') +$objScilab.getNamedVarDimension('strA') +#------------------------------------------------------------------------------ +# read a variable (string) from scilab +$objScilab.SendScilabJob("strB =['test';'scilab']") +$dimstrB = $objScilab.getNamedVarDimension('strB') +$strB = $objScilab.readNamedMatrixOfString('strB') +#------------------------------------------------------------------------------ +$matDouble = (5.,10.,5.,10.,5.,10.) +$objScilab.createNamedMatrixOfDouble('matDouble',3,2,$matDouble) +$objScilab.SendScilabJob("matDouble = matDouble * 2") +$objScilab.SendScilabJob("disp(matDouble)") +$matDouble = $objScilab.readNamedMatrixOfDouble('matDouble') +#------------------------------------------------------------------------------ +$matString = ('test' , 'scilab' , 'from' , 'powershell') +$objScilab.createNamedMatrixOfString('matString',2,2,$matString) +$objScilab.SendScilabJob("matString = convstr(matString,'u')") +$objScilab.SendScilabJob("disp(matString)") +$matString = $objScilab.readNamedMatrixOfString('matString') +#------------------------------------------------------------------------------ diff --git a/modules/call_scilab/examples/call_scilab/NET/powershell/readme.txt b/modules/call_scilab/examples/call_scilab/NET/powershell/readme.txt new file mode 100755 index 000000000..d1d068696 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/NET/powershell/readme.txt @@ -0,0 +1,87 @@ +Call scilab from powershell +(http://wiki.scilab.org/Call_scilab_from_powershell) + +A easy example to call scilab from powershell. + +you need : + +-- powershell 1.0 or 2.0 CTP + +-- scilab 5.2 + +-- visual studio C# 2008 pro or express (to build donetscilab classlibrary) + +1] build donetscilab classlibrary + +launch SCI/modules/call_scilab/examples/call_scilab/NET/C#/dotnetsci.sln + +and build solution. + +2] configure your powershell environment + +launch powershell : + $Scilab_bin_directory = "C:\Program Files\scilab-5.2\bin" + $Env:PATH = $Env:PATH + ";" + $Scilab_bin_directory + +3] load .NET classlibrary + $Fullpath ="$Scilab_bin_directory\DotNet-Component-Scilab.dll" + [System.Reflection.Assembly]::LoadFile($Fullpath) + +4] create a .NET scilab object + $objScilab = new-object dotnetscilab.Scilab + +5] play with methods of scilab object + +send a job to scilab (here , display a string) : + $r = $objScilab.SendScilabJob("disp('Hello')") + $r + +creates a double matrix in scilab and get result in powershell : + $r = $objScilab.SendScilabJob("A=ones(5,10)") + $r + + $objScilab.SendScilabJob("disp(A)") + $objScilab.readNamedMatrixOfDouble('A') + + $dimA = $objScilab.getNamedVarDimension('A') + $dimA + +creates a string in scilab and get result in powershell : + $objScilab.SendScilabJob("strA = 'test'") + $objScilab.readNamedMatrixOfString('strA') + $objScilab.getNamedVarDimension('strA') + +creates a string matrix in scilab and get result in powershell : + $objScilab.SendScilabJob("strB =['test';'scilab']") + $dimstrB = $objScilab.getNamedVarDimension('strB') + $dimstrB + + $strB = $objScilab.readNamedMatrixOfString('strB') + $strB + +send an array of double from powershell, modify by scilab and get result : + $matDouble = (5.,10.,5.,10.,5.,10.) + $matDouble + + $objScilab.createNamedMatrixOfDouble('matDouble',3,2,$matDouble) + + $objScilab.SendScilabJob("matDouble = matDouble * 2") + $objScilab.SendScilabJob("disp(matDouble)") + + $matDouble = $objScilab.readNamedMatrixOfDouble('matDouble') + $matDouble + +send an array of string from powershell, modify by scilab and get result : + $matString = ('test' , 'scilab' , 'from' , 'powershell') + $matString + + $objScilab.createNamedMatrixOfString('matString',2,2,$matString) + $objScilab.SendScilabJob("matString = convstr(matString,'u')") + $objScilab.SendScilabJob("disp(matString)") + + $matString = $objScilab.readNamedMatrixOfString('matString') + $matString + + +Allan CORNET - DIGITEO - 2009 + diff --git a/modules/call_scilab/examples/call_scilab/c/LabWindow/CallsciC.c b/modules/call_scilab/examples/call_scilab/c/LabWindow/CallsciC.c new file mode 100755 index 000000000..267a0554f --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/LabWindow/CallsciC.c @@ -0,0 +1,166 @@ +/* Allan CORNET */ +/* Scilab, INRIA 2004 */ +/* Only For Windows */ +/*--------------------------------------------------------------------------*/ +#pragma comment(lib, "../../../../../../bin/libScilab.lib") +/*--------------------------------------------------------------------------*/ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "call_scilab.h" +#include "stack-c.h" +/*--------------------------------------------------------------------------*/ +/* See SCI/modules/core/includes/call_scilab.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 occurred 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/modules/call_scilab/examples/call_scilab/c/LabWindow/example.prj b/modules/call_scilab/examples/call_scilab/c/LabWindow/example.prj new file mode 100755 index 000000000..296910ac1 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/LabWindow/example.prj @@ -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/modules/call_scilab/examples/call_scilab/c/LabWindow/readme.txt b/modules/call_scilab/examples/call_scilab/c/LabWindow/readme.txt new file mode 100755 index 000000000..a7fa0c148 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/LabWindow/readme.txt @@ -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 diff --git a/modules/call_scilab/examples/call_scilab/c/common/.deps/call_scilab_c-myprog.Po b/modules/call_scilab/examples/call_scilab/c/common/.deps/call_scilab_c-myprog.Po new file mode 100755 index 000000000..9ce06a81e --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/common/.deps/call_scilab_c-myprog.Po @@ -0,0 +1 @@ +# dummy diff --git a/modules/call_scilab/examples/call_scilab/c/common/.deps/call_scilab_c_simple-simple_call_scilab.Po b/modules/call_scilab/examples/call_scilab/c/common/.deps/call_scilab_c_simple-simple_call_scilab.Po new file mode 100755 index 000000000..9ce06a81e --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/common/.deps/call_scilab_c_simple-simple_call_scilab.Po @@ -0,0 +1 @@ +# dummy diff --git a/modules/call_scilab/examples/call_scilab/c/common/makefile.mak b/modules/call_scilab/examples/call_scilab/c/common/makefile.mak new file mode 100755 index 000000000..35f0966d2 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/common/makefile.mak @@ -0,0 +1,34 @@ +SHELL = /bin/sh + +SCIDIR=../../../../../.. +SCIDIR1=..\..\..\..\..\.. + +DUMPEXTS="$(SCIDIR1)\bin\dumpexts" +SCIIMPLIB=$(SCIDIR)/bin/LibScilab.lib + +CFLAGS= $(CC_OPTIONS) -DFORDLL -I"$(SCIDIR)/routines" +CPPFLAGS= $(CC_OPTIONS) -DFORDLL -I"$(SCIDIR)/routines" + +!include $(SCIDIR)/modules/dynamic_link/src/scripts/Makefile.incl.mak + + +OBJSC= myprog.obj + +all:: $(OBJSC) $(SCIDIR)/bin/prog.exe + +distclean:: clean + +clean :: + @del *.obj + +distclean:: clean + @del $(SCIDIR1)\bin\prog.* + + +RESOURCES= $(SCIDIR)/routines/wsci/Rscilab.res + +$(SCIDIR)/bin/prog.exe : $(OBJSC) + @echo "Linking" + $(LINKER) $(LINKER_FLAGS) -OUT:"$*.exe" \ + $(OBJSC) $(SCIDIR)/bin/LibScilab.lib $(SCILAB_LIBS) + @echo "done " $(SCIDIR)/bin/prog.exe diff --git a/modules/call_scilab/examples/call_scilab/c/common/myprog.c b/modules/call_scilab/examples/call_scilab/c/common/myprog.c new file mode 100755 index 000000000..299092138 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/common/myprog.c @@ -0,0 +1,168 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) INRIA + * Copyright (C) INRIA - 2005 - Allan Cornet + * + * This file is released under the 3-clause BSD license. See COPYING-BSD. + * + */ +#include <math.h> +#include <stdio.h> +#ifdef _MSC_VER +#include <windows.h> +#endif +#include <unistd.h> +#include <string.h> +#include "api_scilab.h" +#include "call_scilab.h" /* Provide functions to call Scilab engine */ + +/** + * + * Initialisation of Scilab + */ +/*#ifndef SCI +#define SCI "../.." +#endif */ +/*------------------------------------------------------------*/ +#define TRUE 1 +#define FALSE 0 +/*------------------------------------------------------------*/ +/* See SCI/modules/core/includes/call_scilab.h */ +/*------------------------------------------------------------*/ +static int first_example(void) +{ + static double A[] = {1, 2, 3, 4}; + int mA = 2, nA = 2; + static double b[] = {4, 5}; + int mb = 2, nb = 1; + printf("\nExample 1:\n"); + printf("Some simple computations\n"); + + /* Create Scilab matrices A and b */ + createNamedMatrixOfDouble(pvApiCtx, "A", mA, mA, A); + createNamedMatrixOfDouble(pvApiCtx, "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 occurred during scilab execution (SendScilabJob)\n"); + } + else + { + double *cxtmp = NULL; + int m, n, lp, i; + + /* Get m and n */ + getNamedVarDimension(pvApiCtx, "x", &m, &n); + + cxtmp = (double*)malloc((m * n) * sizeof(double)); + + readNamedMatrixOfDouble(pvApiCtx, "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 second_example(void) +{ + printf("\nExample 2:\n"); + printf("Call graphics\n"); + + SendScilabJob("plot3d();"); + + printf("\nClose Graphical Windows to close this example.\n"); + while ( ScilabHaveAGraph() ) + { + ScilabDoOneEvent(); + sleep(1); + } + return 1; +} +/*------------------------------------------------------------*/ +static int third_example(void) +{ + int code = 0; + char **JOBS = NULL; + const int SizeJOBS = 6; + int i = 0; + printf("\nExample 3:\n"); + printf("Send many jobs.\n"); + 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[2],"b = V_NOT_EXIST;"); */ + strcpy(JOBS[3], "+3;"); + strcpy(JOBS[4], "disp('C=');"); + strcpy(JOBS[5], "C=A+B;disp(C);"); /* C = 12 */ + + code = SendScilabJobs(JOBS, SizeJOBS); + + if (code) + { + char lastjob[4096]; // bsiz in scilab 4096 max + if (GetLastJob(lastjob, 4096)) + { + printf("Error %s\n", lastjob); + } + } + + for (i = 0; i < SizeJOBS; i++) + { + if (JOBS[i]) + { + free(JOBS[i]); + JOBS[i] = NULL; + } + } + return 0; +} + +/*------------------------------------------------------------*/ +int main(void) +{ +#ifdef _MSC_VER + if ( StartScilab(NULL, NULL, NULL) == FALSE ) +#else + if ( StartScilab(getenv("SCI"), NULL, NULL) == FALSE ) +#endif + { + fprintf(stderr, "Error while calling StartScilab\n"); + return -1; + } + + first_example(); + + second_example() ; + + third_example() ; + + if ( TerminateScilab(NULL) == FALSE ) + { + fprintf(stderr, "Error while calling TerminateScilab\n"); + return -2; + } + return 0; +} +/*------------------------------------------------------------*/ diff --git a/modules/call_scilab/examples/call_scilab/c/common/simple_call_scilab.c b/modules/call_scilab/examples/call_scilab/c/common/simple_call_scilab.c new file mode 100755 index 000000000..717c6f66d --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/common/simple_call_scilab.c @@ -0,0 +1,42 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2009 - Sylvestre Ledru + * Copyright (C) INRIA - 2005 - Allan Cornet + * + * This file is released under the 3-clause BSD license. See COPYING-BSD. + * + */ +#include <stdio.h> /* stderr */ + +#include "call_scilab.h" /* Provide functions to call Scilab engine */ + + +// Filename: simple_call_scilab.c + +int main(void) +{ + /****** INITIALIZATION **********/ +#ifdef _MSC_VER + if ( StartScilab(NULL, NULL, NULL) == FALSE ) +#else + if ( StartScilab(getenv("SCI"), NULL, NULL) == FALSE ) +#endif + { + fprintf(stderr, "Error while calling StartScilab\n"); + return -1; + } + + /****** ACTUAL Scilab TASKS *******/ + + SendScilabJob("myMatrix=['sample','for the help']"); + SendScilabJob("disp(myMatrix);"); // Will display !sample for the help ! + SendScilabJob("disp([2,3]+[-44,39]);"); // Will display - 42. 42. + + /****** TERMINATION **********/ + if ( TerminateScilab(NULL) == FALSE ) + { + fprintf(stderr, "Error while calling TerminateScilab\n"); + return -2; + } + return 0; +} diff --git a/modules/call_scilab/examples/call_scilab/c/visual_studio/CallSciVC.sln b/modules/call_scilab/examples/call_scilab/c/visual_studio/CallSciVC.sln new file mode 100755 index 000000000..4d7836d0a --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/visual_studio/CallSciVC.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Callsci Example ", "CallSciVC.vcxproj", "{0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Debug|Win32.ActiveCfg = Debug|Win32 + {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Debug|Win32.Build.0 = Debug|Win32 + {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Debug|x64.ActiveCfg = Debug|x64 + {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Debug|x64.Build.0 = Debug|x64 + {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Release|Win32.ActiveCfg = Release|Win32 + {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Release|Win32.Build.0 = Release|Win32 + {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Release|x64.ActiveCfg = Release|x64 + {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/modules/call_scilab/examples/call_scilab/c/visual_studio/CallSciVC.vcxproj b/modules/call_scilab/examples/call_scilab/c/visual_studio/CallSciVC.vcxproj new file mode 100755 index 000000000..103e3e9dc --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/visual_studio/CallSciVC.vcxproj @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectName>Callsci Example </ProjectName> + <ProjectGuid>{0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}</ProjectGuid> + <RootNamespace>Callsci Example </RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.31118.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../../core/includes;../../../../../api_scilab/includes;../../../../includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + </ClCompile> + <Link> + <OutputFile>../../../../../../bin/CallSciVC.exe</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)CallSciVC.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> + <TargetMachine>MachineX86</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../../core/includes;../../../../../api_scilab/includes;../../../../includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <OutputFile>../../../../../../bin/CallSciVC.exe</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)CallSciVC.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <AdditionalIncludeDirectories>../../../../../core/includes;../../../../../api_scilab/includes;../../../../includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <OutputFile>../../../../../../bin/CallSciVC.exe</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <TargetMachine>MachineX86</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <AdditionalIncludeDirectories>../../../../../core/includes;../../../../../api_scilab/includes;../../../../includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <OutputFile>../../../../../../bin/CallSciVC.exe</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="CallsciC.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/call_scilab/c/visual_studio/CallSciVC.vcxproj.filters b/modules/call_scilab/examples/call_scilab/c/visual_studio/CallSciVC.vcxproj.filters new file mode 100755 index 000000000..027ab191a --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/visual_studio/CallSciVC.vcxproj.filters @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="CallsciC.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/modules/call_scilab/examples/call_scilab/c/visual_studio/CallsciC.c b/modules/call_scilab/examples/call_scilab/c/visual_studio/CallsciC.c new file mode 100755 index 000000000..dd365b7fe --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/c/visual_studio/CallsciC.c @@ -0,0 +1,168 @@ +/*--------------------------------------------------------------------------*/ +/* Example only for Windows */ +/*--------------------------------------------------------------------------*/ +#pragma comment(lib, "../../../../../../bin/call_scilab.lib") +#pragma comment(lib, "../../../../../../bin/api_scilab.lib") +/*--------------------------------------------------------------------------*/ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "call_scilab.h" +#include "api_scilab.h" +#include "stack-c.h" +/*--------------------------------------------------------------------------*/ +/* See SCI/modules/core/includes/call_scilab.h */ +/* See SCI/modules/core/includes/api_scilab.h */ +/*--------------------------------------------------------------------------*/ +static int example1(void) +{ + SciErr sciErr; + + 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 */ + sciErr = createNamedMatrixOfDouble(pvApiCtx, "A", mA, nA, A); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + + sciErr = createNamedMatrixOfDouble(pvApiCtx, "b", mb, nb, b); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + + 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 occurred during scilab execution (SendScilabJob)\n"); + } + else + { + double *cxtmp = NULL; + int m = 0, n = 0; + int i = 0; + + /* Get m and n dimensions of x */ + sciErr = readNamedMatrixOfDouble(pvApiCtx, "x", &m, &n , NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + + cxtmp = (double*)malloc((m * n) * sizeof(double)); + sciErr = readNamedMatrixOfDouble(pvApiCtx, "x", &m, &n , cxtmp); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + + 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) +{ + SendScilabJob("plot3d();"); + printf("\nClose Graphical Windows to close this example.\n"); + while ( ScilabHaveAGraph() ) + { + ScilabDoOneEvent(); + } + return 1; +} +/*--------------------------------------------------------------------------*/ +static int example3(void) +{ + int code = 0; + + char **JOBS = NULL; + const int SizeJOBS = 6; + int i = 0; + + 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], "disp('C=');"); + strcpy(JOBS[5], "C=A+B;disp(C);"); /* C = 12 */ + + code = SendScilabJobs(JOBS, SizeJOBS); + + if (code) + { + char lastjob[4096]; // bsiz in scilab 4096 max + if (GetLastJob(lastjob, 4096)) + { + printf("Error %s\n", lastjob); + } + } + + for (i = 0; i < SizeJOBS; i++) + { + if (JOBS[i]) + { + free(JOBS[i]); + JOBS[i] = NULL; + } + } + return 1; +} +/*--------------------------------------------------------------------------*/ +int main(void) +/* int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow) */ +{ + if ( StartScilab(NULL, NULL, 0) == FALSE ) + { + printf("Error : StartScilab\n"); + return 0; + } + + printf("\nexample 1\n"); + example1(); + system("pause"); + printf("\nexample 2\n"); + example2(); + system("pause"); + printf("\nexample 3\n"); + example3(); + system("pause"); + + if ( TerminateScilab(NULL) == FALSE ) + { + printf("Error : TerminateScilab\n"); + } + return 0; +} +/*--------------------------------------------------------------------------*/ diff --git a/modules/call_scilab/examples/call_scilab/cpp/borlandcpp/readme.txt b/modules/call_scilab/examples/call_scilab/cpp/borlandcpp/readme.txt new file mode 100755 index 000000000..59ee3251e --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/cpp/borlandcpp/readme.txt @@ -0,0 +1,19 @@ +How to make calls to Scilab interpreter from Borland C++ 6 + +Import Scilab library (LibScilab.dll) to Borland + +on a Command line + +impdef Libscilab.def Libscilab.dll +implib Libscilab.lib Libscilab.def + +Add Libscilab.lib in your Borland C++ project in "import library" + + +(On Google see 'Borland import library') + +That's all + +Allan CORNET +September 2006 +Scilab Team diff --git a/modules/call_scilab/examples/call_scilab/cpp/common/Makefile.mak b/modules/call_scilab/examples/call_scilab/cpp/common/Makefile.mak new file mode 100755 index 000000000..23394e245 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/cpp/common/Makefile.mak @@ -0,0 +1,39 @@ +SHELL = /bin/sh + +SCIDIR=../../../../../.. +SCIDIR1=..\..\..\..\..\.. + +DUMPEXTS="$(SCIDIR1)\bin\dumpexts" +SCIIMPLIB=$(SCIDIR)/bin/LibScilab.lib + +CFLAGS= $(CC_OPTIONS) -DFORDLL -I"$(SCIDIR)/modules/core/includes" /EHsc +CPPFLAGS= $(CC_OPTIONS) -DFORDLL -I"$(SCIDIR)/modules/core/includes" /EHsc + +!include $(SCIDIR)/modules/dynamic_link/src/scripts/Makefile.incl.mak + +OBJSC = myprog.obj ccmatrix1.obj + +all:: $(OBJSC) $(SCIDIR)/bin/prog.exe + +distclean:: clean + +clean :: + @del *.obj + @del *.lib + @del *.dll + @del *.exp + @del *.def + @del Makelib.mak + @del loader.sce + + +distclean:: clean + @del $(SCIDIR1)\bin\prog.exe + + + +$(SCIDIR)/bin/prog.exe : $(OBJSC) + @echo "Linking" + $(LINKER) $(LINKER_FLAGS) -OUT:"$*.exe" \ + $(OBJSC) $(SCIDIR)/bin/LibScilab.lib $(TKLIBS) $(GUI) -NODEFAULTLIB:msvcrt.lib + @echo "done " $(SCIDIR)/bin/prog.exe diff --git a/modules/call_scilab/examples/call_scilab/cpp/common/ccmatrix.h b/modules/call_scilab/examples/call_scilab/cpp/common/ccmatrix.h new file mode 100755 index 000000000..917dd1735 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/cpp/common/ccmatrix.h @@ -0,0 +1,26 @@ +/* + * This file is distributed under the same license as the Scilab package. + */ +#ifndef _cc_matrix_H_ +#define _cc_matrix_H_ + + +class CMatrix +{ +private: + int m, n; + char *name; + double *v; + +public: + CMatrix(char *name1, char *job); + void scijob(char *jobname); + CMatrix& plus(CMatrix &B); + void print(); + void inv(); + +}; + +#endif + + diff --git a/modules/call_scilab/examples/call_scilab/cpp/common/ccmatrix1.cc b/modules/call_scilab/examples/call_scilab/cpp/common/ccmatrix1.cc new file mode 100755 index 000000000..60f678935 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/cpp/common/ccmatrix1.cc @@ -0,0 +1,86 @@ +#include <iostream> +#include "ccmatrix.h" + + +class SciError {}; + +// CMatrix A(name,job); + +extern "C" { +#include <stdio.h> +#include <string.h> +#undef _PARAMS +#include "stack-c.h" +int SendScilabJob(char *); +void cc_test(); + +} + +static char buf[256]; + +CMatrix::CMatrix(char *name1,char *job) +{ + sprintf(buf,"%s=%s;",name1,job); + if ( SendScilabJob(buf) != 0) + throw SciError(); + else + { + int lp; + C2F(cmatptr)(name1, &m, &n, &lp,strlen(name1)); + v = stk(lp); + } + name = new char[strlen(name1)+1]; + strcpy(name,name1); +} + + +void CMatrix::scijob(char *jobname) +{ + sprintf(buf,jobname,name); + if ( SendScilabJob(buf) != 0) + throw SciError(); +} + +CMatrix& CMatrix::plus(CMatrix &B) +{ + sprintf(buf,"%s=%s+%s",this->name,this->name,B.name); + if ( SendScilabJob(buf) != 0) + throw SciError(); + int lp; + C2F(cmatptr)(name, &m, &n, &lp,strlen(name)); + v = stk(lp); + return *this; +} + +void CMatrix::print() +{ + fprintf(stdout,"Matrix %s=\n",name); + scijob("disp(%s)"); +} + +void CMatrix::inv() +{ + sprintf(buf,"%s=inv(%s)",name,name); + if ( SendScilabJob(buf) != 0) + throw SciError(); + int lp; + C2F(cmatptr)(name, &m, &n, &lp,strlen(name)); + v = stk(lp); +} + + +void cc_test() +{ + CMatrix A("a","ones(2,2)"); + CMatrix B("b","8"); + A.plus(B); + A.scijob("disp(%s);"); + A.scijob("%s=rand(2,2)"); + A.print(); + A.inv(); + A.print(); +} + + + + diff --git a/modules/call_scilab/examples/call_scilab/cpp/common/ccmatrix1.cpp b/modules/call_scilab/examples/call_scilab/cpp/common/ccmatrix1.cpp new file mode 100755 index 000000000..6286fc193 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/cpp/common/ccmatrix1.cpp @@ -0,0 +1,89 @@ +#include <iostream> +#include "ccmatrix.h" + + +class SciError {}; + +// CMatrix A(name,job); + +extern "C" { +#include <stdio.h> +#undef _PARAMS +#include "stack-c.h" + int send_scilab_job(char *, long int); + void cc_test(); + +} + +static char buf[256]; + +CMatrix::CMatrix(char *name1, char *job) +{ + sprintf(buf, "%s=%s;", name1, job); + if ( send_scilab_job(buf, strlen(buf)) != 0) + { + throw SciError(); + } + else + { + int lp; + C2F(cmatptr)(name1, &m, &n, &lp, strlen(name1)); + v = stk(lp); + } + name = new char[strlen(name1) + 1]; + strcpy(name, name1); +} + + +void CMatrix::scijob(char *jobname) +{ + sprintf(buf, jobname, name); + if ( send_scilab_job(buf, strlen(buf)) != 0) + { + throw SciError(); + } +} + +CMatrix& CMatrix::plus(CMatrix &B) +{ + sprintf(buf, "%s=%s+%s", this->name, this->name, B.name); + if ( send_scilab_job(buf, strlen(buf)) != 0) + { + throw SciError(); + } + int lp; + C2F(cmatptr)(name, &m, &n, &lp, strlen(name)); + v = stk(lp); + return *this; +} + +void CMatrix::print() +{ + fprintf(stdout, "Matrix %s=\n", name); + scijob("disp(%s)"); +} + +void CMatrix::inv() +{ + sprintf(buf, "%s=inv(%s)", name, name); + if ( send_scilab_job(buf, strlen(buf)) != 0) + { + throw SciError(); + } + int lp; + C2F(cmatptr)(name, &m, &n, &lp, strlen(name)); + v = stk(lp); +} + + +void cc_test() +{ + CMatrix A("a", "ones(2,2)"); + CMatrix B("b", "8"); + A.plus(B); + A.scijob("disp(%s);"); + A.scijob("%s=rand(2,2)"); + A.print(); + A.inv(); + A.print(); +} diff --git a/modules/call_scilab/examples/call_scilab/cpp/common/my_ode.c b/modules/call_scilab/examples/call_scilab/cpp/common/my_ode.c new file mode 100755 index 000000000..731493092 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/cpp/common/my_ode.c @@ -0,0 +1,6 @@ + +int odeex(int *neq, double * t, double *y, double * ydot) +{ + ydot[0] = -y[0] + 2.0; + return 0; +} diff --git a/modules/call_scilab/examples/call_scilab/cpp/common/myprog.c b/modules/call_scilab/examples/call_scilab/cpp/common/myprog.c new file mode 100755 index 000000000..2d3794fa6 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/cpp/common/myprog.c @@ -0,0 +1,119 @@ +#include <stdio.h> +#include "stack-c.h" +/*--------------------------------------------------------------------------*/ +#ifndef SCI +#define SCI "SCI=../../.." +#endif +#define TRUE 1 +#define FALSE 0 + +/*--------------------------------------------------------------------------*/ +/* See routines/system/call_scilab.h */ +extern int StartScilab(char *SCIpath, char *ScilabStartup, int *Stacksize); +extern int TerminateScilab(char *ScilabQuit); +extern int SendScilabJob(char *job); +/*--------------------------------------------------------------------------*/ +double f(double x) +{ + return x * x + 1; +} +/*--------------------------------------------------------------------------*/ +static int my_plot() +{ + int m, n, lx, ly, i; + /* Scilab is called to build the abscissae vector and + to allocate the ordinates */ + + SendScilabJob("x=1:0.1:10;y=x;"); + GetMatrixptr("x", &m, &n, &lx); + GetMatrixptr("y", &m, &n, &ly); + /* + * y(i)=f(x(i)) + */ + for ( i = 0; i < m * n ; i++) + { + *stk(ly + i) = f(*stk(lx + i)); + } + /* + * plot(x,y); + */ + SendScilabJob("plot(y,x);"); +} +/*--------------------------------------------------------------------------*/ +static int my_job() +{ + static char job[256]; + /* storing a matrix inside scilab */ + static double A[] = {1, 2, 3, 4}; + int mA = 2, nA = 2; + static double b[] = {4, 5}; + int mb = 2, nb = 1; + int m, n, lp, i; + WriteMatrix("A", &mA, &nA, A); /* if failed make my_job return O; */ + WriteMatrix("b", &mb, &nb, b); + + if ( SendScilabJob("A,b,x=0\\b;") == 27) + { + fprintf(stdout, "division by zero...\n"); + } + else + { + GetMatrixptr("x", &m, &n, &lp); + for ( i = 0 ; i < m * n ; i++) + { + fprintf(stdout, "x[%d] = %5.2f\n", i, *stk(i + lp)); + } + } + + if ( SendScilabJob("A,b,x=A\\b;") != 0) + { + fprintf(stdout, "Error occurred during scilab execution\n"); + } + else + { + GetMatrixptr("x", &m, &n, &lp); + for ( i = 0 ; i < m * n ; i++) + { + fprintf(stdout, "x[%d] = %5.2f\n", i, *stk(i + lp)); + } + } +} +/*--------------------------------------------------------------------------*/ +/* I want to integrate the previous equation */ +int my_ode_job() +{ + double x[] = {1, 0, 0} ; + int mx = 3, nx = 1; + double time[] = {0.4, 4}; + int mt = 1, nt = 2; + fprintf(stdout, "linking \n"); + SendScilabJob("ilib_for_link('odeex','my_ode.c',[],'c');"); + fprintf(stdout, "link done \n"); + SendScilabJob("exec('loader.sce');link('show')"); + WriteMatrix("x", &mx, &nx, x); + WriteMatrix("time", &mt, &nt, time); + /* scilab is called to solve the ODE */ + SendScilabJob("y=ode(x,0,time,''mon_ode''),"); +} +/*--------------------------------------------------------------------------*/ +#if _MSC_VER +int main(void) +#else +int MAIN__(void) +#endif +{ + if ( StartScilab(NULL, NULL, NULL) == FALSE ) + { + printf("Error : StartScilab \n"); + } + my_ode_job(); + my_job(); + my_plot() ; + cc_test(); + if ( TerminateScilab(NULL) == FALSE ) + { + printf("Error : TerminateScilab \n"); + } + return 0; +} +/*--------------------------------------------------------------------------*/ diff --git a/modules/call_scilab/examples/call_scilab/cpp/common/readme.txt b/modules/call_scilab/examples/call_scilab/cpp/common/readme.txt new file mode 100755 index 000000000..1d19258a2 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/cpp/common/readme.txt @@ -0,0 +1,22 @@ + + How to make calls to Scilab interpreter + from a C++ program + +In this directory we provide small examples of C++ calls to the Scilab +interpreter. + +[1] Unix ( soure are myprog.c and ccmatrix1.cc ) +To make it run you have to edit the Makefile +and change the SCIDIR variable to fit your local Scilab installation + +Then type + + make all + ./myprog + +[2] Windows (sources are myprog.c and ccmatrix1.cpp ) + nmake /f Makefile.mak all /a + + ..\..\..\..\..\..\bin\prog.exe + +Update INRIA 2007 diff --git a/modules/call_scilab/examples/call_scilab/fortran/callsci.f b/modules/call_scilab/examples/call_scilab/fortran/callsci.f new file mode 100755 index 000000000..7901f75b4 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/fortran/callsci.f @@ -0,0 +1,85 @@ + program callsci +c!Purpose +c Example of calling scilab from an other C or Fortran program +c!Description +c This program demonstrate on a simple example to use scilab as a +c procedure for an other program +c The computations performed are: +c -1- computation of x such that a*x=b (a and b real matrices) +c -2- computation of y=a*x-b +c All scilab functions and instructions may be used in this context +c for complex instruction, it may be usefull to defined it in a file +c and use exec +c! +c Copyright INRIA +c + dimension a(2,2),b(2),x(2),y(2) + double precision a,b,x,y +c +c a and b definition +c + a(1,1)=1.d0 + a(2,1)=2.d0 + a(1,2)=3.d0 + a(2,2)=4.d0 + b(1)=1.d0 + b(2)=0.d0 + +c create temp directory + call settmpdir + +c +c call to inisci for Scilab initializations +c 10000 is the initial stack size +c + call inisci(-1,10000, ierr) + if(ierr.gt.0) stop +c +c scilab start-up execution. quit added to leave parser after +c start-up execution +c + call scirun('exec(''SCI/etc/scilab.start'',-1);quit') +c +c Program's variables a and b sent to Scilab. +c . 2nd argument of matz not referenced here. +c . 3rd argument is the first dimension of the transmitted +c . variable (here dimension a(2,.) ) +c . arguments #3 and 4 represent the number of rows and columns +c . respectively +c . argument #5 is a character string name of the scilab variable +c . argument #6 (here job=1) means direction fortran--->scilab +c + call matz(a,a,2,2,2,'a',1) + call matz(b,b,2,2,1,'b',1) +c +c call scirun to solve the problem +c . \\ needed to enter a \ in fortran string +c + call scirun('x=a\\b;quit') +c +c Scilab variable x get in program and displayed +c . the numbers m and n (dimensions of x) are here given +c . by scilab .Don't give numerical values to arguments +c . 4 and 5 of matz here. +c . last argument (job=0) means: scilab --->program + + call matz(x,x,2,m,n,'x',0) + write(6,100) x(1),x(2) + 100 format('x = [',2x,f10.5,2x,f10.5,']') +c +c call scilab to check the result +c . note -1- a,x,b are still in the scilab stack +c . -2- this computation might be done in the first call to scirun + call scirun('y=a*x-b;quit') +c +c Scilab variable y get in program and displayed +c + call matz(y,y,2,m,n,'y',0) + write(6,110) y(1),y(2) +110 format('a*x-b = [',2x,f10.5,2x,f10.5,']') +c +c stop properly +c +c call sciquit + stop + end diff --git a/modules/call_scilab/examples/call_scilab/fortran/example.sln b/modules/call_scilab/examples/call_scilab/fortran/example.sln new file mode 100755 index 000000000..d59459e56 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/fortran/example.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "example", "example.vfproj", "{B6C96508-D326-4691-A49D-FD9D8A369A44}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B6C96508-D326-4691-A49D-FD9D8A369A44}.Debug|Win32.ActiveCfg = Debug|Win32 + {B6C96508-D326-4691-A49D-FD9D8A369A44}.Debug|Win32.Build.0 = Debug|Win32 + {B6C96508-D326-4691-A49D-FD9D8A369A44}.Debug|x64.ActiveCfg = Debug|x64 + {B6C96508-D326-4691-A49D-FD9D8A369A44}.Debug|x64.Build.0 = Debug|x64 + {B6C96508-D326-4691-A49D-FD9D8A369A44}.Release|Win32.ActiveCfg = Release|Win32 + {B6C96508-D326-4691-A49D-FD9D8A369A44}.Release|Win32.Build.0 = Release|Win32 + {B6C96508-D326-4691-A49D-FD9D8A369A44}.Release|x64.ActiveCfg = Release|x64 + {B6C96508-D326-4691-A49D-FD9D8A369A44}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/modules/call_scilab/examples/call_scilab/fortran/example.vfproj b/modules/call_scilab/examples/call_scilab/fortran/example.vfproj new file mode 100755 index 000000000..9deaf8a9c --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/fortran/example.vfproj @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<VisualStudioProject ProjectCreator="Intel Fortran" Keyword="Console Application" Version="11.0" ProjectIdGuid="{B6C96508-D326-4691-A49D-FD9D8A369A44}"> + <Platforms> + <Platform Name="Win32"/> + <Platform Name="x64"/></Platforms> + <Configurations> + <Configuration Name="Debug|Win32" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;$(TargetPath)"> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" AdditionalIncludeDirectories="../../../../core/includes" ExternalNameInterpretation="extNameLowerCase" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" Traceback="true" BoundsCheck="true" RuntimeLibrary="rtMultiThreadedDebug"/> + <Tool Name="VFLinkerTool" OutputFile="../../../../../bin/example.exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="../../../../../bin" GenerateDebugInformation="true" ProgramDatabaseFile="$(OUTDIR)/example.pdb" SubSystem="subSystemConsole" AdditionalDependencies="core_f.lib elementary_functions_f.lib output_stream.lib"/> + <Tool Name="VFResourceCompilerTool"/> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFPreLinkEventTool"/> + <Tool Name="VFPreBuildEventTool"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration> + <Configuration Name="Release|Win32" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;$(TargetPath)"> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" ExternalNameInterpretation="extNameLowerCase" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/"/> + <Tool Name="VFLinkerTool" OutputFile="../../../../../bin/example.exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" SubSystem="subSystemConsole" AdditionalDependencies="../../../../../bin/core.lib"/> + <Tool Name="VFResourceCompilerTool"/> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFPreLinkEventTool"/> + <Tool Name="VFPreBuildEventTool"/> + <Tool Name="VFPostBuildEventTool"/></Configuration> + <Configuration Name="Debug|x64" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;$(TargetPath)"> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" AdditionalIncludeDirectories="../../../../core/includes" ExternalNameInterpretation="extNameLowerCase" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" Traceback="true" BoundsCheck="true" RuntimeLibrary="rtMultiThreadedDebug"/> + <Tool Name="VFLinkerTool" OutputFile="../../../../../bin/example.exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="../../../../../bin" GenerateDebugInformation="true" ProgramDatabaseFile="$(OUTDIR)/example.pdb" SubSystem="subSystemConsole" AdditionalDependencies="core_f.lib elementary_functions_f.lib output_stream.lib"/> + <Tool Name="VFResourceCompilerTool"/> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFPreLinkEventTool"/> + <Tool Name="VFPreBuildEventTool"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration> + <Configuration Name="Release|x64" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;$(TargetPath)"> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" ExternalNameInterpretation="extNameLowerCase" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/"/> + <Tool Name="VFLinkerTool" OutputFile="../../../../../bin/example.exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" SubSystem="subSystemConsole" AdditionalDependencies="../../../../../bin/core.lib"/> + <Tool Name="VFResourceCompilerTool"/> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFPreLinkEventTool"/> + <Tool Name="VFPreBuildEventTool"/> + <Tool Name="VFPostBuildEventTool"/></Configuration></Configurations> + <Files> + <Filter Name="Header Files" Filter="fi;fd"/> + <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"/> + <Filter Name="Source Files" Filter="f90;for;f;fpp;ftn;def;odl;idl"> + <File RelativePath="callsci.f"/> + <File RelativePath=".\matz.f"/></Filter> + <File RelativePath="..\..\..\..\..\bin\core.lib"/> + <File RelativePath=".\readme.txt"/></Files> + <Globals/></VisualStudioProject> diff --git a/modules/call_scilab/examples/call_scilab/fortran/matz.f b/modules/call_scilab/examples/call_scilab/fortran/matz.f new file mode 100755 index 000000000..728a20cd2 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/fortran/matz.f @@ -0,0 +1,124 @@ +c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +c Copyright (C) INRIA +c +c This file must be used under the terms of the CeCILL. +c This source file is licensed as described in the file COPYING, which +c you should have received as part of this distribution. The terms +c are also available at +c http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + + subroutine matz(ar,ai,lda,m,n,name,job) +c!purpose +c matz reads or writes in scilab's internal stack +c +c!calling sequence +c +c integer lda,m,n,job +c character*(*) name +c double precision ar(lda,*),ai(lda,*) +c +c ar,ai : working array of size n*lda. Contains the a matrix +c If a is real ai is null +c lda : number of rows in the calling program +c name : character string; name of the scilab variable. +c job : job= 0 scilab -> fortran , real matrix +c job= 1 fortran -> scilab , real matrix +c job=10 scilab -> fortran , complex matrix +c job=11 fortran -> scilab , complex matrix +c +c CAUTION: For scilab->fortran m and n +c are defined by matz. Calling sequence must be: +c call matz(x,y,lda,m,n,name,0) and NOT +c call matz(x,y,lda,10,10,name,0) in the case where a +c is a 10 by 10 matrix. (Here y is not referenced: real case). +c +c! + integer lda,m,n,job + character*(*) name + double precision ar(lda,*),ai(lda,*) +c + include 'stack.h' + integer iadr,sadr + integer il,it,l,l4,lec,srhs,id(nsiz) +c + iadr(l)=l+l-1 + sadr(l)=(l/2)+1 +c + it=0 + if(job.ge.10) it=1 + lec=job-10*it +c + lon=0 + lon1=len(name) + do 100 i=1,lon1 + if(name(i:i).eq.char(0)) goto 200 + lon=lon+1 + 100 continue + 200 continue + if((lon1.gt.0).and.(lon1.lt.lon)) then + ln=lon1 + else + ln=lon + endif + ln=min(nlgh,ln) + call cvname(id,name(1:ln),0) + srhs=rhs + rhs=0 +c + if(lec.ge.1) goto 10 +c +c read : from scilab stack -> fortran variable ar +c ------- +c + fin=-1 + call stackg(id) + if (err .gt. 0) return + if (fin .eq. 0) then + call putid(ids(1,pt+1),id) + call error(4) + return + endif + il=iadr(lstk(fin)) + if(istk(il).ne.1.or.istk(il+3).ne.it) call error(44) + if(err.gt.0) return + m=istk(il+1) + n=istk(il+2) + l=sadr(il+4) + call dmcopy(stk(l),m,ar,lda,m,n) + if(it.eq.1) call dmcopy(stk(l+m*n),m,ai,lda,m,n) + goto 99 +c +c write : fortran -> scilab +c -------- +c + 10 if(top+2.ge.bot) then + call error(18) + return + endif + top=top+1 + il=iadr(lstk(top)) + l=sadr(il+4) + err=l+m*n*(it+1)-lstk(bot) + if(err.gt.0) then + call error(17) + return + endif + istk(il)=1 + istk(il+1)=m + istk(il+2)=n + istk(il+3)=it +c + call dmcopy(ar,lda,stk(l),m,m,n) + if(it.eq.1) call dmcopy(ai,lda,stk(l+m*n),m,m,n) + lstk(top+1)=l+m*n*(it+1) + l4=lct(4) + lct(4)=-1 + call stackp(id,0) + lct(4)=l4 + if(err.gt.0) return + goto 99 +c + 99 rhs=srhs + return +c + end diff --git a/modules/call_scilab/examples/call_scilab/fortran/readme.txt b/modules/call_scilab/examples/call_scilab/fortran/readme.txt new file mode 100755 index 000000000..95a285987 --- /dev/null +++ b/modules/call_scilab/examples/call_scilab/fortran/readme.txt @@ -0,0 +1,26 @@ + An example of calling scilab as a subroutine of a user's main program + + Requirements Intel Fortran 2011 and Visual Studio 2010 IDE + + +Useful files +============ + + * callsci.f: Fortran Example of a usermain program. This main program send matrices + (call matz) and commands (call scirun) to scilab and + gets the results back (call matz). + +Usage +===== + from this directory : + + set SCI=<your current scilab path ex: d:/scilab> + set TMPDIR=%TEMP% + set HOME=%SCI% + set TCL_LIBRARY=%SCI%\modules\tclsci\tcl\tcl8.5 + set TK_LIBRARY=%SCI%\modules\tclsci\tcl\tk8.5 + + ../../../../bin/example.exe + +INRIA 2006 A.C +DIGITEO 2012 - Allan CORNET diff --git a/modules/call_scilab/examples/readme.txt b/modules/call_scilab/examples/readme.txt new file mode 100755 index 000000000..e2dee6f14 --- /dev/null +++ b/modules/call_scilab/examples/readme.txt @@ -0,0 +1,19 @@ +Examples about the Scilab <=> C/C++/C#/VB/Fortran languages + +call_scilab/c : +How to call scilab from C + +call_scilab/cpp : +How to call scilab from C++ + +call_scilab/fortran : +How to call scilab from fortran + +call_scilab/NET/C# : +How to call scilab from C# + +call_scilab/NET/VB.NET : +How to call scilab from VB.NET + +DIGITEO - 2009 +Allan CORNET |