22

So.. This is (to me anyway) the most important feature of this program. I need this to work. Please don't laugh.. (okay you can laugh) but when my program errors, I want it to display this:

          _ _,---._ 
       ,-','       `-.___ 
      /-;'               `._ 
     /\/          ._   _,'o \ 
    ( /\       _,--'\,','"`. ) 
     |\      ,'o     \'    //\ 
     |      \        /   ,--'""`-. 
     :       \_    _/ ,-'         `-._ 
      \        `--'  /                ) 
       `.  \`._    ,'     ________,',' 
         .--`     ,'  ,--` __\___,;' 
          \`.,-- ,' ,`_)--'  /`.,' 
           \( ;  | | )      (`-/ 
             `--'| |)       |-/ 
               | | |        | | 
               | | |,.,-.   | |_ 
               | `./ /   )---`  ) 
              _|  /    ,',   ,-' 
             ,'|_(    /-<._,' |--, 
             |    `--'---.     \/ \ 
             |          / \    /\  \ 
           ,-^---._     |  \  /  \  \ 
        ,-'        \----'   \/    \--`. 
       /            \              \   \ 

Echoing each line doesn't work...

echo              _ _,---._ 
echo           ,-','       `-.___ 
echo          /-;'               `._ 
echo         /\/          ._   _,'o \ 
echo        ( /\       _,--'\,','"`. ) 
echo         |\      ,'o     \'    //\ 
echo         |      \        /   ,--'""`-. 
echo         :       \_    _/ ,-'         `-._ 
echo          \        `--'  /                ) 
echo           `.  \`._    ,'     ________,',' 
echo             .--`     ,'  ,--` __\___,;' 
echo              \`.,-- ,' ,`_)--'  /`.,' 
echo               \( ;  | | )      (`-/ 
echo                 `--'| |)       |-/ 
echo                   | | |        | | 
echo                   | | |,.,-.   | |_ 
echo                   | `./ /   )---`  ) 
echo                  _|  /    ,',   ,-' 
echo                 ,'|_(    /-<._,' |--, 
echo                 |    `--'---.     \/ \ 
echo                 |          / \    /\  \ 
echo               ,-^---._     |  \  /  \  \ 
echo            ,-'        \----'   \/    \--`. 
echo           /            \              \   \ 

I'm assuming this is because of the symbols in the text. Any way to fix it? Or do I need to give up on the "DOH" screen?

aschipfl
  • 28,946
  • 10
  • 45
  • 77
user2863294
  • 292
  • 1
  • 2
  • 10

6 Answers6

25

Include the following in your script:

:::
:::              _ _,---._
:::           ,-','       `-.___
:::          /-;'               `._
:::         /\/          ._   _,'o \
:::        ( /\       _,--'\,','"`. )
:::         |\      ,'o     \'    //\
:::         |      \        /   ,--'""`-.
:::         :       \_    _/ ,-'         `-._
:::          \        `--'  /                )
:::           `.  \`._    ,'     ________,','
:::             .--`     ,'  ,--` __\___,;'
:::              \`.,-- ,' ,`_)--'  /`.,'
:::               \( ;  | | )      (`-/
:::                 `--'| |)       |-/
:::                   | | |        | |
:::                   | | |,.,-.   | |_
:::                   | `./ /   )---`  )
:::                  _|  /    ,',   ,-'
:::                 ,'|_(    /-<._,' |--,
:::                 |    `--'---.     \/ \
:::                 |          / \    /\  \
:::               ,-^---._     |  \  /  \  \
:::            ,-'        \----'   \/    \--`.
:::           /            \              \   \
:::

