From: cabrego on
Steve,

Thanks for the very elegant solution!

Here is an adapted version of what you proposed:

[File, Path]=uigetfile('*.*','Select File');
fullfilename=fullfile(Path,File);

Prog=('"C:\Documents and Settings\prog"');

comm= sprintf('%s',Prog,' option ', fullfilename);
dos(comm)

Two questions:

1) Is there is away to wrap quotes around fullfilename since it will be a dynamic input defined from uigetfile and it may or may not have spaces in the path. The spaces causes problems wiht the dos application.

2) I changed the sprintf syntax a bit, it works but I wasn't really sure what I was doing. does that look ok to you?
From: Steven Lord on

"cabrego " <cpabrego(a)gmail.com> wrote in message
news:ht62qt$bff$1(a)fred.mathworks.com...
> Steve,
>
> Thanks for the very elegant solution!
>
> Here is an adapted version of what you proposed:
>
> [File, Path]=uigetfile('*.*','Select File');
> fullfilename=fullfile(Path,File);
>
> Prog=('"C:\Documents and Settings\prog"');
>
> comm= sprintf('%s',Prog,' option ', fullfilename); dos(comm)
> Two questions:
>
> 1) Is there is away to wrap quotes around fullfilename since it will be a
> dynamic input defined from uigetfile and it may or may not have spaces in
> the path. The spaces causes problems wiht the dos application.

The format string for SPRINTF can contain quote characters "" perfectly
fine, and DOS should be able to handle quote characters around an argument
that doesn't contain any spaces just as well as it can handle them around
arguments containing spaces.

> 2) I changed the sprintf syntax a bit, it works but I wasn't really sure
> what I was doing. does that look ok to you?

Technically this will work, but to make it easier for you I recommend
including one format specifier in the format string for each "thing" you
want to include in the output string.

comm = sprintf('%s %s %s', Prog, 'option', fullfilename)

I also suggest that you read through this page in the documentation as well,
as it describes how to use SPRINTF and friends to format strings.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f2-47856.html#bq0he44-1

--
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: cabrego on
here is a solution that meets my current requirements. Thanks for the tips!

[File, Path]=uigetfile('*.*','Select File');

fullfilename=fullfile(Path,File);

Prog=('"C:\Documents and Settings\prog"');%can clearn up with "%s" in comm

comm= sprintf('%s %s "%s"',Prog,' option ', fullfilename);

dos(comm)