<< .sce => .exe .sce => .exe Utilities >>

.sce => .exe >> .sce => .exe > scetoexe

scetoexe

generates an executable script.exe file from a Scilab script.sce

Syntax

[output, OK, exitCode] = scetoexe(scriptSCE, outDir, devenvPath, cleanTMPdir)

Arguments

scriptSCE

string providing the path+filename of the *.sce Scilab script to be processed.

outDir

string providing the path of the directory where the final script.exe must be stored. By default, the directory where scriptSCE stands is considered. This directory must be writable. Use "" to skip it (and then use the default).

devenvPath

string providing the path+filename of the devenv.exe program of the Visual Studio C compiler installed on your computer. This is required when haveacompiler() returns %F despite a Visual Studio compiler is actually installed, including the devenv.exe program required by scetoexe(). "devenv" (with no path) is the default value, that may be used to skip it.

cleanTMPdir

boolean (default = %t). If it is set to %F, then the set of C-compilable files copied in the TMPDIR/scripSCEname subdirector to build the .exe are left, instead of being removed. When the build fails, error logs from the compiler may be also present in this directory.

output

Column of text: output returned by Windows after calling the devenv compiler.

OK

Boolean: %T if the devenv compiler has been actually called, and Windows has understood the call without error. %F otherwise.

exitCode

Exit code returned by the MS Windows shell when calling the compiler.

Description

scetoexe() tries to build an executable file.exe from the input script file written in Scilab language.
  • A Visual Studio C compiler must be available on the computer where Scilab runs scetoexe().
  • The executable script.exe file won't be a stand-alone: Scilab must be installed where script.exe is run.

A compilable set of files is created in the TMPDIR\scriptName each time scetoexe() is run. If this directory already exists, it is automatically deleted and then recreated.

Examples

// Display the demo sample file in console:
script = scetoexe_getRootPath() + "\demos\example.sce";
f = mgetl(script);
write(%io(2), f);

// Find the C compiler:
if ~isdef("devenv","l") & (~haveacompiler() | findmsvccompiler()=='unknown')
    devenv = uigetfile("*.exe","","Please select the ""devenv.exe"" compiler program");
end
if devenv==[]
    devenv = "devenv"
end
// We will store the .exe in TMPDIR
// Now build the .exe, and do not remove compilation files:  
[output, OK, exitCode] = scetoexe(script, TMPDIR, devenv, %f)

// Finally: start the .exe
if OK
    [a,b,c] = dos("start """+TMPDIR+"\example.exe""")
else
    cd(TMPDIR)
end
--> // Display the demo sample file in console:
--> script = scetoexe_getRootPath() + "\demos\example.sce";
--> f = mgetl(script);
--> write(%io(2), f);
// scetoexe module for Scilab
// Allan CORNET - 2010
//
// example script for scetoexe

disp("Hello from a .sce");

A = rand(5, 3);
mprintf("A = ");
disp(A);
C = A' * A;
disp("C = A'' * A =");
disp(C);

beep();
plot2d();
input("Press RETURN", "s");

--> // Find the C compiler:
--> if ~isdef("devenv","l") & (~haveacompiler() | findmsvccompiler()=='unknown')
  >     devenv = uigetfile("*.exe","","Please select the ""devenv.exe"" compiler program");
  > end

--> if devenv==[]
  >     devenv = "devenv"
  > end

--> [output, OK, exitCode] = scetoexe(script, TMPDIR, devenv, %f)
Please wait while building the .exe... Done
 exitCode  = 
   0.

 OK  = 
   T

 output  = 
   []

Authors

History

VersionDescription
0.2
  • scetoexe() introduced. Former functions become some internals. scetoexe() manages all steps all-in-one.
  • It is now possible to specify the output directory.
  • It is now possible to specify the path to the devenv.exe utility.

Report an issue
<< .sce => .exe .sce => .exe Utilities >>