Insert variable in script

Asked

Viewed 53 times

1

I have the following script working normally

@echo off

if %time:~0,8%  LEQ 11:59:59 goto manha
if %time:~0,8%  LEQ 17:59:59 goto tarde
if %time:~0,8%  LEQ 23:59:59 goto noite

:manha
    echo "BOM DIA"
    Pause

:tarde
    echo "BOA TARDE"
    Pause

:noite
    echo "BOA NOITE"
    Pause

I would like to insert a variable to be able to use in other lines, Example of the code below that did not work:

@echo off

if %time:~0,8%  LEQ 11:59:59 goto manha
if %time:~0,8%  LEQ 17:59:59 goto tarde
if %time:~0,8%  LEQ 23:59:59 goto noite



:manha
    set saudacao= "BOM DIA"


:tarde
    set saudacao= "BOA TARDE"


:noite
    set saudacao= "BOA NOITE"


echo %saudacao% , Resto da frase
pause

Does anyone know what I’m missing? Thank you in advance!

1 answer

2


Friend, in this second script is missing the goto after each sentence:

Example:

@echo off

if %time:~0,8%  LEQ 11:59:59 goto manha
if %time:~0,8%  LEQ 17:59:59 goto tarde
if %time:~0,8%  LEQ 23:59:59 goto noite

:manha
    set saudacao= "BOM DIA"
    goto fim


:tarde
    set saudacao= "BOA TARDE"
    goto fim
:noite
    set saudacao= "BOA NOITE"
    goto fim
:fim
   echo %saudacao% , Resto da frase
   pause
  • Thanks again! D

  • Please friend finish both items and if you can evaluate me. Hugs.

  • need 15 rep. to evaluate ;/ Sorry

Browser other questions tagged

You are not signed in. Login or sign up in order to post.