for /f "delims=: tokens=*" %%A in ('findstr /b ::: "%~f0"') do @echo(%%A

The image could be placed anywhere within the script. It does not need to be near the FOR statement. I chose ::: as a distinguishing label for each image line because : is used for normal labels, and :: is frequently used as a comment.

2014-10-22 Update

There is an even simpler solution using my REPL.BAT utility - a hybrid JScript/batch script that performs a regex search/replace on stdin and writes the result to stdout. Simply substitute the following line for the FOR statement above:

call repl "^:::" "" a <"%~f0"

REPL.BAT is pure script that will run on any Windows machine from XP onward. Full documentation is embedded within the script. This solution uses the A option to only print lines that were altered.

Community
  • 1
  • 1
dbenham
  • 119,153
  • 25
  • 226
  • 353
17

Store image in a file (doh.txt). Then type doh.txt in the batch file.

Malk
  • 11,107
  • 4
  • 31
  • 32
  • Thanks for the quick response. I'd really prefer for it to load the ASCII in the cmd prompt though, because it's going to prompt the user for input after the error. – user2863294 Oct 28 '13 at 18:56
  • @user2863294 - Your comment doesn't make sense to me. Your batch script can simply prompt the user for error after it prints the file content to the screen using TYPE. – dbenham Oct 28 '13 at 21:48
  • OH! I was on a tablet and I didn't realize "type" was part of the command! Brilliant! – user2863294 Oct 28 '13 at 21:56
7
cat << "EOF"
          _ _,---._
       ,-','       `-.___
      /-;'               `._
     /\/          ._   _,'o \
    ( /\       _,--'\,','"`. )
     |\      ,'o     \'    //\
     |      \        /   ,--'""`-.
     :       \_    _/ ,-'         `-._
      \        `--'  /                )
       `.  \`._    ,'     ________,','
         .--`     ,'  ,--` __\___,;'
          \`.,-- ,' ,`_)--'  /`.,'
           \( ;  | | )      (`-/
             `--'| |)       |-/
               | | |        | |
               | | |,.,-.   | |_
               | `./ /   )---`  )
              _|  /    ,',   ,-'
             ,'|_(    /-<._,' |--,
             |    `--'---.     \/ \
             |          / \    /\  \
           ,-^---._     |  \  /  \  \
        ,-'        \----'   \/    \--`.
       /            \              \   \
EOF
Tatekan
  • 121
  • 1
  • 4
6

You need to escape special characters (such as |, used for pipe redirection) in order for it to work.

However, when using echo not all special batch characters need to be escaped, as some as interpreted as text. The ones you still need to escape, and how to escape them, are:

% = %%

^ = ^^

& = ^&

< = ^<

> = ^>

| = ^|

And, if delayed expansion is enabled:

! = ^^!

0
@echo off
echo              _ _,---._ 
echo           ,-','       `-.___ 
echo          /-;'               `._ 
echo         /\/          ._   _,'o \ 
echo        ( /\       _,--'\,','"`. ) 
echo         ^|\      ,'o     \'    //\ 
echo         ^|      \        /   ,--'""`-. 
echo         :       \_    _/ ,-'         `-._ 
echo          \        `--'  /                ) 
echo           `.  \`._    ,'     ________,',' 
echo             .--`     ,'  ,--` __\___,;' 
echo              \`.,-- ,' ,`_)--'  /`.,' 
echo               \^( ;  ^| ^| )      ^(`-/ 
echo                 `--'^| ^|^)       ^|-/ 
echo                   ^| ^| ^|        ^| ^| 
echo                   ^| ^| ^|,.,-.   ^| ^|_ 
echo                   ^| `./ /   )---`  ) 
echo                  _^|  /    ,',   ,-' 
echo                 ,'^|_(    /-^<._,' ^|--, 
echo                 ^|    `--'---.     \/ \ 
echo                 ^|          / \    /\  \ 
echo               ,-^---._     ^|  \  /  \  \ 
echo            ,-'        \----'   \/    \--`. 
echo           /            \              \   \ 

http://www.robvanderwoude.com/escapechars.php

npocmaka
  • 51,748
  • 17
  • 123
  • 166
-5
echo this one works
echo '                ***     ***
echo                *     * *     *
echo                *    *   *    *
echo                 *** *    ****
echo                   *       *
echo                  *  0   0  *
echo                  *    !    *
echo                  *         *
echo                  *   ~~~   *
echo                  *         *
echo            ======           ======
echo            ======           ======
echo      ======                       ======
echo      ======                       ======
hben
  • 67
  • 1
  • 9