Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Simple Batch Text Editor Plzzz help  (Read 1572 times)

0 Members and 1 Guest are viewing this topic.

zask

    Topic Starter


    Intermediate

    • Experience: Experienced
    • OS: Other
    Simple Batch Text Editor Plzzz help
    « on: January 16, 2016, 04:09:55 PM »
    I am trying to make a batch file that creates messages for other batch files. It first ask for a name to name the file it creates. then then asks to display a message which goes into a spinner for 20 loops and then displays if you would like to clear the screen or continue typing. The problem is that every time I type (Y) in the prompt to clear the text of the created batch file, the prompt closes for an unknown reason. can anyone help?

    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION
    color 17
    echo                              浜様様様様様様様様様
    echo                              Batch Text Editor                 
    echo                              藩様様様様様様様様様
    echo.
    pause
    :Restart2
    cls
    SET /p "FileName= Enter the name of the file you want to name: "
    echo @echo off > %FileName%.bat
    echo The file %FileName%.bat was created!
    pause
    cls
    SET X=1


    :Restart1
    if %X% EQU 1 echo Line (1)
    SET /p "Message= Type message here: "
    echo echo %Message% >> %FileName%.bat

    ) ELSE (
    SET /a X+=1
    )
    if !X! EQU 21 goto Reboot
    echo Line (%X%)
    goto Restart1

    :Reboot
    echo pause >> %FileName%.bat
    SET /p "YN=Would you like to clear the screen? (Y/N): "
    if %YN%==Y echo. > %FileName%.bat
    if %YN%==y echo. > %FileName%.bat
    if %YN%==N echo goto Restart2
    if %YN%==n echo goto Restart2
    « Last Edit: January 16, 2016, 04:30:29 PM by zask »

    zask

      Topic Starter


      Intermediate

      • Experience: Experienced
      • OS: Other
      Re: Simple Batch Text Editor
      « Reply #1 on: January 16, 2016, 04:16:59 PM »
      Ill be here if anyone can help.

      Salmon Trout



        Genius

        Thanked: 972
        • Yes
      • Computer: Specs
      • Experience: Experienced
      • OS: Other
      Re: Simple Batch Text Editor Plzzz help
      « Reply #2 on: January 17, 2016, 02:55:25 AM »
      Your IF - ELSE block after label Restart1 does not look right. There is no opening parenthesis ending the IF line.

      Also not connected to the problem I think:

      You did know that you don't need to test separately for upper and lower case?

      Instead of this:

      If %var%==N bla bla bla
      If %var%==n bla bla bla

      You can use the /i switch for IF which ignores case:

      If /i %var%==N bla bla bla



      zask

        Topic Starter


        Intermediate

        • Experience: Experienced
        • OS: Other
        Re: Simple Batch Text Editor Plzzz help
        « Reply #3 on: January 17, 2016, 10:10:24 AM »
        Your IF - ELSE block after label Restart1 does not look right. There is no opening parenthesis ending the IF line.

        Also not connected to the problem I think:

        You did know that you don't need to test separately for upper and lower case?

        Instead of this:

        If %var%==N bla bla bla
        If %var%==n bla bla bla

        You can use the /i switch for IF which ignores case:

        If /i %var%==N bla bla bla
        no i did not know that, thanks!