Jump to content

Spaces In Run Command


Recommended Posts

Hi,

I have a problem with spaces in the Run() command.

The tips I found in the forum didn't help...

What I'm trying is this:

Run ($pgm_path & " " & $file, $work_dir, @SW_MAXIMIZE)

If the variable $pgm_path has spaces, Run won't work...

What can I do???? :ph34r:

Peter

Edited by spiderblues
Link to comment
Share on other sites

If the variable $pgm_path has spaces, Run won't work...

What can I do???? :ph34r:

<{POST_SNAPBACK}>

Enclose it in a set of double quotes:

Run ('"' & $pgm_path & '"' & " " & $file, $work_dir, @SW_MAXIMIZE)

This is so common that I have created a small UDF to do it for me. It works like this:

Run (path($pgm_path) & " " & path($file), path($work_dir), @SW_MAXIMIZE)

Func path($input)
  If StringLeft($input, 1) <> "'" Then $input = '"' & $input
  If StringRight($input, 1) <> '"' Then $input = $input & '"'
  return $input
EndFunc

That function will enclose whatever paramater you feed it with double quotes on either end if they are not present. Great for folder, file, and directory paths that may contain spaces.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

the function to enclose the parameter is working, but the run still don't work...

I tried this:

$cmd = path($pgm_path) & " " & path($file)
Msgbox(0,"",$cmd)
Run ('"'& $cmd & '"', path($work_dir), @SW_MAXIMIZE)

Output:

"C:\Programme\ACD Systems\ACDSee\ACDSee6.exe" "test.jpg"

Looks good, but ACDSee don't run...

Link to comment
Share on other sites

The whole point is that the space has to be inside the double quotes, not outside. What you have effectivally done is used my small routine to attach a set of double quotes around each segment that is before and after the space you include, which will be treated as 2 seperate paramaters.

If you ever want to use a paramater with a space or other reserved character in DOS, it must be enclosed in a string to be processed as a single paramater. Otherwise, in almost every case, it will be interperted as a 2nd paramater.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

The strange thin is, that it's working with other programms with spaces in the pathname (like idoswin pro) but not with acdsee!

I tried to run acdsee from the command line, and that didn't work, too!

So I think, it's acdsee...

Thanks for you help.

Peter

Link to comment
Share on other sites

The strange thin is, that it's working with other programms with spaces in the pathname (like idoswin pro) but not with acdsee!

I tried to run acdsee from the command line, and that didn't work, too!

So I think, it's acdsee...

<{POST_SNAPBACK}>

Each application parses the command line paramaters a bit differently. However, in most cases, spaces will determine an additional paramater. It's just a good habbit to get into of enclosing phrases or paths in double quotes if they could contain a space.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...