Set Space for Text

2

Good afternoon, I would like to know if there is any cmd command to set a fixed space for the text, so that it does not change the position of the rest of the sentence.

In the example below, this space is the * ㅤ ㅤ ㅤ *

My name is * Carlos ㅤ ㅤ ㅤ *, here comes the rest of the sentence
My name is * João vitor ㅤ ㅤ *, here enters the rest of the sentence
My name is * Alexssandra ㅤ *, here comes the rest of the sentence

    
asked by anonymous 18.10.2018 / 18:17

1 answer

2

You can compose your string by concatenating the first two parts by adding the spaces, picking a substring, and adding the ending. see the example below.

@echo off
setlocal

set "espaco=                       "
set "prefixo=Meu nome é"
set "frase= ,aqui entra o resto da frase"

set "nome=Carlos"
set "linha1=%prefixo% %nome%%espaco%"
set "linha1=%linha1:~0,24% %frase%

set "nome=João Vitor"
set "linha2=%prefixo% %nome%%espaco%"
set "linha2=%linha2:~0,24% %frase%

set "nome=Alexssandra"
set "linha3=%prefixo% %nome%%espaco%"
set "linha3=%linha3:~0,24% %frase%

echo %linha1%  & echo %linha2%  & echo %linha3%

    
18.10.2018 / 19:01