0

Example code:

    @echo off
    set money=0
    echo How Much Do You Want To Deposit?
    set /p "moneyPut=>"
    set /a money=%money% + %moneyPut%

Can this work?

  • 5
    Why didn't you just try it? –  Feb 28 '16 at 02:26
  • I did, it didn't function correctly. – YoungCoder Feb 28 '16 at 18:34
  • That's probably because of `>`. `<`, `>`, and `|` have special meaning and are the first thing parsed on a command line. If you want a prompt character see `choice /?` and `prompt /?`. –  Feb 28 '16 at 18:54
  • See here for a list of punctuation - http://stackoverflow.com/questions/31820569/trouble-with-renaming-folders-and-sub-folders-using-batch –  Feb 28 '16 at 19:01

2 Answers2

0

Yes that will work. The assignment of money= is the last thing that occurs. The current value of %money% is evaluated first, like most (all?) other programming languages.

modal_dialog
  • 733
  • 5
  • 12
0

To answer your question; yes, you can. The old value is simply overwritten with a new value. You can use the old value to define the new value though, just like you use the old value of money together with the value of moneyput, to define the new value of money, in your example code. I tested your example code, and found it to be working fine, so more information on how exactly you find it isn't working would be useful.

Alpha_Pi
  • 383
  • 2
  • 13