From: cabrego on
Hi all,
I am writing a code in Matlab that I would eventually like to compile as a stand alone executable. The part of the code I am having problems with is pretty basic.

I would like to import a file using uigetfile and use the filename and path stored as inputs into a dos executable ('prog'). It seems simple enough but I am having troubles inputing options,

here is what I have so far:

[file, path]=uigetfile('*.*','Select File');
dos('C:\Documents and Settings\..\My Documents\prog')

The executable is prog and prog requires an option input, which will be constant, and is in a different directory. I would like to program it in a general sense, so there are no directory requirements associated with this function. The format I have tested in the cmd shell is:

>'C:\Documents and Settings\..\My Documents\prog' option 'path\file'

My problem is I cant figure out how to link the file and path into my dos() command. hope this makes sense...
From: TideMan on
On May 21, 7:06 am, "cabrego " <cpabr...(a)gmail.com> wrote:
> Hi all,
> I am writing a code in Matlab that I would eventually like to compile as a stand alone executable. The part of the code I am having problems with is pretty basic.
>
> I would like to import a file using uigetfile and use the filename and path stored as inputs into a dos executable ('prog').  It seems simple enough but I am having troubles inputing options,
>
> here is what I have so far:
>
> [file, path]=uigetfile('*.*','Select  File');
> dos('C:\Documents and Settings\..\My Documents\prog')
>
> The executable is prog and prog requires an option input, which will be constant, and is in a different directory.  I would like to program it in a general sense, so there are no directory requirements associated with this function.  The format I have tested in the cmd shell is:
>
> >'C:\Documents and Settings\..\My Documents\prog' option 'path\file'
>
> My problem is I cant figure out how to link the  file and path into my dos() command.    hope this makes sense...

Surround it in square brackets:
comm=['C:\Documents and Settings\..\My Documents\prog' option 'path
\file'];
dos(comm)
Note: you may need to add some spaces like this:
comm=['C:\Documents and Settings\..\My Documents\prog ' option ' path
\file']
and I think DOS has problems with spaces in commands, so I'd enclose
the program command in double quotes:
comm=['"C:\Documents and Settings\..\My Documents\prog" ' option ' path
\file']

When I have complicated command lines like this, I always assign them
to string and check that the string is correct before sending it to
dos or system.
From: cabrego on
Thanks for the tips but none of that is working for me. None of your comm variables are being stored properly either.

Note that in my example above path and fileare actually variables stored in the uigetfile function.
From: Steven Lord on

"cabrego " <cpabrego(a)gmail.com> wrote in message
news:ht416s$luh$1(a)fred.mathworks.com...
> Hi all,
> I am writing a code in Matlab that I would eventually like to compile as a
> stand alone executable. The part of the code I am having problems with is
> pretty basic.
>
> I would like to import a file using uigetfile and use the filename and
> path stored as inputs into a dos executable ('prog'). It seems simple
> enough but I am having troubles inputing options,
> here is what I have so far:
>
> [file, path]=uigetfile('*.*','Select File');
> dos('C:\Documents and Settings\..\My Documents\prog')
>
> The executable is prog and prog requires an option input, which will be
> constant, and is in a different directory. I would like to program it in
> a general sense, so there are no directory requirements associated with
> this function. The format I have tested in the cmd shell is:
>
>>'C:\Documents and Settings\..\My Documents\prog' option 'path\file'
>
> My problem is I cant figure out how to link the file and path into my
> dos() command. hope this makes sense...

Adapt this example to your code:

[file, path] = uigetfile('*.m', 'Select File');
fullFilename = fullfile(path, file)
constructedCommand = sprintf('dir %s', fullFilename)
dos(constructedCommand)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: TideMan on
On May 21, 8:26 am, "cabrego " <cpabr...(a)gmail.com> wrote:
> Thanks for the tips but none of that is working for me.  None of your comm variables are being stored properly either.
>
> Note that in my example above path and fileare actually variables stored in the uigetfile function.

Well, why did you enclosed them in quotes then?
That was just plain silly.
Use your loaf a bit, rather than blindly copying what I give you.
And don't say "your comm variables".
It's your bloody problem, not mine.

comm=['"C:\Documents and Settings\cabrego\My Documents\prog" ' option
' ' path file]
This assumes that option, path and file are all strings.

Note: you will have to edit what I have given you to substitute the
appropriate values for YOUR problem.