Limiting echo & Output word "on"

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
drgt
Posts: 144
Joined: 21 Sep 2010 02:22

Limiting echo & Output word "on"

#1 Post by drgt » 14 Nov 2021 03:35

1. How to limit what echo is to process, without splitting the line?

example

Code: Select all

Prompt:>if 2 GTR 1 echo bigger else echo lesser
result: bigger else echo lesser
2. How to echo "ON" instead of turning echo on?
Last edited by drgt on 14 Nov 2021 12:10, edited 1 time in total.

T3RRY
Posts: 194
Joined: 06 May 2020 10:14

Re: Limiting echo

#2 Post by T3RRY » 14 Nov 2021 04:44

drgt wrote:
14 Nov 2021 03:35
1. How to limit what echo is to process, without splitting the line?

example

Code: Select all

Prompt:>if 2 GTR 1 echo bigger else echo lesser
result: bigger else echo lesser
2. How to echo "ON" instead of turning echo on?
Your problem is not with echo, it's with your failure to use correct If else syntax:

Code: Select all

if ( command ) else othercommand

drgt
Posts: 144
Joined: 21 Sep 2010 02:22

Re: Limiting echo & Output word "on"

#3 Post by drgt » 14 Nov 2021 12:15

Thank you for showing my omission :(
Answers
1

Code: Select all

C:\>if 2 gtr 1 (echo greater) else (echo equal or lesser)
2

Code: Select all

C:\>echo.on

aGerman
Expert
Posts: 4325
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Limiting echo & Output word "on"

#4 Post by aGerman » 15 Nov 2021 05:27

Code: Select all

echo(on
Looks definitely weird, but we have lengthy threads here where the outcome is that the lone standing left parenthesis has the fewest side effects, while the period is rather the worst case (even if it is still quite common).

Steffen

drgt
Posts: 144
Joined: 21 Sep 2010 02:22

Re: Limiting echo & Output word "on"

#5 Post by drgt » 18 Nov 2021 23:40

Code: Select all

echo(on
Thanks for the alternative.
Searching for "echo the word on" (at least on the first few results) I did not see any references to the "side effects"

jeb
Expert
Posts: 993
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Limiting echo & Output word "on"

#6 Post by jeb » 19 Nov 2021 02:12


drgt
Posts: 144
Joined: 21 Sep 2010 02:22

Re: Limiting echo & Output word "on"

#7 Post by drgt » 20 Nov 2021 03:17

Thank you JEB

Post Reply