"Al Dunbar" <> wrote in message
news:...
>
> "Pegasus (MVP)" <> wrote in message
> news:...
>>
>> <> wrote in message
>> news:6aca5e7e-9cbc-4cb1-b661-...
>>> I'm using windows batch scripts. Is there a way to echo variables to
>>> specific column positions consistently? I've got VAR1 & VAR2 that can
>>> vary from 5 to 40 characters in length that I'm echoing on the same
>>> line. So I'm trying:
>>>
>>> echo %VAR1% %VAR2%
>>>
>>> ...and I'd like the results in the column for VAR2 to line up. I can
>>> echo using tabs or spaces, but this shifts the VAR2 position a bit
>>> depending on the value in VAR1. Is there any way to force my %VAR2% to
>>> echo at a specific column position?
>>
>> Try this:
>> @echo off
>> set var=%VAR1% $
>> echo %var:~0,50%%VAR2%
>>
>> Remove the "$" character - I only put it there to mark the end of the
>> many spaces I added to this line.
>
> Interesting approach, I had not thought of doing it that way.
>
> But to avoid having to use a marker like "$" and take it out because you
> do not want it in the output, I'd suggest using parentheses:
>
> @echo off
> (set var=%VAR1% )
> echo %var:~0,50%%VAR2%
>
> /Al
Yes, the parentheses are nicer than the $ marker, especially from a script
maintenance point of view.
|