|
-
September 25th, 2014, 12:10 PM
#1
Help With Batch Code
I'm working on a project for my son. I want to imitate the code for the matrix in CMD using a .bat file.
~note: this is an example of whats going on, not the whole code
:start
@set /a bottomlimit = 0
@set /a upperlimit = 2
@set /a result1 = %bottomlimit% + %random% %% (%upperlimit% - %bottomlimit% + 1)
if %result1% == "2" set /a result1 = " " <- this is the part that is messing up, it doesnt change the 2 to a blank space and keeps echoing as 2
echo %result1%
goto start
-
September 25th, 2014, 12:26 PM
#2
Re: Help With Batch Code
This is a Visual C++ forum.
-
September 25th, 2014, 03:33 PM
#3
Re: Help With Batch Code
If you want to compare strings, you need to make the left-hand-side a string as well. And don't use /a when not performing a arithmetic assignment. You should also remove the spaces around "=" in your set commands (I don't use any spacing anywhere).
Code:
if "%result1%" == "2" set result1=" "
echo %result1%
I like to use this site for reference: http://ss64.com/nt/
gg
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|