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

Author Topic: Variable in script.  (Read 2257 times)

0 Members and 1 Guest are viewing this topic.

Woodman

    Topic Starter


    Beginner
    Variable in script.
    « on: December 04, 2008, 01:55:38 AM »
    Win XP H  SP3

    When the following script is run, without a value being entered for %1, %a% is set to 'ECHO is off.' without the '  ' - how can I prevent this happening please?

    Code: [Select]
    @echo off
    cls

    set a=%1

    echo %a% > %temp%\length.txt
    for %%a in (%temp%\length.txt) do set /a length=%%~za%-4


    echo %length%
    type %temp%\length.txt

     

    Prince_



      Beginner

      Thanked: 5
      Re: Variable in script.
      « Reply #1 on: December 04, 2008, 02:29:21 AM »
      Quote
      @echo off
      cls

      set a=%1

      echo.%a% > %temp%\length.txt
      for %%a in (%temp%\length.txt) do set /a length=%%~za%-4


      echo %length%
      type %temp%\length.txt

      Woodman

        Topic Starter


        Beginner
        Re: Variable in script.
        « Reply #2 on: December 04, 2008, 01:04:17 PM »
        Thank you for the very speedy solution.

        W.