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

Author Topic: %%BLAH or %BLAH%!??!?!?  (Read 5175 times)

0 Members and 1 Guest are viewing this topic.

tommyroyall

    Topic Starter


    Rookie

    Thanked: 1
    %%BLAH or %BLAH%!??!?!?
    « on: February 24, 2010, 07:38:17 PM »
    I know that %variables_have_percent_marks% but what %%is_this? is it also a variable?

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: %%BLAH or %BLAH%!??!?!?
    « Reply #1 on: February 24, 2010, 08:52:33 PM »
    Take a nice long look at for /? the next time you open the command prompt...you may just learn something.

    In the mean time, here is what you wanted:
    %variables% are used with the set command are are called variables. Whatever their value is replaces it.
    %%a is not an actual variable. It is a token used in for loops. It only substitutes the value while in a for loop. It can't be changed manually, like a regular variable.

    For example, both these codes will do the exact same thing, but they are different as you can see. 
    Code: [Select]
    @echo off
    :loop
    set /a num+=1
    echo %num%
    if %num%==10 goto stop
    goto loop
    :stop
    pause
    Code: [Select]
    @echo off
    for /l %%a in (1,1,10) do echo %%a
    pause
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: %%BLAH or %BLAH%!??!?!?
    « Reply #2 on: February 24, 2010, 09:36:06 PM »
    also, it's only double-percent signs when in a batch file. you can type for commands on the command line, but you must use a single percent sign:

    Code: [Select]
    C:\Windows>@for /f "tokens=*" %P in ('dir /s /b') do @echo %P
    I was trying to dereference Null Pointers before it was cool.

    Prince_



      Beginner

      Thanked: 5
      Re: %%BLAH or %BLAH%!??!?!?
      « Reply #3 on: February 24, 2010, 10:58:14 PM »
      set a=1&call echo %%a%%

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: %%BLAH or %BLAH%!??!?!?
      « Reply #4 on: February 24, 2010, 11:08:48 PM »
      Code: [Select]
      Microsoft Windows XP [Version 5.1.2600
      (C) Copyright 1985-2001 Microsoft Corp

      d:\batch>set a=1&call echo %%a%%
      %1%

      d:\batch>
      ???

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: %%BLAH or %BLAH%!??!?!?
      « Reply #5 on: February 24, 2010, 11:09:58 PM »
      Code: [Select]
      Microsoft Windows XP [Version 5.1.2600
      (C) Copyright 1985-2001 Microsoft Corp

      d:\batch>set a=1&call echo %%a%%
      %1%

      d:\batch>
      ???

      my thoughts exactly... not sure what is being said with that...
      I was trying to dereference Null Pointers before it was cool.

      Prince_



        Beginner

        Thanked: 5
        Re: %%BLAH or %BLAH%!??!?!?
        « Reply #6 on: February 25, 2010, 12:52:56 AM »
        test it in a .bat file
        set a=1&call echo %%a%%

        greg



          Intermediate

          Thanked: 7
          Re: %%BLAH or %BLAH%!??!?!?
          « Reply #7 on: February 25, 2010, 01:28:17 AM »
          test it in a .bat file



          C:\>type   a25.bat
          Code: [Select]
          @echo off

          REM "Test it in a .bat file"

          set a=1&call echo %%a%%

          Output:

          C:\> a25.bat
          1

          C:\>

           (| (|
          Have a Nice Day

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: %%BLAH or %BLAH%!??!?!?
          « Reply #8 on: February 25, 2010, 09:11:15 AM »
          Not worth bananas. Please do not waster the bananas.