|
From: | Kire Pudsje |
Subject: | Re: Calling an octave function from a BAT file in windows |
Date: | Thu, 15 Dec 2016 16:07:20 +0100 |
Hi Kire,
Thanks for the hints. This is now my current working solution to handle a very general argument list (arguments separated by spaces). My solution is not beautiful, but for me reasonable ;-). More ideas anyone??
/Lars
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
From command line or script file (example):
myapp -flag1 data1 -flag2 optionA inputfile outputfile
The solution
---------------------------------------
A BAT file 'myapp.bat' to pass arguments to octave via a temporary file.
@echo off
echo %* > argin.txt
octave-cli -q --eval myapp
del argin.txt
---------------------------------------
An Octave wrapper script 'myapp.m' to read the list of arguments and send it as a 'varargin' list to 'myfunction'
fid=fopen('argin.txt','r');
line = fgetl(fid);
fclose(fid);
argin=strread(line,'%s');
[a,b]=myfunction(argin)
-----------------------------------------
My function 'myfunction' in 'myfunction.m'
function [out1,out2]=myfunction(varargin);
out1='foo';
out2='bar';
% process varargin for whatever purpose
On 12/14/2016 6:35 PM, Kire Pudsje wrote:
echo 1+1 | path\to\bin\octave-cli
ans = 2
orargv
make a script eg. testfile.m containing:
argv contains the normal input variables, like in C. No argc, but this is just numel(argv).
And run this withpath\to\bin\octave-cli -qf testfile.m arg1 arg2 arg3
ans =
{
[1,1] = arg1
[2,1] = arg2
[3,1] = arg3
}
2016-12-14 10:33 GMT+01:00 Lars Johansson <address@hidden>:
Hi ,
This issue has been up for discussion before, but a quick search did not result in very clear directions?!
Many years ago I used Matlab compiler (on Windows) to compile a function '[a,b]=myfunction(varargin)'. The result was here an executable 'myfunction.exe' that I called from the command line (or any batch procedure) like
>> myfunction arg1 arg2 arg3
a=
data1
data2
data3
....
b=
data4
data5
data6
....
I am now trying to come up with a BAT file 'myfunction.bat' to do more or less the same thing. Any input would be very much appreciated (here the output is less important than the passing of arguments).
Best regards,
/Lars
_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2016.0.7924 / Virus Database: 4739/13591 - Release Date: 12/14/16
[Prev in Thread] | Current Thread | [Next in Thread] |