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

Author Topic: %dd% specs  (Read 4806 times)

0 Members and 1 Guest are viewing this topic.

tommyroyall

    Topic Starter


    Rookie

    Thanked: 1
    %dd% specs
    « on: February 24, 2010, 07:37:24 PM »
    Could I put something like "if %dd%==monday goto :MONDAY" or would it be different?

    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: %dd% specs
    « Reply #1 on: February 24, 2010, 08:37:32 PM »
    I just checked for you:

    ?"if %dd%==monday goto :MONDAY"="if %dd%==monday goto :MONDAY"
    True

    They are the same. Of course really I have no idea what your talking about or what %dd% is. Also you don't need to use the Colon in a goto, just for the label.
    I was trying to dereference Null Pointers before it was cool.

    tommyroyall

      Topic Starter


      Rookie

      Thanked: 1
      Re: %dd% specs
      « Reply #2 on: February 25, 2010, 04:51:10 PM »
      Isn't %dd% to get the day? I've used that before.

      greg



        Intermediate

        Thanked: 7
        Re: %dd% specs
        « Reply #3 on: February 25, 2010, 06:02:31 PM »
        Isn't %dd% to get the day? I've used that before.


        C:\batch>type  tezt.bat
        Code: [Select]
        @echo off
        FOR /F "TOKENS=1* DELIMS= " %%A IN ('date /t') DO (
        SET CDATE=%%B
        echo CDATE=%CDATE%
        )
        pause

        FOR /F "TOKENS=1,2 eol=/ DELIMS=/" %%A IN ('echo %CDATE%') DO (
        SET mm=%%A
        echo mm=%mm%
        )
        pause

        FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO (
        SET dd=%%B
        echo dd=%dd%
        )
        FOR /F "TOKENS=2,3 DELIMS=/" %%A IN ('echo %CDATE%') DO (
        SET yyyy=%%B
        SET date=%mm%%dd%%yyyy%
        echo date=%date%
        )

        Output:

        C:\batch>tezt.bat

        CDATE=02/25/2010
        Press any key to continue . . .
        mm=02
        Press any key to continue . . .
        dd=25
        date=02252010

        C:\batch>
        Have a Nice Day

        greg



          Intermediate

          Thanked: 7
          Re: %dd% specs
          « Reply #4 on: February 25, 2010, 07:14:58 PM »
          Could I put something like "if %dd%==monday goto :MONDAY" or would it be different?


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

          set dd=%date:~0,3%
          echo dd=%dd%

          if %dd%==Mon goto monday
          echo Today is not monday
          goto eof

          :monday

          echo Hello Monday
          pause

          :eof

          Output:

          C:\batch>tommy.bat
          dd=Mon
          Hello Monday
          Press any key to continue . . .
          C:\batch>

          Output:

          C:\batch>tommy.bat
          dd=Thu
          Today is not monday

          C:\batch>

          http://www.dostips.com/DtTipsStringManipulation.php
          Have a Nice Day