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

Author Topic: Find out how many times a Batch is used.  (Read 6048 times)

0 Members and 1 Guest are viewing this topic.

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: Find out how many times a Batch is used.
« Reply #15 on: March 27, 2009, 11:11:45 AM »
that works- I still like my alternate datastream idea, though.
I was trying to dereference Null Pointers before it was cool.

uSlackr



    Rookie

  • A turtle on the information highway since 1989
  • Thanked: 2
    Re: Find out how many times a Batch is used.
    « Reply #16 on: April 07, 2009, 03:16:32 PM »
    How about this:

    Code: [Select]
    setlocal
    for /f %%a in (countit) do set count=%%a
    set /a count=count+1
    echo %count% >countit

    it saves the count in a file called countit and increments everytime its run
    \\uSlackr

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: Find out how many times a Batch is used.
    « Reply #17 on: April 07, 2009, 06:55:33 PM »
    How about this:

    Code: [Select]
    setlocal
    for /f %%a in (countit) do set count=%%a
    set /a count=count+1
    echo %count% >countit

    it saves the count in a file called countit and increments everytime its run


    Why use FOR, when if does the trick.

    Simple:
    Code: [Select]
    if not exist times.txt echo 0 > times.txt
    set /p times=<times.txt
    set /a times+=1
    echo %times% > times.txt
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.

    uSlackr



      Rookie

    • A turtle on the information highway since 1989
    • Thanked: 2
      Re: Find out how many times a Batch is used.
      « Reply #18 on: April 07, 2009, 10:13:21 PM »
      Why use FOR, when if does the trick.

      Simple:
      Code: [Select]
      if not exist times.txt echo 0 > times.txt
      set /p times=<times.txt
      set /a times+=1
      echo %times% > times.txt

      I suspect its 6 of one,  but I didn't know you could do that with set /p.  Cool tip.

      Thx

      \\uSlackr
      \\uSlackr

      Helpmeh



        Guru

      • Roar.
      • Thanked: 123
        • Yes
        • Yes
      • Computer: Specs
      • Experience: Familiar
      • OS: Windows 8
      Re: Find out how many times a Batch is used.
      « Reply #19 on: April 08, 2009, 02:46:45 PM »
      I suspect its 6 of one,  but I didn't know you could do that with set /p.  Cool tip.

      Thx

      \\uSlackr

      I think that set is the most usefull command (that I can use...)
      Where's MagicSpeed?
      Quote from: 'matt'
      He's playing a game called IRL. Great graphics, *censored* gameplay.