1.

Solve : Batch File Parameters?

Answer»

I have a very simple batch file that echos data to a com port. I need to echo a data string that is passed in via a parameter. The problem is that the data string has spaces so when I try to pass it in to one variable, anything after the space gets cut off.

example:
(from other program): call test.bat blahblah blah

test.bat has one line:
echo %1 > com2

data spit out com2 port = blahblah (but not the final blah)

The reason I am doing it this way is becuase the data string has ascii character codes in it and I can't seem to figure out how to use those in this script. If I could do something like:
set data = CHR$(10) & chr$(255)
then I would need to two-step it.

What's the best approach here?

--Davethe data string has spaces in it? Why not enclose the string with quotes?

eggs and BACON

are three parameters, but

"eggs and bacon"

is one parameter, and you can use %~1 in the batch file to remove the quotes.

[edit] Of course, you might be using 'real' MS-DOS, in which case that won't work...

Maybe you could state what OS you are using?




Quote from: contrex on August 29, 2007, 12:53:56 PM


Maybe you could state what OS you are using?


I nominate this for quote of the Month...

It's on XP Pro, but the %~1 was EXACTLY what I was LOOKING for! Thanks!

--Dave


Discussion

No Comment Found